Claude 對話
post/v1/messages
Anthropic Claude Messages API 格式。必須提供 anthropic-version 請求標頭。
驗證
把 OLETOKEN 的 API Key 作為 Bearer Token 放進 Authorization 請求標頭。金鑰在控制台的「API 金鑰」頁建立。
Authorization: Bearer $OLETOKEN_API_KEY請求參數
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
| anthropic-versionheader | string | Anthropic API 版本 | |
| x-api-keyheader | string | — | Anthropic API 金鑰(選填;亦可使用 Bearer Token) |
請求主體
Content-Type:application/json
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
| model | string | — | |
| messages | ClaudeMessage[] | — | |
| role | stringuserassistant | — | |
| content | string | object[] | — | |
| type | stringtextimagetool_usetool_result | — | — |
| text | string | — | — |
| source | object | — | — |
| type | stringbase64url | — | — |
| media_type | string | — | — |
| data | string | — | — |
| url | string | — | — |
| id | string | — | — |
| name | string | — | — |
| input | object | — | — |
| tool_use_id | string | — | — |
| content | string | — | — |
| system | string | object[] | — | — |
| cache_control | object | — | — |
| inference_geo | string | — | — |
| max_tokens | integer≥ 1 | — | |
| temperature | number0–1 | — | — |
| top_p | number | — | — |
| top_k | integer | — | — |
| stream | boolean | — | — |
| stop_sequences | string[] | — | — |
| tools | object[] | — | — |
| name | string | — | — |
| description | string | — | — |
| input_schema | object | — | — |
| tool_choice | object | — | — |
| type | stringautoanytoolnone | — | — |
| name | string | — | — |
| thinking | object | — | — |
| type | stringenableddisabled | — | — |
| budget_tokens | integer | — | — |
| context_management | object | — | — |
| output_config | object | — | — |
| output_format | object | — | — |
| container | string | object | — | — |
| mcp_servers | object[] | — | — |
| metadata | object | — | — |
| user_id | string | — | — |
| speed | stringstandardfast | — | — |
| service_tier | stringautostandard_only | — | — |
回應
200已建立回應
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
| id | string | — | — |
| type | string | — | — |
| role | string | — | — |
| content | object[] | — | — |
| type | string | — | — |
| text | string | — | — |
| model | string | — | — |
| stop_reason | stringend_turnmax_tokensstop_sequencetool_use | — | — |
| usage | object | — | — |
| input_tokens | integer | — | — |
| output_tokens | integer | — | — |
| cache_creation_input_tokens | integer | — | — |
| cache_read_input_tokens | integer | — | — |
請求範例
curl -X POST 'https://api.oletoken.ai/v1/messages' \
-H "Authorization: Bearer $OLETOKEN_API_KEY" \
-H 'anthropic-version:' \
-H 'x-api-key:' \
-H 'Content-Type: application/json' \
-d '{
"model": "claude-3-opus-20240229",
"messages": [],
"max_tokens": 0
}'
