Backend API for Kwami voice agents: LiveKit token issuance, model and voice catalogs, Zep memory operations, and credits (Stripe). Used by Kwami App and the Kwami LiveKit agent.
- LiveKit tokens — Issue JWT tokens for app/agent participants; agent dispatch is handled by LiveKit Cloud
- Models — STT, LLM, TTS model lists derived from LiveKit plugins (OpenAI, Anthropic, Deepgram, ElevenLabs, etc.)
- Voices & languages — Voice and language catalogs for the app
- Memory — Zep-backed memory endpoints (sessions, search, graph operations)
- Credits — Balance, usage, and Stripe checkout for credit purchases
- Auth — Supabase JWT verification for protected routes
- Python 3.11+
- uv (recommended) or pip
# Install dependencies (uv)
uv sync
# Or with pip
pip install -e .
# Configure environment
cp .env.sample .env
# Edit .env with your keys (see Environment variables)# Development (reload on change)
make dev
# or: uv run python -m src.main
# Production (e.g. in Docker)
make docker-build
make docker-upAPI listens on API_HOST:API_PORT (default 0.0.0.0:8080). OpenAPI docs at /docs and /redoc when ENABLE_DOCS=true.
| Prefix | Description |
|---|---|
/ |
Health |
/token |
LiveKit token generation |
/memory |
Zep memory (sessions, etc.) |
/models |
STT/LLM/TTS model lists |
/voices |
Voice catalog |
/languages |
Language catalog |
/credits |
Balance, usage, Stripe |
The token endpoint expects a POST body with roomName, optional participantName / participantIdentity, permissions, and optional kwamiId. It returns a JWT for connecting to LiveKit.
| Variable | Required | Description |
|---|---|---|
LIVEKIT_URL |
Yes | LiveKit WebSocket URL (e.g. wss://your-project.livekit.cloud) |
LIVEKIT_API_KEY |
Yes | LiveKit API key |
LIVEKIT_API_SECRET |
Yes | LiveKit API secret |
ZEP_API_KEY |
For memory | Zep Cloud API key |
SUPABASE_URL |
For auth | Supabase project URL (JWKS verification) |
SUPABASE_SECRET_KEY |
For credits/DB | Supabase service role key |
STRIPE_SECRET_KEY |
For credits | Stripe secret key |
STRIPE_WEBHOOK_SECRET |
For credits | Stripe webhook signing secret |
STRIPE_PUBLISHABLE_KEY |
Optional | Stripe publishable key |
KWAMI_API_KEY |
For agent | Shared secret for agent usage reporting (X-API-Key) |
CORS_ORIGINS |
No | Comma-separated origins (default * in dev) |
API_HOST / API_PORT |
No | Bind address and port (default 0.0.0.0:8080) |
APP_ENV |
No | development | staging | production |
ENABLE_DOCS |
No | Set to true to expose /docs and /redoc in production |
See .env.sample for a full list and comments.
| Command | Description |
|---|---|
make install |
Install dependencies (uv sync) |
make dev |
Run API in dev mode |
make test |
Run tests |
make lint |
Run Ruff linter |
make format |
Format and fix with Ruff |
make docker-build |
Build Docker image |
make docker-up / make docker-down |
Run or stop container |
src/
├── main.py # FastAPI app, CORS, routes
├── api/
│ ├── routes/ # health, token, memory, models, voices, languages, credits
│ └── deps.py # Auth dependencies
├── core/
│ ├── config.py # Pydantic settings
│ └── security.py # JWT / auth helpers
├── services/
│ ├── livekit.py # Token creation
│ ├── models.py # Model list from LiveKit plugins
│ ├── voices.py # Voice catalog
│ ├── languages.py # Language catalog
│ ├── credits.py # Balance, usage, Stripe
│ └── ...
config/ # LiveKit plugin YAML (inference, voices, languages)
migrations/ # SQL migrations (credits, user kwamis)
tests/
- Fly.io —
fly.tomlis included. Set secrets withfly secrets setand deploy withfly deploy. - Docker — Use
Dockerfileand set env via--env-fileor environment.
Apache-2.0. See LICENSE.