POST
/
chat
/
completions
curl --request POST \
  --url https://geekai.co/api/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-4o-mini",
  "messages": [
    {
      "content": "你是一个助手",
      "role": "system"
    },
    {
      "content": "你好",
      "role": "user"
    }
  ],
  "thinking": {
    "enabled": true,
    "budget_tokens": 16000,
    "reasoning_effort": "medium"
  },
  "stream": true,
  "enable_search": true,
  "search_config": {
    "engine": "glm/search-std",
    "deepable": false,
    "return_result": true
  },
  "retries": 3,
  "temperature": 1.3,
  "max_completion_tokens": 4096,
  "json_mode": true,
  "tools": [
    "<any>"
  ],
  "tool_choice": "auto",
  "parallel_tool_calls": true,
  "stop": [
    "<string>"
  ],
  "logprobs": false,
  "top_logprobs": 2,
  "frequency_penalty": 0,
  "presence_penalty": 0,
  "top_p": 1,
  "seed": 123,
  "n": 1,
  "metadata": {},
  "sess_id": ""
}'
{
  "id": "<string>",
  "created": 123,
  "model": "<string>",
  "object": "<string>",
  "choices": [
    {
      "index": 123,
      "message": {
        "role": "assistant",
        "content": "<string>",
        "reasoning_content": "<string>",
        "audio": {
          "id": "<string>",
          "data": "<string>",
          "expires_at": 123,
          "transcript": "<string>"
        },
        "tool_calls": [
          {
            "id": "<string>",
            "type": "function",
            "function": {
              "name": "<string>",
              "arguments": "<string>"
            }
          }
        ]
      },
      "finish_reason": "stop",
      "logprobs": {
        "content": [
          {
            "token": "<string>",
            "logprob": 123,
            "bytes": [
              123
            ],
            "top_logprobs": [
              {
                "token": "<string>",
                "logprob": 123,
                "bytes": [
                  123
                ]
              }
            ]
          }
        ]
      }
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123,
    "billed_units": 123,
    "prompt_tokens_details": {
      "text_tokens": 123,
      "audio_tokens": 123,
      "cached_tokens": 123,
      "image_tokens": 123,
      "video_tokens": 123,
      "citation_tokens": 123
    },
    "completion_tokens_details": {
      "text_tokens": 123,
      "audio_tokens": 123,
      "reasoning_tokens": 123,
      "accepted_prediction_tokens": 123,
      "rejected_prediction_tokens": 123
    }
  },
  "citations": [
    "<string>"
  ],
  "system_fingerprint": "<string>"
}

注:你可以在模型广场筛选查看系统支持的所有对话模型列表,对话模型请求/响应参数结构兼容 OpenAI,切换模型时只需修改对应的模型名称即可,若模型请求/响应参数和 OpenAI 不一致,极客智坊底层会自动转换对齐。 除百度文心一言和讯飞星火模型外,其他所有平台支持函数调用(具体支持模型以平台限制为准)。 调用 GPTs 模型 API 时,需要将 gpt-4-gizmo-* 中的 * 替换成对应 GPTs 的 gizmo_id,获取方式:从 GPTs URL 中提取,以 https://chatgpt.com/g/g-bo0FiWLY7-researchgpt 为例, 对应的 gizmo_id 为 g-bo0FiWLY7。

响应数据基础结构和 OpenAI 完全兼容,并在其基础上为适配其他模型新增功能,提供了对搜索引用链接(citations)、搜索计费次数(billed_units)、消息内容支持视频、图片/视频输入tokens、推理模式设置(thinking)的支持,响应结构会根据是否是流式输出而变化,可以参考下面的请求示例进行判断。

关于对话模型 API 调用示例,可以参考这里:文本对话

请求/响应参数明细

Authorizations

Authorization
string
header
required

JWT认证token

Body

application/json
model
string
default:gpt-4o-mini
required

对话模型

Example:

"gpt-4o-mini"

messages
object[]
required

消息列表

Example:
[
  { "content": "你是一个助手", "role": "system" },
  { "content": "你好", "role": "user" }
]
thinking
object

推理模式配置

stream
boolean
default:false

是否返回流式响应,默认false

Example:

true

是否启用联网搜索,默认false

Example:

true

search_config
object

联网搜索配置

retries
integer
default:0

自动重试次数,默认0

Example:

3

temperature
number
default:1.3

温度参数,默认1.3/0.65(取决于模型取值上限)

Example:

1.3

max_completion_tokens
integer

最大输出token数,默认设置为当前模型最大支持输出

Example:

4096

json_mode
boolean
default:false

是否设置响应格式为JSON对象,默认false

Example:

true

tools
any[]

可调用的工具函数列表

tool_choice
string
default:auto

工具函数调用方式

Example:

"auto"

parallel_tool_calls
boolean
default:true

是否并发调用工具函数

Example:

true

stop
string[]

停止生成的触发词列表

logprobs
boolean
default:false

是否返回token概率

Example:

false

top_logprobs
integer

每个位置返回的最可能token数

Example:

2

frequency_penalty
number
default:0

频率惩罚系数

Example:

0

presence_penalty
number
default:0

存在惩罚系数

Example:

0

top_p
number
default:1

核采样阈值

Example:

1

seed
integer

随机数种子

n
integer
default:1

生成结果数量

Example:

1

metadata
object

自定义元数据

sess_id
string

第三方应用自行实现的会话ID

Example:

""

Response

200
application/json
成功响应
id
string

请求ID

created
integer

请求创建Unix时间戳

model
string

对话使用的模型

object
string

响应对象类型

choices
object[]

生成的对话列表

usage
object

tokens消耗统计

citations
string[]

引用的文献/链接列表

system_fingerprint
string

系统指纹