curl --request POST \
--url https://open.bigmodel.cn/api/paas/v4/assistant \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"assistant_id": "65940acff94777010aa6b796",
"model": "glm-4-assistant",
"messages": [
{
"role": "user",
"content": "你好"
}
]
}'
{
"id": "<string>",
"request_id": "<string>",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "assistant",
"content": "<string>",
"reasoning_content": "<string>",
"audio": {
"id": "<string>",
"data": "<string>",
"expires_at": "<string>"
},
"tool_calls": [
{
"function": {
"name": "<string>",
"arguments": {}
},
"mcp": {
"id": "<string>",
"type": "mcp_list_tools",
"server_label": "<string>",
"error": "<string>",
"tools": [
{
"name": "<string>",
"description": "<string>",
"annotations": {},
"input_schema": {
"type": "object",
"properties": {},
"required": [
"<string>"
],
"additionalProperties": true
}
}
],
"arguments": "<string>",
"name": "<string>",
"output": {}
},
"id": "<string>",
"type": "<string>"
}
]
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}
与AI助手进行对话,支持流式和同步模式。
curl --request POST \
--url https://open.bigmodel.cn/api/paas/v4/assistant \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"assistant_id": "65940acff94777010aa6b796",
"model": "glm-4-assistant",
"messages": [
{
"role": "user",
"content": "你好"
}
]
}'
{
"id": "<string>",
"request_id": "<string>",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "assistant",
"content": "<string>",
"reasoning_content": "<string>",
"audio": {
"id": "<string>",
"data": "<string>",
"expires_at": "<string>"
},
"tool_calls": [
{
"function": {
"name": "<string>",
"arguments": {}
},
"mcp": {
"id": "<string>",
"type": "mcp_list_tools",
"server_label": "<string>",
"error": "<string>",
"tools": [
{
"name": "<string>",
"description": "<string>",
"annotations": {},
"input_schema": {
"type": "object",
"properties": {},
"required": [
"<string>"
],
"additionalProperties": true
}
}
],
"arguments": "<string>",
"name": "<string>",
"output": {}
},
"id": "<string>",
"type": "<string>"
}
]
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}
使用以下格式进行身份验证:Bearer <your api key>
业务处理成功
The response is of type object
.