curl --request POST \
--url https://direct.evolink.ai/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "glm-5.3-flash",
"input": "请用一句话介绍你自己。",
"max_output_tokens": 1024,
"reasoning": {
"effort": "low"
}
}
'{
"id": "response_demo",
"object": "response",
"created_at": 1789971757,
"model": "glm-5.3-flash",
"status": "completed",
"output": [
{
"type": "message",
"id": "message_demo",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "你好,我是 GLM,可以帮你完成对话、写作和代码任务。",
"annotations": []
}
]
}
],
"usage": {
"input_tokens": 17,
"output_tokens": 24,
"total_tokens": 41,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 0
}
},
"error": null
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}GLM 全模型接口 - Responses 快速开始
使用 model 与 input 调用 GLM,支持 glm-5.3、glm-5.3-flash、glm-5.3-flashx 与 glm-5.2。建议设置 max_output_tokens 为 1024 或更高,为推理和正文预留空间。
更多示例与模型差异见完整参数文档。
curl --request POST \
--url https://direct.evolink.ai/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "glm-5.3-flash",
"input": "请用一句话介绍你自己。",
"max_output_tokens": 1024,
"reasoning": {
"effort": "low"
}
}
'{
"id": "response_demo",
"object": "response",
"created_at": 1789971757,
"model": "glm-5.3-flash",
"status": "completed",
"output": [
{
"type": "message",
"id": "message_demo",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "你好,我是 GLM,可以帮你完成对话、写作和代码任务。",
"annotations": []
}
]
}
],
"usage": {
"input_tokens": 17,
"output_tokens": 24,
"total_tokens": 41,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 0
}
},
"error": null
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}https://direct.evolink.ai,对文本模型支持更好,支持长连接;https://api.evolink.ai 为备用地址。POST /v1/responses,通过 model 选择 glm-5.3、glm-5.3-flash、glm-5.3-flashx 或 glm-5.2。最少需要 model 和 input;示例额外设置输出预算与推理档位,便于直接开始。
input,输出上限使用 max_output_tokens,推理强度使用 reasoning.effort。glm-5.3、glm-5.3-flash 与 glm-5.3-flashx 的实际思考档位为 low、high、max;兼容 xhigh → max、medium → high、minimal / none → low。minimal 与 none 不会关闭 5.3 系列的思考,思考 token 仍按输出计费。读取正文
响应的output 可能同时包含推理、正文和工具调用。遍历 type="message" 中的 output_text 内容块,不要假设第一项就是正文。
假设已将响应 JSON 解析为 response,可以这样提取文本:
text = "".join(
part["text"]
for item in response.get("output", [])
if item.get("type") == "message"
for part in item.get("content", [])
if part.get("type") == "output_text"
)
print(text)
max_output_tokens 包含思考与正文,建议从 1024 起按任务调整。若 status="incomplete" 且 incomplete_details.reason="max_output_tokens",请调高上限;预算耗尽时可能只有推理项,没有正文。授权
在 Authorization 请求头中传入 Bearer YOUR_API_KEY。
请求体
选择 GLM 模型。四个型号均支持本接口的文本调用。
| 模型 ID | 输入能力 | 推理参数注意事项 |
|---|---|---|
glm-5.3 | 文本 | 实际思考档位为 low / high / max;支持兼容取值,见 reasoning;不能关闭思考 |
glm-5.3-flash | 文本、图像 | 同上;图像使用 input_image 内容块 |
glm-5.3-flashx | 文本、图像 | 同 glm-5.3;图像使用 input_image 内容块 |
glm-5.2 | 文本 | 传入 none 仍可能产生推理 token,不保证关闭思考 |
不同模型支持的能力有所不同,请查看对应型号的说明。
glm-5.3, glm-5.3-flash, glm-5.3-flashx, glm-5.2 "glm-5.3-flash"
必填。纯文本字符串,或 Responses 输入项数组。数组支持消息、回传的模型输出项与 function_call_output。多轮对话可在每次请求中携带完整历史;系统提示词推荐作为 role=system 消息放在数组首项。图片使用 input_image,仅 glm-5.3-flash 与 glm-5.3-flashx 支持。不要使用 Chat Completions 的 messages / image_url 内容块格式。
"请用一句话介绍你自己。"
本次生成的输出 token 上限,包含推理 token。建议从 1024 起按任务调整。过小可能在思考阶段耗尽预算,只返回 reasoning 项而没有正文;检查 status 和 incomplete_details。不要改写为 max_tokens。
x >= 11024
开启 SSE 流式返回。正文读取 response.output_text.delta 的 delta;成功终态为 response.completed。遇到 response.incomplete、response.failed 或 error 也应结束本轮并处理。不要只等待 [DONE] 或连接断开。
Responses 使用嵌套 reasoning.effort,而非顶层 reasoning_effort 或 thinking。推理用量包含在 output_tokens 中;简单任务可能返回 reasoning_tokens=0,这不代表支持关闭思考。
Show child attributes
Show child attributes
响应
生成成功或返回不完整结果;检查 status。流式时返回 text/event-stream。
本轮响应 ID。用于 previous_response_id 时原样传入。
"response_demo"
"response"创建时间,Unix 秒。
"glm-5.3-flash"
completed 表示本轮生成结束,也可能仅有工具调用;incomplete 表示输出不完整。请同时检查 output 和 error。
completed, incomplete, failed, in_progress, queued 有序输出项。遍历 type=message 的 content 中 type=output_text 的 text 得到正文。reasoning 可能在正文之前;function_call 轮次可能没有正文。不要固定读取 output[0]。
Show child attributes
Show child attributes
可选的正文聚合字段,可能缺失。通用客户端应遍历 output。
Show child attributes
Show child attributes
响应错误;成功时通常为 null。
Show child attributes
Show child attributes
Show child attributes
Show child attributes