请求参数

请求参数

Chat Completions 请求体字段说明与示例。

请求参数

POST /v1/chat/completions 使用 JSON 请求体,字段与 OpenAI Chat Completions 兼容。

参数说明

参数名类型必填描述
modelstring模型 ID,见 支持模型列表
messagesarray对话消息列表,每项含 role(system / user / assistant)与 content
temperaturenumber采样温度,0–2,默认 1
max_tokensinteger最大生成 token 数
streamboolean是否启用 SSE 流式输出,默认 false
top_pnumber核采样参数,0–1

请求体示例

{
  "model": "gpt-4o-mini",
  "messages": [
    { "role": "system", "content": "You are a helpful assistant." },
    { "role": "user", "content": "Explain REST in one sentence." }
  ],
  "temperature": 0.7,
  "stream": false
}

cURL 示例

curl https://api.easyapi.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      { "role": "user", "content": "Hello!" }
    ],
    "temperature": 0.7
  }'

相关章节