Samples
Tokenize text
Convert a string into tokens:Count tokens
Determine how many tokens a text will use:Check token count before API call
Ensure your text fits within model limits:Arguments
Returns
INT[]: An array of token IDs representing the input text.
Related functions
openai_detokenize(): convert tokens back into textopenai_embed(): generate embeddings from text or tokensopenai_chat_complete(): use tokens for completion