API reference
Count tokens
Count a request
POST https://antarya.ai/v1/count-tokens
Send the body you would send to /v1/chat. Antarya returns the number of input tokens and does not write a reply. Counting is free and is not billed. It is limited to 100 a minute per key, apart from the chat limits. The guide explains what the count covers.
Headers
| Header | Value |
|---|---|
Authorization |
Bearer $ANTARYA_API_KEY |
Content-Type |
application/json |
curl https://antarya.ai/v1/count-tokens \
-H "Authorization: Bearer $ANTARYA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "Draft a reply that declines the meeting."}
]
}'Output
{"input_tokens": 12}Request body
| Name | Type | Required | Description |
|---|---|---|---|
messages | array | YesRequired | The conversation to count, as in a chat request. |
model | text | No | The id or alias of the model. Models can count tokens differently. |
system | text | No | Counted with the messages. |
tools | array | No | Counted with the messages. |
response_format | object | No | Counted with the messages. |
Response
| Name | Type | Required | Description |
|---|---|---|---|
input_tokens | number | YesRequired | The tokens the request would use as input. |