Ollama routing for agents

Ollama AI model router for local, cloud, and fallback paths

Keep local Ollama and Ollama Cloud in the same model layer as OpenAI, Anthropic, Gemini, NVIDIA NIM, private gateways, and hosted Sage Router keys. Agents keep one OpenAI-compatible endpoint while routing policy handles cost, capability, and reliability.

Create hosted key Read quickstart Run locally Browse models

Local Ollama stays local

Run Sage Router beside your local Ollama runtime and point Codex, OpenClaw, Cursor, Aider, Continue, OpenHands, or any OpenAI SDK client at one local base URL.

Ollama Cloud fits too

Use Ollama Cloud models exposed through Ollama while keeping the same router policy, telemetry, and fallback chain used for provider APIs and private endpoints.

429 failover without rewiring

When a provider key or route hits a retryable rate limit, Sage Router can fail over to another eligible provider, another API key, or a local Ollama fallback.

60-second Ollama router start

export OLLAMA_HOST=http://127.0.0.1:11434
python3 router.py --port 8790

export OPENAI_BASE_URL=http://127.0.0.1:8790/v1
export OPENAI_API_KEY=local-router

curl "$OPENAI_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sage-router/frontier",
    "messages": [{"role": "user", "content": "Use local or cloud routes intelligently"}]
  }'

Multiple API keys

Configure several OpenAI, Anthropic, Gemini, or compatible keys for one provider, then balance load and fail over when a single credential is rate-limited.

Multimodal routing

Image, audio, video, and document inputs route only to capable models. Learned served modalities are recorded per model to improve future routing decisions.

Agent profiles

Use stable profiles such as sage-router/frontier or direct Ollama models while the router enforces health, capability, and fallback rules.

Why not point every agent directly at Ollama?

Direct Ollama works for one machine and one model family. Agents usually need more: local fallback plus hosted frontier models, provider health checks, 429 failover, multiple API-key load balancing, model capability gates, hosted key activation, and Tailnet or public-edge access. Sage Router keeps Ollama in that path instead of replacing it.

Next steps

Create an API key, read the hosted/local quickstart, see the self-hosted path, or compare OpenRouter.