cd /news/large-language-models/multi-provider-llm-router-or-how-i-g… Β· home β€Ί topics β€Ί large-language-models β€Ί article
[ARTICLE Β· art-125387] src=dev.to β†— pub= topic=large-language-models verified=true sentiment=↑ positive

Multi-Provider LLM Router, or How I Got Tired of Forgetting Which API Format I Had To Use

A developer has open-sourced fastapi-multi-llm-starter, an MIT-licensed FastAPI template that unifies streaming access to multiple LLM providers including Anthropic, Google, OpenAI, and DeepSeek behind a single asynchronous endpoint. The router exposes POST /v1/chat/stream, which accepts a unified payload and emits standardized SSE events for thinking, content, tool calls, and completion, with models defined dynamically in a models.json catalog rather than hardcoded. The repository includes pytest coverage, Pydantic v2 schemas, and a built-in testing playground at localhost:8000.

by read2 min views4 publishedSep 10, 2026

If you've ever built an application that integrates with multiple LLM providers (Anthropic, Google, OpenAI, DeepSeek), you already know the pain:

I recently extracted the core streaming router from my platform into an open-source FastAPI template. Here is how it works.

A single asynchronous endpoint:

POST /v1/chat/stream

It accepts a unified request payload and returns a standardized SSE stream emitting four clean events:

event: thinking β€” Internal model reasoning tokens (streamed in real-time).event: content β€” User-facing response text.event: tool_call β€” Function calling requests.event: done β€” Stream completion ([DONE]). Instead of pulling heavy wrapper frameworks, use direct asynchronous HTTP via httpx.AsyncClient and the official Google GenAI SDK:

fastapi-multi-llm-starter/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ config.py       # Pydantic Settings  environment variables
β”‚   β”œβ”€β”€ main.py         # FastAPI app with CORS, health check & test playground
β”‚   β”œβ”€β”€ models.json     # Dynamic model catalog (Claude, Gemini, GPT)
β”‚   β”œβ”€β”€ router.py       # Unified multi-provider async stream dispatcher
β”‚   └── schemas.py      # Strict Pydantic v2 validation models
β”œβ”€β”€ tests/              # Automated unit tests (pytest)
β”œβ”€β”€ requirements.txt
└── README.md

I disliked the idea of hardcoded models, so I decoupled them into a models.json file:

{
  "models": [
    {
      "id": "claude-sonnet-5",
      "name": "Claude Sonnet 5",
      "provider": "Anthropic",
      "thinking": true
    },
    {
      "id": "gemini-3.8-flash",
      "name": "Gemini 3.8 Flash",
      "provider": "Google",
      "thinking": true
    },
    {
      "id": "gpt-5.6-terra",
      "name": "GPT 5.6 Terra",
      "provider": "OpenAI",
      "thinking": true
    }
  ]
}

Now, if you want to add another model, you just edit the JSON. The backend and the embedded UI dynamically populate available models via GET /v1/models.

The repository includes a testing playground running directly at http://localhost:8000/. You can immediately test prompts, check streaming latency, and verify reasoning blocks without setting up a frontend framework.

Of course, you'll need your own API keys.

The full core code is open-source under the MIT License on GitHub:

πŸ‘‰ github.com/wolfnomknight/fastapi-multi-llm-starter

Includes full pytest test coverage, .env.example, and clean Pydantic v2 schemas.

Feel free to fork it, use it in your side projects or micro-SaaS, and let me know if you run into any issues or have ideas for additional providers!

── more in #large-language-models 4 stories Β· sorted by recency
── more on @fastapi 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/multi-provider-llm-r…] indexed:0 read:2min 2026-09-10 Β· β€”