OpenAI-compatible
POST/v1/chat/completions

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

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

Response

{
  "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 }
}