This section provides hands-on examples of how to use Kaiko's APIs in common scenarios. Copy and adapt these recipes to jumpstart your own projects.
Goal: A chatbot that not only replies but also adjusts tone based on user emotion.
Steps
context_id for the conversation.emotions.user.category to detect tone.curl https://api.kaiko.ai/v1/chat/completions \
-H "x-api-key: $KAIKO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4.1-nano",
"emotion_model": "emotion-v1",
"context_id": "chat-42",
"messages": [{"role": "user", "content": "I'm so frustrated right now"}]
}'Response snippet:
"emotions": {
"user": {"category": "anger"}
}→ Your agent can now choose a calm, supportive response.
Goal: Track trends in user mood over time.
Steps
context_id per user/session..../analyse for each incoming message..../emotions/:context_id to retrieve the latest state.curl https://api.kaiko.ai/v1/emotions/user-789 \
-H "x-api-key: $KAIKO_API_KEY"→ Use this to chart mood trends across conversations.
Goal: Route conversations to a human if user frustration spikes.
Steps
emotion_model.emotions.user.raw.anger.if emotions["user"]["raw"]["anger"] > 0.7:
escalate_to_human()Goal: Tutor agent that adapts feedback style based on learner mood.
Steps
context_id.→ Creates a more engaging and responsive learning flow.
Goal: Quickly process text streams without storing state.
Steps
category and raw scores in your database.curl https://api.kaiko.ai/v1/emotions/analyse \
-H "x-api-key: $KAIKO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "emotion-v1",
"messages": [{"content": {"text": "Not sure how I feel"}}]
}'→ Best for pipelines or analytics where context is managed externally.
Goal: Measure emotional resonance of campaign responses.
Steps
→ Identify which content drives the strongest positive reactions.
Goal: Notify a support team when a customer shows high distress.
Steps
emotions.user.category.sadness or fear > threshold, send a Slack/email alert.→ Enables proactive intervention.