Skip to main content
POST
/
v1
/
chat
/
completions
Error
A valid request URL is required to generate request examples
{}
POST /v1/chat/completions 是 kapon 接入 GLM 的默认入口。

基础请求

curl -X POST "https://models.kapon.cloud/v1/chat/completions" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-4.7",
    "messages": [
      {"role": "system", "content": "你是一个简洁的技术助手。"},
      {"role": "user", "content": "用三句话介绍 GLM。"}
    ],
    "max_tokens": 256
  }'

GLM 特有能力

thinking

GLM OpenAI 兼容入口支持透传 thinking 对象:
{
  "model": "glm-5.1",
  "thinking": {
    "type": "disabled"
  }
}
GLM 的联网搜索不是普通 function tool。你需要传入完整的原生 web_search 子对象,详见 GLM 联网搜索

什么时候用这个入口

  • 你正在使用 OpenAI SDK、OpenAI 风格的网关、或现有 chat/completions 代码路径
  • 你需要统一接入多个 provider,同时保留 GLM 的少量原生扩展字段

什么时候不要用这个入口

  • 你的应用明确依赖 Anthropic Messages 协议、Message blocks 或 Anthropic SDK
  • 你只想接入 GLM 的 Anthropic 兼容能力,此时应使用 Anthropic 兼容

返回结果

普通文本调用返回标准 OpenAI 风格的:
  • choices[].message.content
  • usage
  • reasoning_content(当上游返回时)
如果请求里使用了 web_search,并且上游返回搜索证据,响应顶层还会出现:
{
  "web_search": [
    {
      "title": "Current Local Time in Beijing, Beijing Municipality, China",
      "link": "https://www.timeanddate.com/worldclock/china/beijing",
      "refer": "ref_1"
    }
  ]
}

Authorizations

Authorization
string
header
required

Authorization: Bearer

Body

application/json

The body is of type object.

Response

200 - application/json

OK

The response is of type object.