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