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
.envfiles 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.
Retry safely
- Retry
429and5xxresponses with exponential backoff and jitter. - Wait for
Retry-Afterbefore retrying a rate-limited request. - Check which provider served each request in request logs, so you notice when traffic fails over to another provider.
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.