You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move API keys from bundled .env to backend-served (#5726)
## Summary
- New `GET /v1/config/api-keys` backend endpoint serves Deepgram,
Gemini, and Anthropic keys to authenticated users
- New `APIKeyService` singleton fetches keys from backend after sign-in,
holds in memory only (never persisted to disk)
- Bundled `.env` keys loaded as fallback during transition, overwritten
once backend keys arrive
- Developer API Keys UI in Settings > Advanced for custom key overrides
(like mobile app pattern)
- Keys cleared on sign-out
- Cloud Run backend already updated with all 3 keys in env vars
## How it works
1. App starts → loads `.env` (fallback keys for transition)
2. User signs in → `APIKeyService.fetchKeys()` calls backend
3. Backend returns keys → set in memory via `setenv()`
4. ACP bridge, Gemini, Deepgram all use the backend-provided keys
5. Developer overrides in Settings take precedence over backend keys
## Next steps (after this merges)
- Remove API keys from `OMI_DESKTOP_APP_ENV` Codemagic secret (once
backend endpoint is deployed)
- Proxy Deepgram/Gemini calls through backend (eliminates key exposure
entirely)
## Test plan
- [x] Both Swift and Rust builds compile
- [x] Backend endpoint returns all 3 keys to authenticated user (tested
with curl)
- [x] App fetches keys from backend: "Fetched keys from backend
(deepgram=true, gemini=true, anthropic=true)"
- [x] Fallback works when backend unavailable
- [x] Chat works with backend-served keys
- [x] Retry with backoff (3 attempts, 1s/2s/4s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
0 commit comments