透過 AI Gateway 使用 Anthropic Messages API 相容端點呼叫中國開源大模型。
/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 | 必要 | 最大輸出 Token 數 |
stream | boolean | 選填 | 啟用串流回應,設為 true 以使用 SSE |
| 參數 | 類型 | 說明 |
|---|---|---|
id | string | 唯一回應識別碼 |
model | string | 實際使用的模型 |
content | string | 產生的文字內容 |
usage | object | Token 使用統計 |
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"}]
}'