Skip to main content
POST
/
langchain
/
anthropic
/
v1
/
messages
/
count_tokens
Error
A valid request URL is required to generate request examples
{
  "input_tokens": 123
}

Authorizations

Authorization
string
header
required

Bearer token authentication. Use your provider API key or Bifrost authentication token. Virtual keys (prefixed with sk-bf-) can also be passed here.

Body

application/json
model
string
required

Model identifier (e.g., claude-3-opus-20240229)

Example:

"claude-3-opus-20240229"

max_tokens
integer
required

Maximum tokens to generate

messages
object[]
required

List of messages in the conversation

system

System prompt

cache_control
object

Automatic caching directives for the whole request

metadata
object
stream
boolean

Whether to stream the response

temperature
number
Required range: 0 <= x <= 1
top_p
number
top_k
integer
stop_sequences
string[]
tools
object[]
tool_choice
object
mcp_servers
object[]

MCP servers configuration (requires beta header)

thinking
object
output_format
object

Structured output format (requires beta header)

fallbacks
string[]

Response

Successful response

input_tokens
integer

Number of input tokens