Skip to main content
POST
/
v3
/
llm
/
v1
/
messages
/
count_tokens
Anthropic Count Tokens
curl --request POST \
  --url https://api.edenai.run/v3/llm/v1/messages/count_tokens \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "messages": [
    {
      "role": "user",
      "content": "<string>"
    }
  ],
  "system": "<string>",
  "tools": [
    {}
  ],
  "tool_choice": {}
}
'
{
  "detail": [
    {
      "loc": [
        "<string>"
      ],
      "msg": "<string>",
      "type": "<string>"
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Body for /v1/messages/count_tokens — same fields as messages but max_tokens is optional.

model
string
required
messages
AnthropicMessage · object[]
required
system
tools
Tools · object[] | null
tool_choice
Tool Choice · object

Response

Successful Response