curl -N -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": "你是一个简洁的技术助手。" },
{ "role": "user", "content": "用三点说明 API 网关的作用。" }
],
"stream": true,
"stream_options": {
"include_usage": true
}
}'
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-5.5","choices":[{"index":0,"delta":{"role":"assistant","content":"API"},"finish_reason":null}]}
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-5.5","choices":[{"index":0,"delta":{"content":" 网关"},"finish_reason":null}]}
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-5.5","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":26,"completion_tokens":38,"total_tokens":64}}
data: [DONE]
{
"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 兼容格式发起对话,并显式开启 SSE 流式返回。
POST
https://www.geeknow.top
/
v1
/
chat
/
completions
curl -N -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": "你是一个简洁的技术助手。" },
{ "role": "user", "content": "用三点说明 API 网关的作用。" }
],
"stream": true,
"stream_options": {
"include_usage": true
}
}'
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-5.5","choices":[{"index":0,"delta":{"role":"assistant","content":"API"},"finish_reason":null}]}
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-5.5","choices":[{"index":0,"delta":{"content":" 网关"},"finish_reason":null}]}
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-5.5","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":26,"completion_tokens":38,"total_tokens":64}}
data: [DONE]
{
"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、Claude、Gemini、DeepSeek、Qwen 等上游模型。本页展示流式写法,适合需要边生成边展示的聊天、Agent 和长文本生成场景。如果未传
stream,接口默认按非流式返回。若希望固定获得流式响应,请显式传入 "stream": true。请求体
array<object>
required
按时间顺序排列的对话消息。常见角色为
system、user、assistant、tool。string | array
required
消息内容。字符串表示纯文本;数组表示多模态内容,支持
text、image_url、input_audio、file、video_url。boolean
required
设为
true 后响应为 text/event-stream,每个片段以 data: 推送,结束时返回 data: [DONE]。boolean
在流式最后一条消息中携带 token 用量统计。仅部分上游模型支持。
integer
限制最大生成 token 数。部分推理模型建议改用
max_completion_tokens。integer
限制最大补全 token 数,包含推理 token。适合支持 reasoning 的模型。
number
采样温度,常用范围
0 到 2。较低值更稳定,较高值更多样。number
核采样参数,常用范围
0 到 1。通常不建议同时大幅调整 temperature 和 top_p。array<object>
函数调用工具列表,格式兼容 OpenAI
tools。string | object
控制模型是否调用工具。常见值为
auto、none、required,也可指定某个函数。object
指定输出格式,例如
{ "type": "json_object" } 或 json_schema。string
推理强度。常见值包括
none、minimal、low、medium、high、xhigh;是否生效取决于模型。高强度不一定更好,建议按业务评测选择。请求示例
curl -N -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": "你是一个简洁的技术助手。" },
{ "role": "user", "content": "用三点说明 API 网关的作用。" }
],
"stream": true,
"stream_options": {
"include_usage": true
}
}'
多模态流式
图片 URL 需要能被上游模型公网下载;本地图片请先上传图床。base64 图片可使用data:image/png;base64,... 形式放在 image_url.url。
curl -N -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": [
{ "type": "text", "text": "概括这张图表的主要结论。" },
{ "type": "image_url", "image_url": { "url": "https://YOUR_IMAGE_HOST/path/chart.png", "detail": "high" } }
]
}
],
"stream": true
}'
响应示例
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-5.5","choices":[{"index":0,"delta":{"role":"assistant","content":"API"},"finish_reason":null}]}
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-5.5","choices":[{"index":0,"delta":{"content":" 网关"},"finish_reason":null}]}
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-5.5","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":26,"completion_tokens":38,"total_tokens":64}}
data: [DONE]
{
"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
本次生成的响应 ID。
string
流式响应固定为
chat.completion.chunk。object
增量内容。可能包含
role、content、reasoning_content 或 tool_calls。string
结束原因,常见值为
stop、length、tool_calls。object
用量统计。只有上游返回用量且启用
stream_options.include_usage 时才一定出现。