Tokenize
POST/tokenize
Count the number and return the list of input tokens of a given prompt.
tip
Useful for agentic use to besure the number of token do not exceed the context window.
Request
curl -X POST https://api.ig1.ai/tokenize \
-H "Authorization: Bearer $IG1AI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kimi-k26-instant",
"prompt": "Tell me a three sentence bedtime story about a unicorn."
}'
Response
{
"count": 11,
"max_model_len": 262144,
"tokens": [
69211,
1019,
261,
3499,
23819,
97790,
5511,
1215,
261,
144473,
13
],
"token_strs": null
}
Response fields
| Field | Type | Description |
|---|---|---|
count | interger | Number of tokens |
max_model_len | integer | Model context window |
tokens | array | List of tokens |
token_strs | string | Always "null" |