Utilities

Estimate Token Count

Estimates the number of tokens that would be used for a given set of messages and model. The input structure is almost identical to that of chat completion.

post/v1/tokenizers/estimate-token-count

Request

  • Base URL: https://api.moonshot.ai
  • URL: https://api.moonshot.ai/v1/tokenizers/estimate-token-count
  • Auth: HTTP bearer

Request body

model'kimi-k3' | 'kimi-k2.7-code' | 'kimi-k2.7-code-highspeed' | 'kimi-k2.6' required

Model ID

Example request

{
  "messages": [
    {
      "role": "user"
    }
  ]
}

Response

Token count estimation

Example response

{
  "data": {
    "total_tokens": 80
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.