curl --request POST \ --url https://open.bigmodel.cn/api/paas/v4/tokenizer \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model": "glm-5.3", "messages": [ { "role": "user", "content": "What opportunities and challenges will the Chinese large model industry face in 2025?" } ]}'
import requests
url = "https://open.bigmodel.cn/api/paas/v4/tokenizer"
payload = {
"model": "glm-5.3",
"messages": [
{
"role": "user",
"content": "What opportunities and challenges will the Chinese large model industry face in 2025?"
}
]
}
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({
model: 'glm-5.3',
messages: [
{
role: 'user',
content: 'What opportunities and challenges will the Chinese large model industry face in 2025?'
}
]
})
};
fetch('https://open.bigmodel.cn/api/paas/v4/tokenizer', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
HttpResponse<String> response = Unirest.post("https://open.bigmodel.cn/api/paas/v4/tokenizer")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"glm-5.3\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What opportunities and challenges will the Chinese large model industry face in 2025?\"\n }\n ]\n}")
.asString();
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://open.bigmodel.cn/api/paas/v4/tokenizer"
payload := strings.NewReader("{\n \"model\": \"glm-5.3\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What opportunities and challenges will the Chinese large model industry face in 2025?\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://open.bigmodel.cn/api/paas/v4/tokenizer",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'glm-5.3',
'messages' => [
[
'role' => 'user',
'content' => 'What opportunities and challenges will the Chinese large model industry face in 2025?'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Tokenizer 用于将文本切分为模型可识别的 token 并计算数量。它接收用户输入的文本,通过模型进行分词处理,最终返回对应的 token 数量。适用于文本长度评估、模型输入预估、对话上下文截断、费用计算等。点击 Try it 按钮可快速试用。
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-5.3", "messages": [ { "role": "user", "content": "What opportunities and challenges will the Chinese large model industry face in 2025?" } ]}'
import requests
url = "https://open.bigmodel.cn/api/paas/v4/tokenizer"
payload = {
"model": "glm-5.3",
"messages": [
{
"role": "user",
"content": "What opportunities and challenges will the Chinese large model industry face in 2025?"
}
]
}
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({
model: 'glm-5.3',
messages: [
{
role: 'user',
content: 'What opportunities and challenges will the Chinese large model industry face in 2025?'
}
]
})
};
fetch('https://open.bigmodel.cn/api/paas/v4/tokenizer', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
HttpResponse<String> response = Unirest.post("https://open.bigmodel.cn/api/paas/v4/tokenizer")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"glm-5.3\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What opportunities and challenges will the Chinese large model industry face in 2025?\"\n }\n ]\n}")
.asString();
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://open.bigmodel.cn/api/paas/v4/tokenizer"
payload := strings.NewReader("{\n \"model\": \"glm-5.3\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What opportunities and challenges will the Chinese large model industry face in 2025?\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://open.bigmodel.cn/api/paas/v4/tokenizer",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'glm-5.3',
'messages' => [
[
'role' => 'user',
'content' => 'What opportunities and challenges will the Chinese large model industry face in 2025?'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}