Skip to main content
POST
JavaScript

Authorizations

Authorization
string
header
required

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-version
string

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.

Example:

"2023-06-01"

Body

application/json

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
string
required

Model identifier.

Example:

"gpt-oss-120b"

messages
Message Input Message · object[]
required

Conversation turns.

Minimum array length: 1
system

System 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.

thinking
Message Thinking Disabled · object

Disables Anthropic-style extended thinking. In v1: silently accepted as a no-op

tools
Message Tool · object[] | null

Tool definitions the model may call.

tool_choice
Message Tool Choice (Auto) · object

Controls how the model selects from tools.

Response

Successful response. Returns the input token count.

Token count for the supplied prompt.

input_tokens
integer
required

Total tokens in the prompt (system + messages + tools).