Skip to main content
Put Gateway calls behind one service on your backend, keep keys out of clients and logs, retry only what is safe to retry, and watch latency, cost and errors per model. Each section below links to the page with the details.

Structure the integration

  • Wrap Gateway calls in one service or SDK client, so a model or provider change stays in one place. See Integrating with the Gateway.
  • Stream responses to chat UIs, so users see tokens as they arrive. See Streaming.
  • Queue work that isn’t urgent, such as background generations and evaluations, to smooth out traffic spikes. The Batch API runs large jobs asynchronously.

Keep keys secret

  • Store API keys in a secrets manager (AWS Secrets Manager, Doppler, 1Password) rather than .env files in production.
  • Call the Gateway from your backend, and authenticate your own client apps to it, so clients never hold a Gateway key.
  • Log only a key’s prefix, such as phaseo_v1_sk_<kid>, never the secret.
See Authentication.

Retry safely

  • Retry 429 and 5xx responses with exponential backoff and jitter.
  • Wait for Retry-After before retrying a rate-limited request.
  • Check which provider served each request in request logs, so you notice when traffic fails over to another provider.
See Errors and Debugging and Rate Limits.

Watch the right signals

See Request logs and observability. Keep your prompt templates, parameters and output handling documented where your team can review them; presets keep shared prompts and defaults in one place.
Last modified on November 5, 2026