Skip to main content
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.
  • info logs include request/job metadata (model, peer/job ids, price, timings, byte/token counts).
  • debug may include HTTP request logs (including client_ip); treat debug logs as more sensitive.

Routing and peer selection

For a given model, the Provider peer is selected in this order:
  1. OPENAI_SERVE_MODEL_MAP (if the mapped peer is connected/LCP-ready)
  2. OPENAI_SERVE_DEFAULT_PEER_ID (if set and connected/LCP-ready)
  3. A peer that advertises the model in its manifest supported_tasks (if any)
  4. Fallback to the first connected peer
If there are no connected LCP peers, the request fails.

Model validation

Model validation is designed to prevent accidental misrouting or unexpected charges.
  • If OPENAI_SERVE_MODEL_ALLOWLIST is set: model must be in the allowlist unless OPENAI_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 advertise supported_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

If OPENAI_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.