🎁 新人 免费注册,送 10 次调用,最高 $1,免绑卡。

Chat Completions

POST /v1/chat/completions

为给定的聊天对话创建模型响应。兼容 OpenAI Chat Completions API。

请求体

参数类型说明
model*string要使用的模型 ID(例如 gpt-5.4、qwen3.5-flash、gemini-2.5-flash)。
messages*array对话中的消息列表。每一项都包含 role 和 content。
streamboolean若为 true,则返回 SSE 事件流。默认值:false。
temperaturenumber采样温度 0–2。值越高 = 越随机。默认值:1。
max_tokensinteger要生成的最大 token 数。上限取决于模型。
top_pnumber核采样概率。0–1。默认值:1。
stopstring[]最多 4 个序列,生成在遇到这些序列时停止。
ninteger要生成的补全选项数量。默认值:1。

示例请求

POST /v1/chat/completions
Authorization: Bearer YOUR_API_KEY

{
  "model": "gpt-5.4-mini",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user",   "content": "What is the capital of France?"}
  ],
  "temperature": 0.7,
  "max_tokens": 256
}

示例响应

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1714000000,
  "model": "qwen3.5-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The capital of France is Paris."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 26,
    "completion_tokens": 9,
    "total_tokens": 35
  }
}

该端点会路由到网关背后的所有提供商——选择一个 model,在 model price comparison 中并排比较按 token 的价格。