Skip to main content
POST
Count Message tokens

Authorizations

Authorization
string
header
required

API key authentication. Pass your API key as a Bearer token.

Headers

X-Opper-Name
string

Function name for tracing and project-level guardrail function-scope filtering.

X-Opper-Parent-Span-Id
string<uuid>

Parent span ID for distributed tracing context.

Body

application/json
max_tokens
integer
required
messages
object[]
required
model
string
required
cache_control
object

Opt in to top-level automatic prompt caching: {"type":"ephemeral"} (optionally "ttl":"1h"). Places one moving breakpoint on the largest cacheable prefix. Explicit per-block cache_control on system/message/tool content takes precedence. Caching is off unless set. Cache writes cost 1.25x input and reads 0.1x

metadata
object
output_format
object
stop_sequences
string[]
stream
boolean
system
any

Any value

temperature
number
thinking
any

Any value

tool_choice
any

Any value

tools
object[]
top_k
integer
top_p
number

Response

Successful response

input_tokens
integer
required

The number of input tokens the request would consume.