Chat Completions
请求端点
text
POST https://api.dream-link.pro/v1/chat/completions请求体
json
{
"model": "gemini-2.5-flash",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is quantum computing?"}
],
"stream": false,
"temperature": 0.7,
"max_tokens": 2048,
"top_p": 0.9
}参数说明
| Parameter | Type | 是 | 默认值 | Description |
|---|---|---|---|---|
| model | string | 是 | — | 模型 ID |
| messages | array | 是 | — | 消息数组,至少包含一条消息 |
| stream | boolean | 否 | false | 是否使用流式输出 |
| temperature | number | 否 | 模型默认 | 采样温度,0-2 之间 |
| max_tokens | number | 否 | 4096 | 最大生成 token 数 |
| top_p | number | 否 | 模型默认 | 核采样参数 |
| tools | array | 否 | — | 工具定义 |
| tool_choice | string/object | 否 | "auto" | 工具调用策略 |
消息格式
| Role | Description | Content Type |
|---|---|---|
| system | 系统提示词 | string |
| user | 用户输入 | string | ContentPart[] |
| assistant | 模型回复 | string | null |
| tool | 工具调用结果 | string |
响应格式
json
{
"id": "chatcmpl-a1b2c3d4e5f6...",
"object": "chat.completion",
"created": 1700000000,
"model": "gemini-2.5-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Quantum computing is..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 150,
"total_tokens": 175
}
}finish_reason 说明
| Value | Description |
|---|---|
| stop | 正常结束 |
| length | 达到 max_tokens 上限 |
| tool_calls | 模型请求调用工具 |
| content_filter | 内容被安全过滤 |