Count tokens for a message request
Anthropic count_tokens compatible endpoint. Returns the number of input tokens that would be consumed by a POST /messages call with the same prompt content (system, messages, tools, tool_choice). Authentication accepts either the bearer Authorization: Bearer <key> header (SambaNova SDK default) or the x-api-key header (Anthropic SDK default); the same API key is used in both cases.
Authorizations
SambaNova API key, sent as a bearer token in the Authorization header (Authorization: Bearer <key>). Default authentication scheme used by the SambaNova SDK across every OpenAI compatible endpoint.
Headers
Anthropic API version header sent by the official anthropic SDK. Accepted (any value) but currently has no effect on response shape - included for drop-in SDK compatibility.
"2023-06-01"
Body
Token counting parameters (subset of message creation parameters).
Request body for POST /messages/count_tokens. Returns the input token count for a prompt without generating output. Same prompt shape as MessageCreateRequest minus generation-time parameters (max_tokens, stream, sampling, stop_sequences, metadata, service_tier, etc.).
Model identifier.
"gpt-oss-120b"
Conversation turns.
1System prompt for the conversation. Accepts either a single string (most common) or an array of text blocks (used when individual segments need cache_control markers). Multiple text blocks are joined with newlines and prepended to the conversation as a role: system message.
Disables Anthropic-style extended thinking. In v1: silently accepted as a no-op
- Message Thinking Disabled
- Message Thinking Enabled
- Message Thinking Adaptive
Tool definitions the model may call.
Controls how the model selects from tools.
- Message Tool Choice (Auto)
- Message Tool Choice (Any)
- Message Tool Choice (None)
- Message Tool Choice (Tool)
Response
Successful response. Returns the input token count.
Token count for the supplied prompt.
Total tokens in the prompt (system + messages + tools).

