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"
}

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
  • User Message
  • System Message
  • Assistant Message
tools
Function Call · object[]

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

request_id
string

Passed by the client, must be unique. If empty, it will be generated by default.

user_id
string

Unique ID of the end user

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"