The Emotion APIs let you analyze text for emotional tone. You can choose between Context-Based (stateful, memory across a session) and Non-Context (stateless, per message) modes.
Use this API when you need emotional memory across a session or conversation.
POST /v1/emotions/:context_id/analyse⚠ Your draft spec used GET with a body, but best practice is POST.
GET /v1/emotions/:context_idGET /v1/emotions/:context_id/message/:external_id| Field | Type | Required | Description |
|---|---|---|---|
| context_id | string | ✔ | Unique ID for the session (≤128 bytes). |
| external_id | string | ✔ (for message lookup) | Unique message ID supplied when analysing. |
{
"model": "emotion-v1",
"params": {},
"messages": [
{
"role": "user",
"external_id": "msg-1",
"content": {"text": "You are awesome!"}
}
]
}{
"object": "emotions.analyse",
"model": "emotion-v1",
"metadata": {
"context_id": "example-123"
},
"emotions": {
"user": {
"text": "Highly JOY",
"category": "joy",
"raw": {
"joy": 0.99,
"anger": 0.003,
"sadness": 0.002,
"fear": 0.001,
"surprise": 0.0008,
"love": 0.0006
}
}
}
}{
"object": "emotions.state",
"model": "emotion-v1",
"emotions": {
"system": {
"text": "Highly JOY",
"category": "joy",
"raw": {
"joy": 0.99,
"fear": 0.001,
"love": 0.0006,
"anger": 0.003,
"sadness": 0.002,
"surprise": 0.0008
}
}
},
"metadata": {
"context_id": "example-123"
}
}{
"object": "emotions.state",
"model": "emotion-v1",
"metadata": {
"context_id": "example-123",
"message_id": "msg-1"
},
"emotions": {
"user": {
"text": "Highly JOY",
"category": "joy",
"raw": {
"joy": 0.99,
"fear": 0.001,
"love": 0.0006,
"anger": 0.003,
"sadness": 0.002,
"surprise": 0.0008
}
}
}
}context_id accumulates and updates emotional state until expired.external_id for message-level lookups.Use this API when you only need to analyze emotions per message and don't want Kaiko to store state.
POST /v1/emotions/analyse{
"model": "emotion-v1",
"params": {},
"messages": [{
"content": {"text": "I don't know"}
}]
}{
"object": "emotions.analyse",
"model": "emotion-v1",
"emotions": {
"_default": {
"text": "Slightly ANGER",
"category": "anger",
"raw": {
"anger": 0.42,
"sadness": 0.31,
"joy": 0.15,
"fear": 0.09,
"love": 0.008,
"surprise": 0.003
}
}
}
}| Code | Meaning | Common causes |
|---|---|---|
| 400 | Bad Request | Missing messages field, wrong type |
| 401 | Unauthorized | No x-api-key header |
| 404 | Not Found | Invalid/expired context_id |
| 413 | Payload Too Large | Too many or too long inputs |
| 429 | Rate Limited | Retry with exponential backoff |
| 500 | Server Error | Retry or contact support |
| Use Case | Recommended API |
|---|---|
| Single-turn emotion analysis | Non-Context |
| Multi-turn conversation with memory | Context-Based |
| Emotional state tied to a session | Context-Based |
| Analytics pipeline or offline batch | Non-Context |
Next: see Quickstart for copy-paste examples, or Unified Chat API to combine LLM and emotions in a single call.