AI Chat¶
Cadence includes a built-in AI coaching chat that uses your fitness data to provide personalized training advice.
How It Works¶
The chat is an agentic loop: when you ask a question, the LLM can call Cadence's MCP tools to fetch your data, analyze it, and respond with data-backed coaching advice. Each conversation supports up to 10 tool-calling rounds.
User: "Am I ready for a hard workout today?"
↓
LLM calls get_daily_brief → recovery 82%, HRV 65ms, 7.2h sleep
LLM calls get_readiness → green (training readiness: high)
LLM calls get_strength_history → last session 2 days ago
↓
AI: "You're in great shape for a hard session today. Recovery is 82%,
HRV is above your baseline, and you've had 2 full rest days..."
Supported LLM Providers¶
Cadence uses LiteLLM to support multiple providers:
| Provider | Model Examples | Env Variable |
|---|---|---|
| Anthropic | Claude Sonnet 4.5, Claude Haiku | ANTHROPIC_API_KEY |
| OpenAI | GPT-4o, GPT-4o-mini | OPENAI_API_KEY |
| Gemini 2.0 Flash, Gemini Pro | GOOGLE_API_KEY |
|
| xAI | Grok | XAI_API_KEY |
| Groq | Llama, Mixtral | GROQ_API_KEY |
| Mistral | Mistral Large, Mistral Small | MISTRAL_API_KEY |
API Key Precedence¶
- Per-user key — users can set their own key in Settings
- Admin key — stored encrypted in the database (set via admin panel)
- Environment variable — fallback from
.env
Coaching Personality¶
The AI operates as "Cadence", an expert fitness coach that:
- Leads with data — always calls
get_daily_briefbefore giving advice - Cites numbers — references actual recovery %, HRV in ms, sleep hours
- Uses readiness colors — green (go hard), yellow (moderate), red (rest/easy)
- Flags risks proactively — HRV decline 3+ days, sleep debt >2h, ACWR >1.3
- Renders charts — visualizes trends after fetching time-series data
Streaming¶
Chat responses are streamed via Server-Sent Events (SSE):
| Event | Description |
|---|---|
token |
Text streamed token by token |
tool_start |
Tool execution beginning (shows loading state) |
tool_end |
Tool execution complete |
chart |
Chart spec for visualization |
usage |
Input/output token counts |
done |
Stream complete |
error |
Error occurred |
Coaching Profile¶
Each user can set a coaching profile in Settings — free-text context about their goals, injuries, preferences, and training background. This is prepended to the system prompt for every conversation, personalizing the coaching advice.
Token Limits¶
Admins can set per-user monthly token limits via the admin panel. Token usage is tracked per conversation and per model in the token_usage table.