This quickstart keeps the web UI and backend responsibilities separate. The Next.js app owns the browser-facing /api/* URLs, and next.config.ts rewrites them to the Python FastAPI service that owns token generation and agent lifecycle.
Browser
↓
Next.js app
↓
/api/* rewrites through AGENT_BACKEND_URL
↓
FastAPI service
↓
Agora Cloud Services
webowns the browser UI and the/api/*entrypointsserverowns the actual token generation and agent start/stop logic- this is the mode used by
bun run dev
Frontend: GET /api/get_config
→ Generate Token007 config for a user UID, agent UID, and channel
→ Frontend joins RTC and logs into RTM
Frontend: POST /api/startAgent { channelName, rtcUid, userUid }
→ Build agent session
→ Scope remote_uids to the requesting user
→ Start session and return agent_id
User audio → RTC
→ Managed ASR, LLM, and TTS pipeline
→ Agent audio + RTM transcript events
→ UIKit transcript and visualizer in the web app
Frontend: POST /api/stopAgent { agentId }
→ Stop session directly or through stateless fallback
→ Client cleans up RTC and RTM state
| Endpoint | Method | Description |
|---|---|---|
/get_config |
GET | Generate connection config (Token007, channel, UIDs) |
/startAgent |
POST | Start the agent session |
/stopAgent |
POST | Stop the agent by agent_id |
Frontend calls these as /api/*. Next rewrites those calls to AGENT_BACKEND_URL; the Next app does not run token or AgentKit logic in-process.
Token007 (AccessToken2) — generated from AGORA_APP_ID + AGORA_APP_CERTIFICATE only. No API_KEY/API_SECRET needed. The SDK handles token generation and API auth internally.
- docs/ai/L1/02_architecture.md — web ↔ FastAPI topology, rewrites, lifecycle
- docs/ai/L1/03_code_map.md — where code lives under
web/andserver/ - AGENTS.md — AI agent development guide
- README.md — Quick start, configuration, deployment