Skip to main content
POST
/
zrag
/
agent
/
chat
问答 Agent 对话(流式)
curl --request POST \
  --url https://open.bigmodel.cn/api/zrag/agent/chat \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "messages": [
    {
      "role": "user",
      "content": "公司的年假制度是什么?"
    }
  ],
  "model": "glm-5v-turbo",
  "temperature": 0.2,
  "max_steps": 10,
  "retrieval": {
    "know_ids": [
      "123"
    ],
    "top_k": 8,
    "top_n": 10,
    "enable_rerank": false
  }
}
'
{
  "type": "session_created",
  "sessionId": "<string>",
  "messageId": "<string>",
  "data": "<string>",
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123,
    "total_calls": 123,
    "prompt_tokens_details": {
      "cached_tokens": 123
    },
    "completion_tokens_details": {
      "reasoning_tokens": 123
    }
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.bigmodel.cn/llms.txt

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

Authorizations

Authorization
string
header
required

使用以下格式进行身份验证:Bearer

Headers

X-Session-Id
string

会话 ID,续聊时传入

Body

application/json
messages
object[]
required

当前消息列表,支持多模态内容

retrieval
object
required

检索预设参数。预设后 LLM 仅决定是否调用检索,无需自行填写参数

model
string
default:glm-5v-turbo

LLM 模型名称,默认为 glm-5v-turbo

temperature
number
default:0.7

采样温度,默认为 0.7

max_steps
integer
default:10

最大推理步数,默认为 10

enable_thinking
boolean
default:false

是否启用思考模式。启用后模型输出推理过程,通过 reasoning 事件流式返回

Response

SSE 流式响应,返回 AgentStreamEvent 事件流

SSE 事件流中的单个事件对象

type
enum<string>

事件类型

Available options:
session_created,
reasoning,
thought,
tool_call,
tool_result,
answer,
done,
error
sessionId
string

会话 ID

messageId
string

消息 ID(仅 done 事件)

data

事件负载,结构取决于 type

usage
object

Token 用量信息(仅 done 事件)