POST/v1/messages

/v1/messages

Anthropic Messages 請求會被 Gateway 接受並正規化。

請求#

anthropic-version header 會被接受並原樣轉送。

curl https://api.atptoken.ai/v1/messages \
  -H "Authorization: Bearer atp-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model from GET /v1/models>",
    "max_tokens": 256,
    "messages": [{"role": "user", "content": "hi"}]
  }'

參數#

最上層的 system 欄位可以是字串,也可以是文字區塊陣列(區塊上的 cache_control 會被接受)。

欄位型別說明
modelstring · 必填來自 GET /v1/models 的模型 ID。
max_tokensinteger · 必填最大輸出 token 數(Anthropic 必填)。開 extended thinking 時思考預算也算在內——設太低會拿到內容為空的 200(見錯誤)。
messagesarray · 必填對話輪次,每則為 { role, content }。
systemstring or arraySystem prompt,字串或文字區塊陣列皆可。
temperaturenumber取樣溫度,0–1。
streamboolean以 Anthropic SSE 事件串流。
這頁有幫助嗎?