Samples
Classify sentiment
Categorize text as positive or negative:Classify support tickets
Categorize customer inquiries:Batch classification
Classify multiple texts at once:Arguments
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
model | TEXT | - | ✔ | The Cohere model to use (e.g., embed-english-v3.0) |
inputs | TEXT[] | - | ✔ | Array of texts to classify |
api_key | TEXT | NULL | ✖ | Cohere API key. If not provided, uses configured secret |
api_key_name | TEXT | NULL | ✖ | Name of the secret containing the API key |
examples | JSONB | NULL | ✖ | Training examples as array of {"text": "...", "label": "..."} objects |
truncate_long_inputs | TEXT | NULL | ✖ | How to handle long inputs: START, END, NONE |
verbose | BOOLEAN | FALSE | ✖ | Enable verbose logging for debugging |
Returns
TABLE: A table with the following columns:
| Column | Type | Description |
|---|---|---|
input | TEXT | The input text that was classified |
prediction | TEXT | The predicted category label |
confidence | FLOAT8 | Confidence score (0.0 to 1.0) for the prediction |
Related functions
cohere_classify(): full API response with additional metadatacohere_embed(): generate embeddings for custom classification