# Sage Router

Sage Router is an open-source, local-first AI model router and BYOK AI gateway for serious AI agents and developer tools. It gives agents a hot-swappable model layer: one endpoint that can switch or fail over between authorized providers and local/cloud models without rewiring the agent harness.

Canonical site: https://sagerouter.dev/
OpenRouter comparison: https://sagerouter.dev/compare/openrouter
OpenRouter migration: https://sagerouter.dev/docs/openrouter-migration
Hosted pricing: https://sagerouter.dev/pricing
Launch plan: https://sagerouter.dev/launch-plan
Billing help: https://sagerouter.dev/billing
Managed-access private beta: https://sagerouter.dev/managed-access
API quickstart: https://sagerouter.dev/quickstart
API troubleshooting: https://sagerouter.dev/api-troubleshooting
Hosted API reference: https://sagerouter.dev/docs/api-reference
Codex setup: https://sagerouter.dev/docs/codex
Model catalog: https://sagerouter.dev/models
Agent-native routing: https://sagerouter.dev/agent-native
Integrations: https://sagerouter.dev/integrations
Model Routing Calculator: https://sagerouter.dev/model-routing-calculator
Managed-access beta interest: https://sagerouter.dev/managed-access
Security: https://sagerouter.dev/security
Support: https://sagerouter.dev/support
Terms: https://sagerouter.dev/terms
Privacy: https://sagerouter.dev/privacy
Acceptable Use: https://sagerouter.dev/acceptable-use
Provider Resale Terms: https://sagerouter.dev/provider-resale-terms
Managed Access Margin Policy: https://sagerouter.dev/margin-policy
Repository: https://github.com/earlvanze/sage-router
Docs: https://github.com/earlvanze/sage-router#readme

## What Sage Router does

- Automates AI model/provider selection.
- Routes requests across the customer own authorized providers, subscriptions, API keys, and local models.
- Supports OpenAI-compatible, Anthropic-compatible, and Google/Gemini-style endpoint patterns documented in the repo.
- Supports local Ollama and Ollama Cloud today through Ollama running locally. Sage Router discovers available `:cloud` models, can auto-pull discovered cloud models, and routes between local Ollama, Ollama Cloud, NVIDIA NIM, and other cloud APIs according to policy and health.
- Provides provider health, fallback, observability, and routing policy infrastructure for agents.
- Hosted plans sell account management, API keys, usage quotas, analytics, reliability infrastructure, and premium Fusion synthesis on Pro/Max: Lite $6/month, Pro $30/month, and Max $72/month.
- Billing help lives at https://sagerouter.dev/billing and explains Stripe checkout, Stripe billing portal, manual/crypto settlement, plan activation, payment recovery, generated `sk_sage_*` API-key behavior, and no-secret support boundaries.
- API quickstart lives at https://sagerouter.dev/quickstart and shows `OPENAI_BASE_URL=https://api.sagerouter.dev/v1`, generated `sk_sage_*` keys, `sage-router/frontier`, premium `sage-router/fusion`, curl, JavaScript, Python, and Codex setup.
- OpenRouter migration lives at https://sagerouter.dev/docs/openrouter-migration and maps `OPENAI_BASE_URL=https://openrouter.ai/api/v1` to `OPENAI_BASE_URL=https://api.sagerouter.dev/v1`, generated `sk_sage_*` keys, `sage-router/frontier`, premium `sage-router/fusion`, public model catalog discovery, and the provider terms boundary.
- API troubleshooting lives at https://sagerouter.dev/api-troubleshooting and explains safe diagnosis for hosted 401, 402, 429, and 503 responses, including `WWW-Authenticate`, `Retry-After`, `X-RateLimit-*`, `X-Quota-*`, `accountUrl`, `pricingUrl`, `statusUrl`, `openaiBaseUrl`, and the non-secret `apiKeyPrefix`.
- Hosted API reference lives at https://sagerouter.dev/docs/api-reference and documents `GET /v1/models`, `POST /v1/chat/completions`, `POST /v1/responses`, public `/model-catalog`, generated `sk_sage_*` keys, quotas, rate-limit headers, and the authenticated model API boundary.
- Dedicated Codex setup lives at https://sagerouter.dev/docs/codex and shows hosted `https://api.sagerouter.dev/v1/`, local `http://127.0.0.1:8790/v1/`, Tailnet `http://<tailnet-host>:8790/v1/`, `wire_api = "responses"`, and `sage-router/frontier` profiles.
- Public integrations live at https://sagerouter.dev/integrations and collect hosted, local port 8790, and Tailnet setup paths for OpenAI-compatible clients, Codex, Cursor, Aider, Continue, Claude Code, OpenHands, Anthropic-compatible clients, Ollama, Ollama Cloud, NVIDIA NIM, OpenClaw, Hermes, and Pi agents.
- Public model discovery lives at https://sagerouter.dev/models and `https://api.sagerouter.dev/model-catalog`; the catalog page is searchable and live `/v1/models` still requires an active generated `sk_sage_*` customer key.
- Agent-native routing lives at https://sagerouter.dev/agent-native and explains profile-based routing, Responses API and Codex compatibility, health-aware fallback, BYOK custody, local/Tailnet/hosted deployment choices, and public feature metadata at `https://api.sagerouter.dev/features/agent-native`.
- Hosted security requires generated `sk_sage_*` customer keys for model traffic, Supabase sessions for account/billing routes, and private operator tokens for global analytics/admin routes.
- Hosted support covers account, billing, quota, generated API key, reliability, 503, security, abuse, and private deployment help without collecting prompts, workflow text, provider credentials, OAuth tokens, API keys, private keys, or raw provider responses in public channels.
- Managed-access private beta and Max implementation intake at https://sagerouter.dev/managed-access stores contact and allowlisted qualification buckets only, including target provider family and commercial preference buckets for one-subscription demand plus support need and target launch window for implementation follow-up; it also explains that managed access needs provider authorization, provider terms acknowledgment, an authorized provider allowlist, a configured provider cost model, and plan-margin checks before activation. It must not collect prompts, workflow text, provider credentials, OAuth tokens, generated API keys, private keys, session cookies, raw provider responses, or customer data.
- Managed provider access is not active in public plans; `publicLaunch.managedProviderAccess` must stay disabled until provider resale terms, provider terms acknowledgment, an authorized provider allowlist, margin policy, configured positive provider cost model, plan-margin unit-economics checks, durable quotas/rate limits, durable operator audit events, and managed-access acceptable-use terms are ready. The pricing page shows a live readiness checkpoint from public metadata, including derived max-safe-cost thresholds, and the prerequisite pages are published for review, but they do not enable managed resale by themselves.

