Skip to main content
POST
/
v1
/
agents
cURL
curl --request POST \
  --url https://api.z.ai/api/v1/agents \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "agent_id": "general_translation",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "<string>"
        }
      ]
    }
  ],
  "stream": true,
  "custom_variables": {
    "glossary": "<string>",
    "strategy_config": {
      "general": {
        "suggestion": "<string>"
      },
      "cot": {}
    }
  }
}
'
import requests

url = "https://api.z.ai/api/v1/agents"

payload = {
"agent_id": "general_translation",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "<string>"
}
]
}
],
"stream": True,
"custom_variables": {
"glossary": "<string>",
"strategy_config": {
"general": { "suggestion": "<string>" },
"cot": {}
}
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
agent_id: 'general_translation',
messages: [{role: 'user', content: [{type: 'text', text: '<string>'}]}],
stream: true,
custom_variables: {
glossary: '<string>',
strategy_config: {general: {suggestion: '<string>'}, cot: {}}
}
})
};

fetch('https://api.z.ai/api/v1/agents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
HttpResponse<String> response = Unirest.post("https://api.z.ai/api/v1/agents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent_id\": \"general_translation\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\"\n }\n ]\n }\n ],\n \"stream\": true,\n \"custom_variables\": {\n \"glossary\": \"<string>\",\n \"strategy_config\": {\n \"general\": {\n \"suggestion\": \"<string>\"\n },\n \"cot\": {}\n }\n }\n}")
.asString();
{
  "id": "<string>",
  "agent_id": "<string>",
  "choices": [
    {
      "index": 123,
      "finish_reason": "<string>",
      "messages": [
        {
          "role": "<string>",
          "content": {
            "text": "<string>",
            "type": "<string>"
          }
        }
      ]
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123,
    "total_calls": 123
  }
}

Authorizations

Authorization
string
header
required

Use the following format for authentication: Bearer

Headers

Accept-Language
enum<string>
default:en-US,en

Config desired response language for HTTP requests.

Available options:
en-US,en
Example:

"en-US,en"

Body

application/json
agent_id
enum<string>
required

Agent ID: general_translation.

Available options:
general_translation
messages
object[]
required

Session message body.

stream
boolean

False for sync calls (default). True for streaming.

custom_variables
object

Response

Processing successful

id
string

Task ID.

agent_id
string

Agent ID.

status
string

Task status.

choices
object[]

Model output content.

usage
object

Token usage statistics.