OpenRouter in Production Best Practices
Ten practices for reliability, cost control, and observability when OpenRouter backs a production agent.
Busca en todas las páginas de la documentación
Ten practices for reliability, cost control, and observability when OpenRouter backs a production agent.
Use this as a launch rubric and a quarterly review checklist.
model_ref values mapped by config. Promotions and rollbacks are registry edits, not multi-file refactors.HTTP-Referer / X-Title (or current equivalents) from the shared client.Retry-After; do not retry auth or bad-request errors.Items 1-10 are the core production practices. Items 11-15 extend them into observability and change control after launch.
A single gateway with registry-mapped models (practices 1-2). Most other controls hang off that seam.
No.
They apply to custom loops and frameworks alike.
On every registry change, and on a calendar cadence (for example monthly) because quality and pricing shift.
No.
Combine bounded client retries with capability-safe model fallbacks. See OpenRouter Rate Limits, Retries, and Backoff Strategies.
Only on noncritical paths after tool evals and with strict rate/cost caps. Hot agent paths need predictable capacity.
Credit exhaustion, 429 storms, fallback disable switch, registry rollback, and where to read latency/cost dashboards.
Canary ramps help ops, but multi-turn agents still need per-run stickiness when two models are live.
Treat Ollama as another backend behind the same gateway and apply practices 8-10 carefully for local-only data. See Building a Self-Hosted Fallback Layer: Ollama + OpenRouter.
More than one module constructing OpenAI/OpenRouter clients or hardcoding base_url outside the gateway package.
Prefer eng-owned config with product input via experiments. Unreviewed slug changes are production incidents waiting to happen.
Launch PR templates, agent platform README, and quarterly reliability reviews.
Stack versions: Pins from the category manifest (verify at build): OpenRouter (~315+ models, July 2026 pricing/fees); LangGraph 1.0+; CrewAI 1.14+; Microsoft Agent Framework 1.0; Vercel AI SDK 6; Pydantic AI (latest); LlamaIndex (latest); OpenAI Agents SDK (latest + MCP); MCP (Linux Foundation governance); A2A (HTTP+SSE+JSON-RPC 2.0); Solana
@solana/web3.js+@solana/spl-token.
Revisado por Chris St. John·Última actualización: 16 jul 2026