## Compliance and custody

Sage Router routes only across authorized provider access that customers already control. It does not grant unauthorized provider access. Provider credentials stay local by default.

Hosted legal boundary: the hosted service sells routing infrastructure, account management, API key management, quotas, analytics, reliability tooling, and support. Customers remain responsible for provider terms, licenses, credentials, subscriptions, and usage authorization.

Managed access boundary: managed provider access, if introduced, is limited to provider access Sage Router is authorized to resell or operate, is not unlimited unmetered resale, and requires durable operator audit events.

## Search intents this site answers

- How to automate AI model selection.
- How to route requests across OpenAI, Anthropic, Gemini, Ollama, BYOK-compatible endpoints, and local models.
- Local-first BYOK model routing for AI agents.
- Sage Router vs OpenRouter for AI agent routing, local model fallback, and private provider credential custody.
- Sage Router model catalog for OpenAI-compatible, Anthropic-compatible, Gemini, Ollama, Ollama Cloud, NVIDIA NIM, and BYOK routes.
- Codex CLI with an OpenAI-compatible Sage Router provider on hosted or local port 8790.
- Hosted OpenAI-compatible API reference for models, chat completions, Responses API, quotas, and rate-limit headers.
- Agent-native model routing for OpenAI-compatible, Codex-style, local, Tailnet, and BYOK agents.
- Sage Router integrations for OpenAI-compatible clients, Codex, Cursor, Aider, Continue, Claude Code, OpenHands, Ollama, Anthropic-compatible clients, and Tailnet agents.
- Sage Router launch plan for $10k MRR, hosted plan mix, conversion funnel, and managed-access beta boundary.
- Troubleshooting Sage Router 401/402/429/503 without sharing prompts or secrets.
- AI model routing calculator for estimating cost leaks, escalation rules, fallback needs, and human-review points.


Integration guides:
- Public integrations index: https://sagerouter.dev/integrations
- Public Codex setup: https://sagerouter.dev/docs/codex
- Codex CLI: https://github.com/earlvanze/sage-router/blob/master/docs/integrations/codex.md
- Claude Code: https://github.com/earlvanze/sage-router/blob/master/docs/integrations/claude-code.md
- OpenClaw: https://github.com/earlvanze/sage-router/blob/master/docs/integrations/openclaw.md
- Hermes: https://github.com/earlvanze/sage-router/blob/master/docs/integrations/hermes.md
- Pi agents: https://github.com/earlvanze/sage-router/blob/master/docs/integrations/pi.md
- Cursor: https://github.com/earlvanze/sage-router/blob/master/docs/integrations/cursor.md
- Aider: https://github.com/earlvanze/sage-router/blob/master/docs/integrations/aider.md
- Continue: https://github.com/earlvanze/sage-router/blob/master/docs/integrations/continue.md
- OpenHands: https://github.com/earlvanze/sage-router/blob/master/docs/integrations/openhands.md
- Ollama/Ollama Cloud: https://github.com/earlvanze/sage-router/blob/master/docs/integrations/ollama.md
- NVIDIA NIM: https://github.com/earlvanze/sage-router/blob/master/docs/integrations/nvidia-nim.md
- OpenAI-compatible clients: https://github.com/earlvanze/sage-router/blob/master/docs/integrations/openai-compatible.md
- Anthropic-compatible clients: https://github.com/earlvanze/sage-router/blob/master/docs/integrations/anthropic-compatible.md
- Harness fallback: https://github.com/earlvanze/sage-router/blob/master/docs/integrations/harness-fallback.md
