Appearance
聊天补全 API
请求示例
bash
curl https://gpuaihub.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-5.6-sol",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"temperature": 0.7,
"max_tokens": 1000
}'请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 是 | 模型 ID,如 gpt-5.6-sol、claude-sonnet-4-6 |
| messages | array | 是 | 消息列表,包含 role 和 content |
| temperature | number | 否 | 采样温度,0-2,默认 1 |
| max_tokens | number | 否 | 最大生成 token 数 |
| stream | boolean | 否 | 是否流式输出,默认 false |
| top_p | number | 否 | 核采样参数,默认 1 |
| frequency_penalty | number | 否 | 频率惩罚,-2 到 2,默认 0 |
| presence_penalty | number | 否 | 存在惩罚,-2 到 2,默认 0 |
响应示例
json
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-5.6-sol",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}