Skip to main content
POST
https://api.classer.ai
/
v1
/
tag
Tag
curl --request POST \
  --url https://api.classer.ai/v1/tag \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "source": "<string>",
  "labels": [
    "<string>"
  ],
  "descriptions": {},
  "threshold": 123,
  "model": "<string>"
}
'
{
  "tags": ["technology", "finance"],
  "confidences": [0.7234, 0.4521],
  "latency_ms": 156,
  "usage": {
    "prompt_tokens": 42,
    "completion_tokens": 1,
    "total_tokens": 43
  }
}

Request

source
string
required
The text to tag
labels
string[]
required
List of possible labels (2-26 labels)
descriptions
object
Optional descriptions for each label to improve accuracy
threshold
number
default:"0.3"
Minimum confidence threshold (0-1). Labels below this are excluded.
model
string
Model override (optional)

Response

tags
string[]
List of labels above the threshold
confidences
number[]
Confidence scores for each tag (same order as tags)
latency_ms
number
Processing time in milliseconds
usage
object
Token usage information

Examples

Basic tagging

import classer

result = classer.tag(
    source="Breaking: Tech stocks surge amid AI boom",
    labels=["politics", "technology", "finance", "sports"],
    threshold=0.3
)

print(result.tags)        # ["technology", "finance"]
print(result.confidences) # [0.72, 0.45]

Adjusting threshold

Lower threshold = more tags, higher threshold = fewer but more confident tags.
# Low threshold - get more tags
result = classer.tag(
    source="New study shows coffee may improve focus",
    labels=["health", "science", "food", "lifestyle"],
    threshold=0.2
)
# tags: ["health", "science", "food", "lifestyle"]

# High threshold - only confident tags
result = classer.tag(
    source="New study shows coffee may improve focus",
    labels=["health", "science", "food", "lifestyle"],
    threshold=0.5
)
# tags: ["health", "science"]
{
  "tags": ["technology", "finance"],
  "confidences": [0.7234, 0.4521],
  "latency_ms": 156,
  "usage": {
    "prompt_tokens": 42,
    "completion_tokens": 1,
    "total_tokens": 43
  }
}