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.
estimate-token-count is almost identical to that of chat completion.
Plain Text Call Example
Vision Call Example
error field, you can take data.total_tokens as the calculation result.The Authorization header expects a Bearer token. Use an MOONSHOT_API_KEY as the token. This is a server-side secret key. Generate one on the API keys page in your dashboard.
Model ID
kimi-k2.5, kimi-k2-0905-preview, kimi-k2-0711-preview, kimi-k2-turbo-preview, moonshot-v1-8k, moonshot-v1-32k, moonshot-v1-128k, moonshot-v1-auto, moonshot-v1-8k-vision-preview, moonshot-v1-32k-vision-preview, moonshot-v1-128k-vision-preview A list of messages in the conversation so far. Each element has the format {"role": "user", "content": "Hello"}. role supports system, user, or assistant. content must not be empty
Token count estimation