Browse documentation

Count the tokens a message payload would consume, without sending it.

Count the tokens a message payload would consume, without sending it.

POST
/v1/messages/count_tokens

Authorization

NRouterApiKey
AuthorizationBearer <token>

Your nRouter virtual key (sk-nrouter-…). Sent as Authorization: Bearer sk-nrouter-….

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/v1/messages/count_tokens" \  -H "Content-Type: application/json" \  -d '{    "model": "string",    "messages": [      {}    ]  }'
{  "input_tokens": 9}
Was this page helpful?