登录

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
}

参数说明

ParameterType默认值Description
modelstring模型 ID
messagesarray消息数组,至少包含一条消息
streambooleanfalse是否使用流式输出
temperaturenumber模型默认采样温度,0-2 之间
max_tokensnumber4096最大生成 token 数
top_pnumber模型默认核采样参数
toolsarray工具定义
tool_choicestring/object"auto"工具调用策略

消息格式

RoleDescriptionContent 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 说明

ValueDescription
stop正常结束
length达到 max_tokens 上限
tool_calls模型请求调用工具
content_filter内容被安全过滤