Build a production-style voice agent with a Next.js web client and Python FastAPI backend. This quickstart includes live transcript, agent visualizer (Agent UIKit), and managed STT/LLM/TTS defaults.
Install the CLI (skip if already installed), scaffold the Python quickstart, install dependencies, and run.
-
Install the Agora CLI and sign in (skip if
agorais already on your PATH):curl -fsSL https://raw.githubusercontent.com/AgoraIO/cli/main/install.sh | sh -s -- --add-to-path agora login -
Scaffold and run (replace
my-python-demowith your own project name):agora init my-python-demo --template python cd my-python-demo bun run setup bun run dev -
Open http://localhost:3000 and click Start conversation.
If the agent does not join or transcripts do not appear, run agora project doctor --deep to check credentials, feature enablement, network reachability, and local env binding.
Use this path if you already cloned this repo:
git clone https://github.com/AgoraIO-Conversational-AI/agent-quickstart-python.git
cd agent-quickstart-python
agora login
agora project use <your-project>
bun run setup
agora quickstart env write .
bun run doctor:local
bun run devbun run setup preserves a configured server/.env, copies a legacy server/.env.local when needed, and prints the credential-writing step when the resulting file lacks real Agora values. Setup and doctor:local replace an untouched example file with configured legacy credentials. This supports CLI versions that wrote .env.local.
Services:
- Frontend:
http://localhost:3000 - Backend:
http://localhost:8000 - API docs:
http://localhost:8000/docs
Deploy web as a Next.js app and server as a reachable Python service.
Browser-facing /api/* routes in Next proxy to FastAPI via:
AGENT_BACKEND_URL=https://your-python-backend.example.comSet backend env values:
AGORA_APP_ID=your_agora_app_id
AGORA_APP_CERTIFICATE=your_agora_app_certificateTo export local env values from the Agora CLI-bound project:
agora project use <your-project>
agora quickstart env write .
rg "^(AGORA_APP_ID|AGORA_APP_CERTIFICATE)=" server/.envPrimary backend env file: server/.env.example.
| Variable | Required | Default | Notes |
|---|---|---|---|
AGORA_APP_ID |
✅ | — | Agora Console -> Project -> App ID |
AGORA_APP_CERTIFICATE |
✅ | — | Agora Console -> Project -> App Certificate (server only) |
PORT |
8000 |
FastAPI server port | |
AGENT_BACKEND_URL (web deploy) |
✅ | — | Required in deployed web app when proxying to external FastAPI |
Default vs BYOK — this quickstart defaults to Agora-managed STT + LLM + TTS in the backend. Enable BYOK by uncommenting provider blocks in
server/src/agent.pyand adding matching keys.
# Dev
bun run setup
bun run dev
# Quality
bun run doctor
bun run doctor:local
bun run verify:backend
# CI / pre-ship
bun run verify:web
bun run verify:local
bun run verifyRun bun run verify before shipping web-only changes, and bun run verify:local when backend behavior changed.
Tests run standalone (no Agora cloud needed): pytest in server/, bun test in web/. CI runs them on Linux/macOS/Windows × Python 3.10 & 3.13.
The browser talks to Next.js /api/* routes. In local mode, Next rewrites those routes to FastAPI using AGENT_BACKEND_URL=http://localhost:8000; FastAPI owns token generation and agent start/stop logic.
- Next.js web client (
web/) with transcript UI and agent visualizer - FastAPI backend (
server/) for token generation and agent lifecycle /api/get_config,/api/startAgent, and/api/stopAgentbrowser-facing contract- Managed default pipeline (Deepgram STT, OpenAI LLM, MiniMax TTS)
- Browser requests connection config from
/api/get_config. - Backend generates combined RTC+RTM config and returns channel + token.
- Browser joins RTC/RTM and starts streaming audio.
- Browser calls
/api/startAgent; backend starts the cloud agent session. - Browser receives transcript and state updates over RTM, and
/api/stopAgentends the session.
web/— Next.js 16 + React 19 + TypeScript frontendserver/— Python FastAPI backend + Agora Agent Server SDK integrationARCHITECTURE.md— system-level flow and ownership boundariesAGENTS.md— contributor agent instructions
- Agent does not join or transcripts are missing: run
agora project doctor --deep. - Missing credentials: run
agora quickstart env write .. - Auth errors from backend: confirm
AGORA_APP_IDandAGORA_APP_CERTIFICATEare set inserver/.env. - Frontend cannot reach backend: confirm
AGENT_BACKEND_URL=http://localhost:8000in local frontend scripts. - Unsure who owns
/api/*: Next owns browser-facing/api/*; FastAPI owns/get_config,/startAgent,/stopAgent.
- ARCHITECTURE.md
- AGENTS.md
- docs/ai/L1/02_architecture.md — full-stack topology and lifecycle
- docs/ai/L1/03_code_map.md — curated
web/+server/file map
Released under the MIT License.