curl --request POST \
--url https://agent-api.bigmodel.cn/api/agent/managed/v1/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'zai-beta: <zai-beta>' \
--header 'zai-version: <zai-version>' \
--data '
{
"agent": "<string>",
"environment_id": "env_019e8f00-1ac2-7a6b-8000-3f2d5c8b9a01",
"agent_id": "<string>",
"title": null,
"metadata": {},
"initial_events": [],
"resources": [],
"vault_ids": []
}
'import requests
url = "https://agent-api.bigmodel.cn/api/agent/managed/v1/sessions"
payload = {
"agent": "<string>",
"environment_id": "env_019e8f00-1ac2-7a6b-8000-3f2d5c8b9a01",
"agent_id": "<string>",
"title": None,
"metadata": {},
"initial_events": [],
"resources": [],
"vault_ids": []
}
headers = {
"zai-version": "<zai-version>",
"zai-beta": "<zai-beta>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'zai-version': '<zai-version>',
'zai-beta': '<zai-beta>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
agent: '<string>',
environment_id: 'env_019e8f00-1ac2-7a6b-8000-3f2d5c8b9a01',
agent_id: '<string>',
title: null,
metadata: {},
initial_events: [],
resources: [],
vault_ids: []
})
};
fetch('https://agent-api.bigmodel.cn/api/agent/managed/v1/sessions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://agent-api.bigmodel.cn/api/agent/managed/v1/sessions")
.header("zai-version", "<zai-version>")
.header("zai-beta", "<zai-beta>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent\": \"<string>\",\n \"environment_id\": \"env_019e8f00-1ac2-7a6b-8000-3f2d5c8b9a01\",\n \"agent_id\": \"<string>\",\n \"title\": null,\n \"metadata\": {},\n \"initial_events\": [],\n \"resources\": [],\n \"vault_ids\": []\n}")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://agent-api.bigmodel.cn/api/agent/managed/v1/sessions"
payload := strings.NewReader("{\n \"agent\": \"<string>\",\n \"environment_id\": \"env_019e8f00-1ac2-7a6b-8000-3f2d5c8b9a01\",\n \"agent_id\": \"<string>\",\n \"title\": null,\n \"metadata\": {},\n \"initial_events\": [],\n \"resources\": [],\n \"vault_ids\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("zai-version", "<zai-version>")
req.Header.Add("zai-beta", "<zai-beta>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://agent-api.bigmodel.cn/api/agent/managed/v1/sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'agent' => '<string>',
'environment_id' => 'env_019e8f00-1ac2-7a6b-8000-3f2d5c8b9a01',
'agent_id' => '<string>',
'title' => null,
'metadata' => [
],
'initial_events' => [
],
'resources' => [
],
'vault_ids' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"zai-beta: <zai-beta>",
"zai-version: <zai-version>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "sess_01J...",
"type": "session",
"agent": {
"id": "<string>",
"type": "agent",
"name": "<string>",
"model": {
"id": "glm-5.3",
"speed": "standard",
"effort": "max"
},
"system": "<string>",
"description": "<string>",
"tools": [
{
"type": "agent_toolset_20260601",
"default_config": {
"enabled": true,
"permission_policy": {
"type": "always_allow"
}
},
"configs": [
{
"name": "read",
"enabled": true,
"permission_policy": {
"type": "always_allow"
}
}
]
}
],
"skills": [
{
"type": "custom",
"skill_id": "<string>",
"version": "<string>"
}
],
"mcp_servers": [
{
"type": "url",
"name": "knowledge-base",
"url": "https://mcp.example.com/mcp"
}
],
"version": 1,
"multiagent": null
},
"environment_id": "<string>",
"status": "idle",
"title": "<string>",
"metadata": {},
"resources": [
{
"type": "memory_store",
"memory_store_id": "<string>",
"name": "<string>",
"description": "<string>",
"access": "read_only",
"instructions": "<string>",
"mount_path": "<string>"
}
],
"vault_ids": [
"<string>"
],
"outcome_evaluations": [
{}
],
"stats": {
"active_seconds": 123,
"duration_seconds": 123
},
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_read_input_tokens": 123
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"archived_at": "<string>",
"budget": null
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>",
"details": {}
},
"request_id": "req_01J..."
}创建 Session
基于指定 Agent 和 Environment 创建 Session。可选择固定 Agent 版本或提供会话级覆盖,并可附带初始用户消息、File 或 Memory Store 资源及 Vault。点击 Try it 按钮可快速试用。
curl --request POST \
--url https://agent-api.bigmodel.cn/api/agent/managed/v1/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'zai-beta: <zai-beta>' \
--header 'zai-version: <zai-version>' \
--data '
{
"agent": "<string>",
"environment_id": "env_019e8f00-1ac2-7a6b-8000-3f2d5c8b9a01",
"agent_id": "<string>",
"title": null,
"metadata": {},
"initial_events": [],
"resources": [],
"vault_ids": []
}
'import requests
url = "https://agent-api.bigmodel.cn/api/agent/managed/v1/sessions"
payload = {
"agent": "<string>",
"environment_id": "env_019e8f00-1ac2-7a6b-8000-3f2d5c8b9a01",
"agent_id": "<string>",
"title": None,
"metadata": {},
"initial_events": [],
"resources": [],
"vault_ids": []
}
headers = {
"zai-version": "<zai-version>",
"zai-beta": "<zai-beta>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'zai-version': '<zai-version>',
'zai-beta': '<zai-beta>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
agent: '<string>',
environment_id: 'env_019e8f00-1ac2-7a6b-8000-3f2d5c8b9a01',
agent_id: '<string>',
title: null,
metadata: {},
initial_events: [],
resources: [],
vault_ids: []
})
};
fetch('https://agent-api.bigmodel.cn/api/agent/managed/v1/sessions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://agent-api.bigmodel.cn/api/agent/managed/v1/sessions")
.header("zai-version", "<zai-version>")
.header("zai-beta", "<zai-beta>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent\": \"<string>\",\n \"environment_id\": \"env_019e8f00-1ac2-7a6b-8000-3f2d5c8b9a01\",\n \"agent_id\": \"<string>\",\n \"title\": null,\n \"metadata\": {},\n \"initial_events\": [],\n \"resources\": [],\n \"vault_ids\": []\n}")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://agent-api.bigmodel.cn/api/agent/managed/v1/sessions"
payload := strings.NewReader("{\n \"agent\": \"<string>\",\n \"environment_id\": \"env_019e8f00-1ac2-7a6b-8000-3f2d5c8b9a01\",\n \"agent_id\": \"<string>\",\n \"title\": null,\n \"metadata\": {},\n \"initial_events\": [],\n \"resources\": [],\n \"vault_ids\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("zai-version", "<zai-version>")
req.Header.Add("zai-beta", "<zai-beta>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://agent-api.bigmodel.cn/api/agent/managed/v1/sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'agent' => '<string>',
'environment_id' => 'env_019e8f00-1ac2-7a6b-8000-3f2d5c8b9a01',
'agent_id' => '<string>',
'title' => null,
'metadata' => [
],
'initial_events' => [
],
'resources' => [
],
'vault_ids' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"zai-beta: <zai-beta>",
"zai-version: <zai-version>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "sess_01J...",
"type": "session",
"agent": {
"id": "<string>",
"type": "agent",
"name": "<string>",
"model": {
"id": "glm-5.3",
"speed": "standard",
"effort": "max"
},
"system": "<string>",
"description": "<string>",
"tools": [
{
"type": "agent_toolset_20260601",
"default_config": {
"enabled": true,
"permission_policy": {
"type": "always_allow"
}
},
"configs": [
{
"name": "read",
"enabled": true,
"permission_policy": {
"type": "always_allow"
}
}
]
}
],
"skills": [
{
"type": "custom",
"skill_id": "<string>",
"version": "<string>"
}
],
"mcp_servers": [
{
"type": "url",
"name": "knowledge-base",
"url": "https://mcp.example.com/mcp"
}
],
"version": 1,
"multiagent": null
},
"environment_id": "<string>",
"status": "idle",
"title": "<string>",
"metadata": {},
"resources": [
{
"type": "memory_store",
"memory_store_id": "<string>",
"name": "<string>",
"description": "<string>",
"access": "read_only",
"instructions": "<string>",
"mount_path": "<string>"
}
],
"vault_ids": [
"<string>"
],
"outcome_evaluations": [
{}
],
"stats": {
"active_seconds": 123,
"duration_seconds": 123
},
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_read_input_tokens": 123
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"archived_at": "<string>",
"budget": null
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>",
"details": {}
},
"request_id": "req_01J..."
}Headers
Managed Agents API 协议版本,固定为 2026-05-26。
2026-05-26 "2026-05-26"
必须包含 managed-agents-2026-05-26;可与其他 beta 标识用逗号分隔。
"managed-agents-2026-05-26"
仅创建 Session 时可用;精确传 true/false,缺省为 false。
true, false Checkpoint TTL(天),仅在 x-checkpoint: true 时允许。
1 <= x <= 30Body
- agent
- agent_id
必须提供 agent 与 environment_id。未传 agent 时,服务端仍接受兼容字段 agent_id。
Agent 配置;必填。仅为兼容旧调用时可改用 agent_id。
1必填的 Environment ID;必须存在、未归档并可由当前 Agent 使用。
1 - 64^env_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"env_019e8f00-1ac2-7a6b-8000-3f2d5c8b9a01"
兼容字段;agent 缺失时使用。
1会话标题;省略或传 null 时不设置。
256客户端自定义元数据;省略时默认为空对象。最多 16 个键,键名长度不超过 64 字符,值必须是长度不超过 512 字符的字符串。
Show child attributes
Show child attributes
创建后立即写入的 user.message 事件;省略时为空。仅允许文本与 base64 图片。
50Show child attributes
Show child attributes
挂载资源;省略时为空。默认平台上限为 500 个 file 与 8 个 memory_store,实际上限可由平台配置调整;文件 mount_path 不得重叠。
508- memory_store
- file
Show child attributes
Show child attributes
挂载的 Vault ID;省略时为空,最多 20 个且不得重复。
20Response
请求成功。
Session ID。
"sess_01J..."
session Show child attributes
Show child attributes
idle, running, rescheduling, terminated Session 标题。
客户端自定义元数据;省略时默认为空对象。最多 16 个键,键名长度不超过 64 字符,值必须是长度不超过 512 字符的字符串。
Show child attributes
Show child attributes
- memory_store
- file
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
创建时间。
更新时间。
归档时间。
当前不支持会话级消费上限,固定为 null。
Was this page helpful?