Chat Completions
接口地址
text
POST https://seeknode.cn/v1/chat/completions
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型名称,如 gpt-5.4-mini |
messages | array | 是 | 对话消息列表 |
stream | boolean | 否 | 是否流式输出,默认 false |
temperature | number | 否 | 采样温度,0-2,默认 1 |
top_p | number | 否 | 核采样参数,0-1 |
max_tokens | integer | 否 | 最大输出 token 数 |
frequency_penalty | number | 否 | 频率惩罚,-2 到 2 |
presence_penalty | number | 否 | 存在惩罚,-2 到 2 |
seed | integer | 否 | 随机种子 |
tools | array | 否 | 工具/函数调用定义 |
请求示例
基础对话
bash
curl https://seeknode.cn/v1/chat/completions \
-H "Authorization: Bearer sk-你的令牌" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-mini",
"messages": [
{"role": "system", "content": "你是一个有用的助手。"},
{"role": "user", "content": "你好!"}
],
"temperature": 0.7,
"max_tokens": 1024
}'
流式输出
bash
curl https://seeknode.cn/v1/chat/completions \
-H "Authorization: Bearer sk-你的令牌" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-mini",
"messages": [{"role": "user", "content": "你好"}],
"stream": true
}'
多轮对话
bash
curl https://seeknode.cn/v1/chat/completions \
-H "Authorization: Bearer sk-你的令牌" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-mini",
"messages": [
{"role": "user", "content": "1+1等于几?"},
{"role": "assistant", "content": "1+1=2"},
{"role": "user", "content": "再加上3呢?"}
]
}'
工具调用(Function Calling)
bash
curl https://seeknode.cn/v1/chat/completions \
-H "Authorization: Bearer sk-你的令牌" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-mini",
"messages": [{"role": "user", "content": "北京的天气怎么样?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "获取指定城市的天气",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "城市名称"}
},
"required": ["location"]
}
}
}]
}'
视觉识别(多模态)
bash
curl https://seeknode.cn/v1/chat/completions \
-H "Authorization: Bearer sk-你的令牌" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-mini",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "请描述这张图片。"},
{
"type": "image_url",
"image_url": {"url": "https://example.com/image.jpg"}
}
]
}
]
}'
建议先在 Playground 用 Image URL 验证模型可用,再接入生产。
响应字段
返回结构与 OpenAI Chat Completions 一致,关键字段:
| 字段 | 说明 |
|---|---|
id | 本次响应 ID |
model | 实际响应使用的模型名 |
choices[].message.content | 模型输出文本 |
choices[].message.tool_calls | 工具调用(如有) |
usage.prompt_tokens | 输入 Token 数 |
usage.completion_tokens | 输出 Token 数 |
usage.total_tokens | 总 Token 数 |