API reference

API reference · Public

Estimate a token count

GET/api/tokensNo key

A heuristic estimate, not a tokenizer. 200 KB cap on the input.

Parameters

Path and query parameters
FieldTypeWhat it is
text (query)stringThe text to measure.

Answer 200

The estimate.

Fields of the 200 answer
FieldTypeWhat it is
estimateinteger
method"heuristic"
notestringSays plainly that this is an estimate, not a tokenizer.

Errors

  • 413OpenAI shaped error.

Every error answers in one shape, with its type, code and the field it names. The whole list is in the docs' Errors section.

Antimatter