Skip to main content
POST
/
paas
/
v4
/
tokenizer
Text Tokenizer
curl --request POST \
  --url https://api.z.ai/api/paas/v4/tokenizer \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "glm-4.6",
  "messages": [
    {
      "role": "user",
      "content": "What opportunities and challenges will the Chinese large model industry face in 2025?"
    }
  ]
}
'
{
  "id": "20241120141244890ab4ee4af84acf",
  "usage": {
    "prompt_tokens": 123,
    "image_tokens": 123,
    "video_tokens": 123,
    "total_tokens": 123
  },
  "created": 1727156815,
  "request_id": "1"
}

Documentation Index

Fetch the complete documentation index at: https://docs.z.ai/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

Use the following format for authentication: Bearer

Body

application/json
model
enum<string>
default:glm-4.6
required

The model code to be called.

Available options:
glm-4.6,
glm-4.6v,
glm-4.5
Example:

"glm-4.6"

messages
(User Message · object | System Message · object | Assistant Message · object)[]
required

The current conversation message list as the model’s prompt input, provided in JSON array format, e.g.,{“role”: “user”, “content”: “Hello”}. Possible message types include system messages, user messages. Note: The input must not consist of system or assistant messages only.

Minimum array length: 1
tools
Function Call · object[]

List of tools the model can call. Supports up to 128 functions.

request_id
string

Passed by the user side, needs to be unique; used to distinguish each request, 6–64 characters. If not provided by the user side, the platform will generate one by default.

Required string length: 6 - 64
user_id
string

Unique ID for the end user, 6–128 characters. Avoid using sensitive information.

Required string length: 6 - 128

Response

Business processing successful

id
string
required

The task sequence number generated by the Zhipu AI Open Platform. Please use this number when calling the request result interface.

Example:

"20241120141244890ab4ee4af84acf"

usage
object
required
created
integer<int64>
Example:

1727156815

request_id
string

The task number submitted by the client or generated by the platform when the request was initiated.

Example:

"1"