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": {
    "source_lang": "auto",
    "target_lang": "zh-CN",
    "glossary": "<string>",
    "strategy": "general",
    "strategy_config": {
      "general": {
        "suggestion": "<string>"
      },
      "cot": {
        "reason_lang": "from"
      }
    }
  }
}
'
{
  "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.