เอนด์พอยต์ที่เข้ากันได้กับ Anthropic Messages API สำหรับโมเดล AI โอเพนซอร์สจีนผ่าน AI Gateway
/api/ai/v1/anthropic/messages| พารามิเตอร์ | จำเป็น | คำอธิบาย |
|---|---|---|
Authorization | จำเป็น | Bearer YOUR_API_KEY |
anthropic-version | จำเป็น | ค่าคงที่ 2023-06-01 |
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
model | string | จำเป็น | ชื่อโมเดล เช่น deepseek-v4.1-flash, qwen3.8-max |
messages | array | จำเป็น | อาร์เรย์ข้อความในรูปแบบ |
max_tokens | integer | จำเป็น | จำนวนโทเค็นเอาต์พุตสูงสุด |
stream | boolean | ไม่บังคับ | เปิดการตอบสนองแบบสตรีม ตั้งค่าเป็น true สำหรับ SSE |
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
id | string | ตัวระบุการตอบสนองที่ไม่ซ้ำกัน |
model | string | โมเดลที่ใช้จริง |
content | string | เนื้อหาข้อความที่สร้าง |
usage | object | สถิติการใช้โทเค็น |
curl --location 'https://your-domain.com/api/ai/v1/anthropic/messages' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'anthropic-version: 2023-06-01' \
--data '{
"model": "deepseek-v4.1-flash",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, who are you?"}
]
}'import requests
response = requests.post(
"https://your-domain.com/api/ai/v1/anthropic/messages",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY",
"anthropic-version": "2023-06-01"
},
json={
"model": "deepseek-v4.1-flash",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, who are you?"}
]
}
)
print(response.json())curl --location 'https://your-domain.com/api/ai/v1/anthropic/messages' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'anthropic-version: 2023-06-01' \
--data '{
"model": "deepseek-v4.1-flash",
"max_tokens": 1024,
"stream": true,
"messages": [{"role": "user", "content": "Hello"}]
}'