Count input tokens

Count the tokens an input would use, without running the model.

POST/responses/input_tokens

Count the tokens an input would use, without running the model.

The request takes the same model and input as POST /responses. Any file in the input is converted to text first, and that text is what is counted. So the count tells you whether a set of files fits the 65536-token context window before you ask a question about them. The API does not shorten a prompt that is too long. It refuses it with 400.

Counting is free. It still counts against your rate limit. The first count for a file also converts it, so a file you count right after uploading it is ready for your first question.

Authorization

BearerAuth
AuthorizationBearer <token>

Your Avey API key, sent as Authorization: Bearer <key>. This is the header the OpenAI SDKs already send, so pass the key as the client's ordinary api_key and no further configuration is needed.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

The body of a token count request. It takes the same model and input as a response.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl https://api.avey.ai/llm/responses/input_tokens \  -H "Authorization: Bearer $AVEY_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "olive",    "input": [      {        "role": "user",        "content": [          { "type": "input_file", "file_id": "file-Cn3MSNn72ENTiiq11Qda4A" }        ]      }    ]  }'
{  "object": "response.input_tokens",  "input_tokens": 4125}