Samples
Tokenize text
{5432, 8754, 389, 264, 8147, 4729}
Count tokens
Arguments
Returns
INT[]: Array of token IDs.
Related functions
cohere_detokenize(): convert tokens back to text
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Convert text into token IDs using Cohere’s tokenizer
SELECT ai.cohere_tokenize(
'embed-english-v3.0',
'PostgreSQL is a powerful database'
);
{5432, 8754, 389, 264, 8147, 4729}
SELECT array_length(ai.cohere_tokenize(
'embed-english-v3.0',
'PostgreSQL is a powerful database'
), 1) AS token_count;
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
model | TEXT | - | ✔ | Cohere model for tokenization |
text_input | TEXT | - | ✔ | Text to tokenize |
api_key | TEXT | NULL | ✖ | Cohere API key |
api_key_name | TEXT | NULL | ✖ | Name of secret containing the API key |
verbose | BOOLEAN | FALSE | ✖ | Enable verbose logging |
INT[]: Array of token IDs.
cohere_detokenize(): convert tokens back to text