> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prismgateway.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Code

> ชี้ Claude Code และ Anthropic SDK มาที่ Prism

# Claude Code

Prism รองรับ Anthropic Messages API แบบ native ที่ `POST /v1/messages` ดังนั้น
Claude Code และ Anthropic SDK ตัวจริงใช้กับ Prism ได้ด้วย environment variable
สามตัว ไม่ต้องแก้โค้ด

## Claude Code

```bash theme={null}
export ANTHROPIC_BASE_URL=https://api.prism.example.com
export ANTHROPIC_AUTH_TOKEN=sk-prism-your-key
export ANTHROPIC_MODEL=anthropic/claude-opus-5

claude
```

ใช้ model id ของ Prism ไม่ใช่ของ Anthropic ตรง ๆ — `anthropic/claude-opus-5`
ไม่ใช่ `claude-opus-5` เพราะ Prism แปลงผ่าน catalog ซึ่งเป็นตัวที่บังคับใช้ราคา
และ model policy ขององค์กรคุณ

## Anthropic SDK

```ts theme={null}
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://api.prism.example.com",
  apiKey: process.env.PRISM_API_KEY,
});

const message = await client.messages.create({
  model: "anthropic/claude-opus-5",
  max_tokens: 1024,
  messages: [{ role: "user", content: "สวัสดี" }],
});
```

รองรับทั้ง `x-api-key` และ `Authorization: Bearer` ไคลเอนต์ส่งแบบไหนก็ใช้ได้

## สิ่งที่รองรับ

* ทั้งแบบ non-streaming และ streaming (`stream: true`, ครบทุก event ของ Anthropic SSE)
* `system` เป็นสตริงหรือเป็นลิสต์ของ text block
* content block แบบข้อความและรูป (ทั้ง base64 และ URL)
* `tools`, `tool_choice`, `tool_use` และ `tool_result` — agent loop ทำงานได้
* `temperature`, `top_p`, `stop_sequences`

`max_tokens` เป็นฟิลด์บังคับเหมือนฝั่ง Anthropic Prism ไม่ใส่ค่า default ให้
เพราะ `max_tokens` คือค่าที่ระบบใช้กันวงเงินเครดิตของ request ถ้าใส่ default
เงียบ ๆ จะกลายเป็นกันวงเงินในจำนวนที่คุณไม่เคยขอ

## การคิดเงินเหมือนกันทุกอย่าง

`/v1/messages` เป็นชั้นแปลงรูปแบบบนเส้นทางเดียวกับ `/v1/chat/completions` — auth
เดียวกัน การจองเครดิตเดียวกัน การคิดหน่วยเดียวกัน request หนึ่งราคาเท่ากันไม่ว่า
เรียกผ่านโปรโตคอลไหน และ `x-prism-trace-id` ใน response ใช้ค้นย้อนหลังใน
[usage](/th/usage) ได้เหมือนกัน

## Error

Error กลับมาในรูปแบบของ Anthropic:

```json theme={null}
{ "type": "error", "error": { "type": "authentication_error", "message": "invalid api key" } }
```

`402 payment_required` ของ Prism (เครดิตหมด) ไม่มีคู่ที่ตรงกันฝั่ง Anthropic จะมา
เป็น `invalid_request_error` โดยเหตุผลจริงอยู่ในข้อความ ดูที่
[billing](/th/billing-and-trials)

## ที่ยังไม่รองรับ

Gemini `generateContent` และ `/v1/responses` ของ OpenAI ยังไม่มีตัวแปลง คำว่า
"unified gateway" ของ Prism หมายถึงความครอบคลุมของโมเดล ส่วนความครอบคลุมของ
โปรโตคอลตอนนี้คือ OpenAI-compatible บวก Anthropic-native

[English version](/claude-code)
