Docs
API referenceMessages

Count message tokens

POST
/v1/messages/count_tokens

Counts the input tokens of a Messages request without running the model. Free: never billed, and it works even when the balance is zero. It counts toward rate limits.

Authorization

headerAuthorizationBearer <token>

Your API key: Authorization: Bearer io-sk-…. If a request also sends x-api-key, x-api-key wins.

Header Parameters

x-interodin-session-id?string

Optional prompt-cache routing hint, honoured on every generation endpoint (including count_tokens). Send the same opaque value (for example a conversation id, at most 128 characters recommended) on every request of one conversation. Never put prompts, personal data or secrets in it.

anthropic-version?string

Accepted for Anthropic SDK compatibility (a date such as 2023-06-01). Only well-formed values are honoured.

anthropic-beta?string

Accepted for Anthropic SDK compatibility (comma-separated feature names). Only well-formed values are honoured.

Request Body

application/json
  1. body
model*string
messages*array<>
Items1 <= items
system?string|array<>
tools?array<|>

Client tools: tools with no type or with type: "custom" (name, description, input_schema). The web search tool (type: "web_search_20250305", at most 5 searches per request, billed per search) is also kept. Tools with any other type (code execution, bash, text editor, computer use) and mcp_servers are removed from the request without an error.

tool_choice?
thinking?

Thinking is on or off. disabled turns it off on both models. budget_tokens does not cap it.

output_config?

Accepted and ignored: thinking has no levels.

Response Body

The input token count.

application/json
  1. response
input_tokens*integer
Range0 <= value
curl -X POST 'https://api.interodin.com/v1/messages/count_tokens' \  -H 'Content-Type: application/json' \  -d '{  "model": "odin-v1",  "messages": [    {      "role": "user",      "content": "How many tokens is this?"    }  ]}'
{  "input_tokens": 0}