API Keys
RadarOS supports per-request API key overrides so clients can pass their own API keys instead of relying on server-side environment variables. Useful for multi-tenant apps, user-provided keys, and development.Supported Headers
| Header | Provider | Use Case |
|---|---|---|
x-openai-api-key | OpenAI | GPT, embeddings |
x-google-api-key | Gemini, embeddings | |
x-anthropic-api-key | Anthropic | Claude |
x-api-key | Generic | Fallback when provider-specific key not set |
How It Works
- Client sends a request with one of the headers (or
apiKeyin body). - Transport layer extracts the key via
extractApiKey(). - Key is passed to
agent.run(input, { apiKey })oragent.stream(input, { apiKey }). - The model provider uses the per-request key instead of
process.env.*.
REST (Express)
Socket.IO
Provider Matching
The transport layer uses a priority-based matching system:-
Provider-specific headers — Highest priority. Matched directly to the provider:
x-openai-api-key→ used when agent uses an OpenAI modelx-google-api-key→ used when agent uses a Google/Vertex modelx-anthropic-api-key→ used when agent uses an Anthropic model
-
Generic header —
x-api-keyis used as a fallback when no provider-specific header is found. The transport passes it to whatever provider the agent uses. -
Body parameter —
apiKeyin the request body is the final fallback.
Security Notes
HTTPS Required
Always use HTTPS in production. API keys sent over HTTP are visible to network intermediaries.
No Key Logging
Never log request headers or bodies that may contain API keys. Configure your logging middleware to redact sensitive headers.
Key Rotation
Support key rotation by accepting new keys without downtime. Per-request keys make this seamless — clients switch to new keys immediately.
Rate Limiting
Apply rate limiting per API key to prevent abuse in multi-tenant setups.