API reference

API reference · Public

Estimate a token count

POST/api/tokensNo key

Send application/json as {text} or any other content type as a raw body.

Request body

application/json, optional

Request body fields
FieldTypeWhat it is
textstring

Example

{
  "text": "string"
}

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