Skip to main content
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-4o",
    "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-4o","choices":[{"index":0,"delta":{"role":"assistant","content":"API"},"finish_reason":null}]}

data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":" 网关"},"finish_reason":null}]}

data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":26,"completion_tokens":38,"total_tokens":64}}

data: [DONE]

Documentation Index

Fetch the complete documentation index at: https://docs.geeknow.top/llms.txt

Use this file to discover all available pages before exploring further.

通用对话接口(默认流式)

使用统一对话格式调用 OpenAI、Claude、Gemini、DeepSeek、Qwen 等上游模型。本文档以流式输出为默认写法,适合需要边生成边展示的聊天、Agent 和长文本生成场景。
本项目路由中 stream 未传时按非流式处理。若希望固定获得流式响应,请显式传入 "stream": true

请求体

model
string
required
模型名称。可通过 模型列表 查询当前 API Key 可用模型。
messages
array<object>
required
按时间顺序排列的对话消息。常见角色为 systemuserassistanttool
messages[].content
string | array
required
消息内容。字符串表示纯文本;数组表示多模态内容,支持 textimage_urlinput_audiofilevideo_url
stream
boolean
required
设为 true 后响应为 text/event-stream,每个片段以 data: 推送,结束时返回 data: [DONE]
stream_options.include_usage
boolean
在流式最后一条消息中携带 token 用量统计。仅部分上游模型支持。
max_tokens
integer
限制最大生成 token 数。部分推理模型建议改用 max_completion_tokens
max_completion_tokens
integer
限制最大补全 token 数,包含推理 token。适合支持 reasoning 的模型。
temperature
number
采样温度,常用范围 02。较低值更稳定,较高值更多样。
top_p
number
核采样参数,常用范围 01。通常不建议同时大幅调整 temperaturetop_p
tools
array<object>
函数调用工具列表,格式兼容 OpenAI tools
tool_choice
string | object
控制模型是否调用工具。常见值为 autononerequired,也可指定某个函数。
response_format
object
指定输出格式,例如 { "type": "json_object" }json_schema
reasoning_effort
string
推理强度。常见值为 lowmediumhigh,是否生效取决于模型。

请求示例

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-4o",
    "messages": [
      { "role": "system", "content": "你是一个简洁的技术助手。" },
      { "role": "user", "content": "用三点说明 API 网关的作用。" }
    ],
    "stream": true,
    "stream_options": {
      "include_usage": true
    }
  }'

多模态流式

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-4o",
    "messages": [
      {
        "role": "user",
        "content": [
          { "type": "text", "text": "概括这张图表的主要结论。" },
          { "type": "image_url", "image_url": { "url": "https://.../chart.png", "detail": "high" } }
        ]
      }
    ],
    "stream": true
  }'

响应示例

data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{"role":"assistant","content":"API"},"finish_reason":null}]}

data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":" 网关"},"finish_reason":null}]}

data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":26,"completion_tokens":38,"total_tokens":64}}

data: [DONE]

响应字段

id
string
本次生成的响应 ID。
object
string
流式响应固定为 chat.completion.chunk
choices[].delta
object
增量内容。可能包含 rolecontentreasoning_contenttool_calls
choices[].finish_reason
string
结束原因,常见值为 stoplengthtool_calls
usage
object
用量统计。只有上游返回用量且启用 stream_options.include_usage 时才一定出现。

相关接口