POST/v1/chat/completions

/v1/chat/completions

用任何 OpenAI SDK 呼叫這個端點。Request body 完全沿用 OpenAI 的 chat completions schema。model 欄位必須是 GET /v1/models 回傳的值。

請求#

把 MODEL_ID 換成 GET /v1/models 回傳的模型 ID。

在 Studio 試
curl https://api.atptoken.ai/v1/chat/completions \
  -H "Authorization: Bearer $ATP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "messages": [{"role": "user", "content": "hi"}]
  }'

參數#

欄位型別說明
modelstring · 必填來自 GET /v1/models 的模型 ID。
messagesarray · 必填對話訊息,每則為 { role, content }。
max_tokensinteger最大輸出 token 數。reasoning 模型的思考也吃這個額度——設太低會拿到內容為空的 200(見錯誤)。
temperaturenumber取樣溫度,0–2。
streamboolean以 SSE chunk 串流回應。
toolsarrayTool/function 定義(OpenAI tool schema)。

回應#

{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "<model>",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "..." },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 9, "completion_tokens": 12, "total_tokens": 21 }
}
這頁有幫助嗎?