openai-serve is configured via environment variables.
You can use apps/openai-serve/.envrc.sample (direnv) for local development.
Environment variables
Logging (privacy)
openai-serve logs are intentionally designed to avoid persisting raw user content.
- Logs MUST NOT contain raw prompts (
messages[].content) or raw model outputs. infologs include request/job metadata (model, peer/job ids, price, timings, byte/token counts).debugmay include HTTP request logs (includingclient_ip); treat debug logs as more sensitive.
Routing and peer selection
For a givenmodel, the Provider peer is selected in this order:
OPENAI_SERVE_MODEL_MAP(if the mapped peer is connected/LCP-ready)OPENAI_SERVE_DEFAULT_PEER_ID(if set and connected/LCP-ready)- A peer that advertises the model in its manifest
supported_tasks(if any) - Fallback to the first connected peer
Model validation
Model validation is designed to prevent accidental misrouting or unexpected charges.- If
OPENAI_SERVE_MODEL_ALLOWLISTis set:modelmust be in the allowlist unlessOPENAI_SERVE_ALLOW_UNLISTED_MODELS=true. - Otherwise: if any connected peers advertise
supported_tasks, the model must be advertised by at least one peer. If no peers advertisesupported_tasks, validation is skipped to keep the gateway usable.
Safety limits
OPENAI_SERVE_MAX_PRICE_MSAT: upper-bound quote prices (rejects quotes above this value)OPENAI_SERVE_TIMEOUT_QUOTE/OPENAI_SERVE_TIMEOUT_EXECUTE: bounds quote/execution duration
Authentication
IfOPENAI_SERVE_API_KEYS is set (comma-separated keys), all /v1/* endpoints require:
/healthz is intentionally not protected (useful for local probes); protect it at the reverse-proxy layer if needed.