Reference Count tokens
Count tokens
Returns the input estimate a call would be held at, without calling a model or charging anything.
POSThttps://api.runmoth.si/v1/messages/count_tokens
Body
modelrequiredA chat model ID from the catalog.
messagesrequiredThe conversation, as for messages.
system, toolsstring, arrayCounted as they would be sent.
The figure is the hold's estimate of your input, the body's bytes divided by three plus 5,000 for each image, and a call with web search holds 40,000 tokens more. It is usually larger than the count a call is billed for, so use it to stay inside a context or a cap rather than to predict a charge.
Errors
400invalid_request_errorThe body isn't valid401authentication_errorThe key is missing, revoked or expired403permission_errorThe key may not use this model404not_found_errorThe model isn't a chat model in the catalog429rate_limit_errorToo many calls from the key or the account, or to the model, so wait for retry-after when it is sent529overloaded_errorThe model is paused, or busy or down at its host, so choose another or wait for retry-after when it is sent