POST
/
paas
/
v4
/
tokenizer
文本分词器
curl --request POST \
  --url https://open.bigmodel.cn/api/paas/v4/tokenizer \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "glm-4-plus",
  "messages": [
    {
      "role": "user",
      "content": "What opportunities and challenges will the Chinese large model industry face in 2025?"
    }
  ]
}'
{
  "created": 1727156815,
  "id": "20241120141244890ab4ee4af84acf",
  "request_id": "1",
  "usage": {
    "prompt_tokens": 123
  }
}

Authorizations

Authorization
string
header
required

使用以下格式进行身份验证:Bearer <your api key>

Body

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

调用的模型代码。

Available options:
glm-4-plus,
glm-4-0520,
glm-4-long,
glm-4-air,
glm-4-flash
Example:

"glm-4-plus"

messages
(用户消息 · object | 系统消息 · object | 助手消息 · object | 工具消息 · object)[]
required

对话消息列表输入。支持四种角色:system(系统消息)、user(用户消息)、assistant(助手消息)、tool(工具消息)。

Minimum length: 1
request_id
string

由用户端传参,需保证唯一性,用户传空会默认生成

user_id
string

终端用户的唯一ID

Response

业务处理成功

id
string
required

智谱AI开放平台生成的任务序号,调用请求结果接口时请使用此序号。

Example:

"20241120141244890ab4ee4af84acf"

usage
object
required
created
integer
Example:

1727156815

request_id
string

请求发起时客户端提交的任务号或平台生成的任务号。

Example:

"1"