Skip to content

聊天补全

POST /v1/chat/completions

请求参数

参数类型必填说明
modelstring模型名称,如 gpt-4o
messagesarray对话消息列表
streamboolean是否流式返回,默认 false
temperaturenumber随机性,0~2,默认 1
max_tokensinteger最大生成 Token 数

请求示例

bash
curl https://www.meteorlink.net/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user",   "content": "Hello!"}
    ],
    "temperature": 0.7
  }'

流式请求

bash
curl https://www.meteorlink.net/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": true
  }'

响应示例

json
{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 19,
    "completion_tokens": 10,
    "total_tokens": 29
  }
}

Powered by MeteorLink