Guides
Environment Variables Reference
1. Web App (apps/web)
Primary local file: apps/web/.env.local
Required for dashboard + demos
| Variable | Scope | Required | Notes |
|---|---|---|---|
NEXT_PUBLIC_CONVEX_URL | Build-time (client) | Yes | Convex HTTP URL (https://<deployment>.convex.site) |
NEXT_PUBLIC_APP_SLUG | Build-time (client) | Yes | Default app slug |
NEXT_PUBLIC_LIVEKIT_URL | Build-time (client) | Yes | LiveKit websocket URL (wss://...) |
NEXT_PUBLIC_GEMINI_API_KEY | Build-time (client) | Yes | Gemini key for browser chatbot/live demos |
APP_SECRET | Runtime (server) | Yes | Server-only Convex app secret |
LIVEKIT_URL | Runtime (server) | Yes | LiveKit API URL (https://...) |
LIVEKIT_API_KEY | Runtime (server) | Yes | LiveKit API key |
LIVEKIT_API_SECRET | Runtime (server) | Yes | LiveKit API secret |
Used by server routes / optional flows
| Variable | Required | Used For |
|---|---|---|
GEMINI_API_KEY | Optional | /api/summarize and /api/memory/extract (fallbacks to NEXT_PUBLIC_GEMINI_API_KEY) |
LIVEKIT_SIP_TRUNK_ID | Optional | PSTN/SIP outbound call demo |
TWILIO_FROM_NUMBER | Optional | Caller ID for outbound call flow |
INTERNAL_API_TOKEN | Recommended | Required by internally gated server routes (/api/twilio/call, /api/summarize, /api/memory/extract) in production. /api/session is publicly callable but rate-limited. |
2. Convex Backend (apps/backend deployment env)
Set these in Convex dashboard for your deployment:
| Variable | Required | Notes |
|---|---|---|
GEMINI_API_KEY | Yes | Used for token vending, embeddings, clustering |
LIVEKIT_URL | Yes | LiveKit API URL (https://...) |
LIVEKIT_API_KEY | Yes | LiveKit credentials |
LIVEKIT_API_SECRET | Yes | LiveKit credentials |
Additional backend vars:
| Variable | Required | Notes |
|---|---|---|
ALLOWED_ORIGINS | Optional | Comma-separated CORS allow-list |
GOOGLE_API_KEY | Optional | Fallback in QA internals if GEMINI_API_KEY missing |
LIVEKIT_EGRESS_MANUAL_START | Optional | Enables explicit egress start logic |
LIVEKIT_EGRESS_RECORDING_MODE | Optional | room_composite or participant_per_role |
LIVEKIT_EGRESS_FILE_TYPE | Optional | Effective output is mp4 in backend |
LIVEKIT_EGRESS_FILEPATH_PREFIX | Optional | Storage prefix for recordings |
LIVEKIT_EGRESS_S3_ACCESS_KEY | Optional | Object storage creds |
LIVEKIT_EGRESS_S3_SECRET | Optional | Object storage creds |
LIVEKIT_EGRESS_S3_BUCKET | Optional | Object storage bucket |
LIVEKIT_EGRESS_S3_REGION | Optional | Region (auto commonly) |
LIVEKIT_EGRESS_S3_ENDPOINT | Optional | S3-compatible endpoint |
LIVEKIT_EGRESS_S3_FORCE_PATH_STYLE | Optional | Path-style toggle |
LIVEKIT_RECORDINGS_PUBLIC_BASE_URL | Optional | Public CDN/base URL for recording playback |
CLI-only variable (not a dashboard env var):
| Variable | Required | Used For |
|---|---|---|
CONVEX_DEPLOY_KEY | Yes for CLI deploy/run | npx convex deploy, npx convex run |
3. SDK Agent Runtime (@riyaan/sdk/agent)
LiveKit voice agent mode
| Variable | Required | Notes |
|---|---|---|
GOOGLE_API_KEY or GEMINI_API_KEY | Yes | Gemini realtime + TTS/LLM paths |
DEEPGRAM_API_KEY | Recommended | Needed for pipeline STT mode |
LIVEKIT_URL | Yes | Agent room connectivity |
LIVEKIT_API_KEY | Yes | LiveKit auth |
LIVEKIT_API_SECRET | Yes | LiveKit auth |
CONVEX_URL | Optional | Backend callbacks for persistence/persona/tools |
APP_SLUG | Optional | Backend auth (room slug parsing can override) |
APP_SECRET | Optional | Backend auth |
Optional runtime tuning
| Variable | Notes |
|---|---|
VOICE_NOISE_PRESET | noisy (default), balanced, or fast preset for VAD/turn/interruption tuning |
PREFER_PIPELINE_FOR_ROBOT_TOOLS | Set false to keep realtime first even for robot-tool rooms |
SILERO_MIN_SILENCE_DURATION | Numeric tuning passed to Silero VAD loader |
SILERO_ACTIVATION_THRESHOLD | Numeric tuning passed to Silero VAD loader |
SILERO_PREFIX_PADDING_DURATION | Numeric tuning passed to Silero VAD loader |
SILERO_MIN_SPEECH_DURATION | Numeric Silero min speech duration (seconds) |
DEEPGRAM_ENDPOINTING_MS | Deepgram endpointing silence window in milliseconds |
AGENT_MIN_INTERRUPTION_DURATION_MS | LiveKit AgentSession minimum speech duration before interruption |
AGENT_MIN_INTERRUPTION_WORDS | LiveKit AgentSession minimum transcript words before interruption |
AGENT_MIN_ENDPOINTING_DELAY_MS | LiveKit AgentSession minimum endpointing delay in milliseconds |
AGENT_MAX_ENDPOINTING_DELAY_MS | LiveKit AgentSession maximum endpointing delay in milliseconds |
REALTIME_VAD_START_SENSITIVITY | Gemini Live realtime VAD start sensitivity (LOW/HIGH) |
REALTIME_VAD_END_SENSITIVITY | Gemini Live realtime VAD end sensitivity (LOW/HIGH) |
REALTIME_VAD_PREFIX_PADDING_MS | Gemini Live realtime VAD prefix padding in milliseconds |
REALTIME_VAD_SILENCE_DURATION_MS | Gemini Live realtime VAD silence duration in milliseconds |
REALTIME_ACTIVITY_HANDLING | Gemini Live activity handling (NO_INTERRUPTION or START_OF_ACTIVITY_INTERRUPTS) |
LIVEKIT_NOISE_CANCELLATION_MODULE_ID | Optional LiveKit noise cancellation module id for server-side input filtering |
LIVEKIT_NOISE_CANCELLATION_OPTIONS_JSON | JSON object string passed as module options for the LiveKit noise cancellation module |
Pi runtime provider keys (when using createAgent)
| Variable | Required | Notes |
|---|---|---|
ANTHROPIC_API_KEY | Optional | Required only for Anthropic provider usage |
OPENAI_API_KEY | Optional | Required only for OpenAI provider usage |
GOOGLE_API_KEY / GEMINI_API_KEY | Optional | Required for Google provider usage |
4. Optional Telephony Adapter Env Vars
Used if your app wires env directly into @riyaan/sdk/telephony adapters:
| Variable | Provider |
|---|---|
TWILIO_ACCOUNT_SID | Twilio |
TWILIO_AUTH_TOKEN | Twilio |
TWILIO_FROM_NUMBER | Twilio |
TELNYX_API_KEY | Telnyx |
TELNYX_CONNECTION_ID | Telnyx |
5. E2E / Playwright
| Variable | Notes |
|---|---|
BASE_URL | Playwright base URL (default http://localhost:3200) |
CI | Affects Playwright server reuse behavior |
E2E_INTEGRATION | Enables integration-spec paths |
E2E_TWILIO_ALLOW_CALLS | Allows real PSTN test call execution |
E2E_TWILIO_TO | Destination number for Twilio call integration tests |
6. Backend Smoke Test (scripts/backend-smoke-test.mjs)
| Variable | Required | Notes |
|---|---|---|
SMOKE_BASE_URL | Yes | Convex deployment HTTP URL, e.g. https://<deployment>.convex.site |
SMOKE_APP_SLUG | Yes | App slug used for auth/session and flow checks |
SMOKE_APP_SECRET | Yes | App secret used to mint session token |
SMOKE_TIMEOUT_MS | Optional | Per-request timeout in milliseconds (default 30000) |
Script fallbacks:
SMOKE_BASE_URLcan fall back toCONVEX_HTTP_URL,NEXT_PUBLIC_CONVEX_URL, orCONVEX_URL.SMOKE_APP_SLUGcan fall back toNEXT_PUBLIC_APP_SLUGorAPP_SLUG.SMOKE_APP_SECRETcan fall back toAPP_SECRET.
Common Pitfalls
Build-time variables
NEXT_PUBLIC_* vars are build-time in Next.js. Changing them requires rebuild/redeploy.
Secret exposure
Keep APP_SECRET server-only. Never expose it through NEXT_PUBLIC_*.
URL protocols
Use wss:// for NEXT_PUBLIC_LIVEKIT_URL and https:// for LIVEKIT_URL.
Voice agent fallback
For full voice-agent fallback behavior, set DEEPGRAM_API_KEY in agent environments.
Edit on GitHub
Last updated on