All use casesUse Case
The backend layer for a voice agent: sessions, billing, and orchestration.
Voice agents chain speech-to-text, an LLM turn, and text-to-speech per exchange. FastAPI AI Kit's session model, streaming support, and unified LLM layer handle the middle step and the conversation state; you plug in your STT/TTS providers of choice.
FastAPIOpenAI / AnthropicRedisPostgreSQLStripeSSE
The usual pain points
- ✕Maintaining conversation state across a multi-turn voice session
- ✕Keeping LLM turnaround fast enough for natural conversation pacing
- ✕Billing usage in a way that reflects call duration or turns, not raw tokens alone
- ✕Coordinating three services (STT, LLM, TTS) reliably per exchange
How the kit solves them
- Session store already built for multi-turn conversation history
- Unified LLM layer with streaming keeps the text-generation leg fast
- Stripe metering supports custom units, so you can bill per minute or per turn
- Background job pattern available for async transcription/post-processing steps
Example implementation
@router.post("/v1/voice/turn")
@require_api_key(tier=["voice"])
async def voice_turn(body: VoiceTurnRequest, key: APIKey = Depends(get_api_key)):
history = await session_store.get(body.session_id)
# body.transcript comes from your STT provider of choice
response = await llm.chat(messages=[*history, body.transcript], track_tokens=True)
await meter.record(key.id, units=1) # billed per turn
# Hand response.content to your TTS provider of choice
return {"reply_text": response.content}Ready to build your ai voice agent backend?
FastAPI AI Kit ships with everything shown above, pre-configured and production-ready. Clone the repo and start building in minutes.
Ready to ship your AI backend this weekend?
Join developers who skipped weeks of boilerplate and went straight to building.
No subscriptions · One-time payment · Lifetime updates
