curl -X POST https://www.geeknow.top/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [
{ "role": "system", "content": "你是一个 API 文档助手,回答要简洁。" },
{ "role": "user", "content": "生成一个接口说明摘要。" }
],
"max_completion_tokens": 200,
"stream": false
}'
{
"id": "chatcmpl_abc123",
"object": "chat.completion",
"created": 1735689600,
"model": "gpt-5.5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "该接口接收统一对话消息,并根据模型生成一次性完整回复。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 31,
"completion_tokens": 24,
"total_tokens": 55
}
}
{
"error": {
"message": "field model is required",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "用户额度不足",
"type": "new_api_error",
"param": "",
"code": "insufficient_user_quota"
}
}
{
"error": {
"message": "当前请求频率过高,请稍后再试",
"type": "new_api_error",
"param": "",
"code": "too_many_requests"
}
}
{
"error": {
"message": "bad response body",
"type": "new_api_error",
"param": "",
"code": "bad_response_body"
}
}
文本系列
Chat Completions(非流式)
使用 OpenAI Chat Completions 兼容格式发起对话,并一次性返回完整结果。
POST
https://www.geeknow.top
/
v1
/
chat
/
completions
curl -X POST https://www.geeknow.top/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [
{ "role": "system", "content": "你是一个 API 文档助手,回答要简洁。" },
{ "role": "user", "content": "生成一个接口说明摘要。" }
],
"max_completion_tokens": 200,
"stream": false
}'
{
"id": "chatcmpl_abc123",
"object": "chat.completion",
"created": 1735689600,
"model": "gpt-5.5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "该接口接收统一对话消息,并根据模型生成一次性完整回复。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 31,
"completion_tokens": 24,
"total_tokens": 55
}
}
{
"error": {
"message": "field model is required",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "用户额度不足",
"type": "new_api_error",
"param": "",
"code": "insufficient_user_quota"
}
}
{
"error": {
"message": "当前请求频率过高,请稍后再试",
"type": "new_api_error",
"param": "",
"code": "too_many_requests"
}
}
{
"error": {
"message": "bad response body",
"type": "new_api_error",
"param": "",
"code": "bad_response_body"
}
}
Chat Completions(非流式)
适用于后台任务、结构化输出、短问答和不需要实时展示生成过程的场景。省略stream 或传入 false 时,接口一次性返回完整 chat.completion 对象。
请求体
array<object>
required
对话消息数组。每条消息至少包含
role 与 content。常见角色为 system、developer、user、assistant、tool。第三方兼容接入建议优先用 system 放全局指令;如果明确按 OpenAI 新模型语义接入,可用 developer 表示应用开发者指令。string | array
消息内容。字符串表示纯文本;数组可传多模态内容,例如
{ "type": "text" } 与 { "type": "image_url" }。图片 URL、base64 和本地图片上传处理见 图像输入与图床上传。boolean
省略或传
false 时为非流式响应。object
指定输出格式。常用于 JSON 输出或 JSON Schema 结构化输出。结构化输出对模型能力有要求,建议先用小 schema 验证。
array<object>
函数调用工具列表。
string | object
控制工具调用策略。
number
采样温度。默认值由上游模型决定。
number
核采样参数。
integer
最大生成 token 数。部分新推理模型也支持或更推荐
max_completion_tokens。integer
最大补全 token 数,通常包含推理 token。对 GPT-5 系列等推理模型更明确。
number
随机种子。上游支持时可提升复现性。
string
推理强度。常见值包括
none、minimal、low、medium、high、xhigh;是否生效取决于模型。延迟敏感场景可先评估 low,质量优先场景再逐级提高。请求示例
curl -X POST https://www.geeknow.top/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [
{ "role": "system", "content": "你是一个 API 文档助手,回答要简洁。" },
{ "role": "user", "content": "生成一个接口说明摘要。" }
],
"max_completion_tokens": 200,
"stream": false
}'
结构化输出
curl -X POST https://www.geeknow.top/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [
{ "role": "user", "content": "提取这句话的主题和语气:这个版本发布节奏很稳。" }
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "analysis",
"strict": true,
"schema": {
"type": "object",
"additionalProperties": false,
"properties": {
"topic": { "type": "string" },
"tone": { "type": "string" }
},
"required": ["topic", "tone"]
}
}
}
}'
图像输入
curl -X POST https://www.geeknow.top/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4-7",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "这张图片的主要颜色是什么?" },
{
"type": "image_url",
"image_url": {
"url": "https://YOUR_IMAGE_HOST/path/image.png",
"detail": "high"
}
}
]
}
],
"max_tokens": 128
}'
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,BASE64_IMAGE_DATA"
}
}
响应示例
{
"id": "chatcmpl_abc123",
"object": "chat.completion",
"created": 1735689600,
"model": "gpt-5.5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "该接口接收统一对话消息,并根据模型生成一次性完整回复。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 31,
"completion_tokens": 24,
"total_tokens": 55
}
}
{
"error": {
"message": "field model is required",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "用户额度不足",
"type": "new_api_error",
"param": "",
"code": "insufficient_user_quota"
}
}
{
"error": {
"message": "当前请求频率过高,请稍后再试",
"type": "new_api_error",
"param": "",
"code": "too_many_requests"
}
}
{
"error": {
"message": "bad response body",
"type": "new_api_error",
"param": "",
"code": "bad_response_body"
}
}
响应字段
string | null
模型生成的文本内容。发生工具调用时可能为
null。array<object>
模型请求调用的函数工具。
object
本次请求的 token 用量。