请求参数
Chat Completions 请求体字段说明与示例。
请求参数
POST /v1/chat/completions 使用 JSON 请求体,字段与 OpenAI Chat Completions 兼容。
参数说明
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
model | string | 是 | 模型 ID,见 支持模型列表 |
messages | array | 是 | 对话消息列表,每项含 role(system / user / assistant)与 content |
temperature | number | 否 | 采样温度,0–2,默认 1 |
max_tokens | integer | 否 | 最大生成 token 数 |
stream | boolean | 否 | 是否启用 SSE 流式输出,默认 false |
top_p | number | 否 | 核采样参数,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
}'