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.

X-Opper-Tags
string

Comma-separated key:value usage-attribution tags (e.g. tenant:acme,project:demo, max 8). Recorded on the generation's billing/metrics rows; group spend by any key via GET /v2/analytics/usage?group_by=. Header-borne twin of the /v3/session URL prefix tags (which win per key when both are present); opper.-prefixed keys and session_id are reserved. Malformed values return 400.

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.