GLM 4.7

    z-ai/glm-4.7
    试验场

    综合能力均衡,中文理解与推理表现较好,通用任务适配面广。

    中文内容生成推理
    模态
    输入 / 输出价格
    $0.59 / $2.35M tokens
    上下文
    128000
    发布时间
    2025-12-22

    价格

    规格价格
    输入$0.59/ M tokens
    输出$2.35/ M tokens
    缓存读$0.55/ M tokens
    缓存写--

    快速开始

    可直接粘贴运行下方示例代码。Gate.AI API 与 OpenAI 兼容,多数 SDK 只需替换 base URL;切换模型时,只需修改模型 ID。

    1

    获取 API Key

    登录 Gate.AI 控制台,在「API Keys」页面创建一个新的密钥并妥善保管,请求时通过 Authorization 请求头携带该密钥。

    前往控制台创建密钥
    2

    发起请求

    向 Chat Completions 接口发送 POST 请求,传入模型 ID 与对话消息数组,即可获得模型回复。

    POSThttps://api.gate.ai/openai/v1/chat/completions
    curl --location "https://api.gate.ai/openai/v1/chat/completions" \
      --header "Authorization: Bearer {API_KEY}" \
      --header "Content-Type: application/json" \
      --data '{
      "model": "glm-4.7",
      "messages": [
        {"role": "user", "content": "Hello"}
      ]
    }'
    3

    处理响应与流式输出

    默认返回完整 JSON 响应;如需逐字返回,可在请求体中加入 "stream": true,并按 SSE 格式逐块解析 chunk。

    POSThttps://api.gate.ai/openai/v1/chat/completions
    curl --no-buffer --location "https://api.gate.ai/openai/v1/chat/completions" \
      --header "Authorization: Bearer {API_KEY}" \
      --header "Content-Type: application/json" \
      --data '{
      "model": "glm-4.7",
      "messages": [
        {"role": "user", "content": "Hello"}
      ],
      "stream": true
    }'

    端点

    基础 URL、请求方法和必需请求头均按当前模型的协议模板渲染。

    POSThttps://api.gate.ai/openai/v1/chat/completions
    字段
    值
    Authorization
    认证请求头,使用 Bearer {API_KEY} 格式传递 API Key
    Content-Type
    请求内容类型,固定为 application/json
    model
    模型 ID,当前模型为 glm-4.7
    messages
    按顺序排列的对话消息数组
    stream
    是否以 SSE 流式返回结果

    相关模型