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"
    }
  ],
  "enable_thinking": true,
  "thinking": {
    "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

Response

200
application/json

成功响应

The response is of type object.