Proxies & Multi-provider Gateways: AI Resources 2025

Proxies & Multi-provider Gateways: AI Resources 2025

This is the glue between your apps and a messy, ever-shifting model landscape. You point everything at one URL that speaks the OpenAI API, and the gateway translates those requests to whichever backend you choose—cloud (OpenAI, Anthropic, Google, Mistral, Groq, Bedrock, Azure) or local runners (Ollama, vLLM, TGI) on localhost. The result: a single code path for dev, staging, and prod; model swaps become config changes, not rewrites. These gateways typically handle streaming, retries/fallbacks, load balancing across multiple deployments, per-team API keys, rate limits, and spend/budget tracking. They also let you alias models (“gpt4o” → today’s best pick), route by policy (PII? force local), and keep a paper trail with request/response logging.

Operationally, this layer lets you run local-first and burst to cloud when traffic spikes or a feature is missing, without touching your app code. It also de-risks vendor lock-in: if prices, latency, or quality shift, you update routing rules and carry on. Practical tips: keep the proxy private (behind a reverse proxy/auth), separate keys per environment/team, set sane token/latency budgets, and enable observability (metrics + structured logs). Expect provider quirks (parameter names, tokenization, tool/function calling variants); the gateway smooths most—but not all—edges, so validate outputs and timeouts. Done right, this tier becomes your “model OS,” standardizing how everything from chat UIs to agents operate, via one consistent interface.


LiteLLM (OpenAI-compatible gateway across 100+ providers & local backends)

What it is: LiteLLM is a lightweight LLM gateway + SDK that lets you send standard OpenAI-style requests to… basically everything: OpenAI, Anthropic, Google, Groq, Mistral, Bedrock, Azure, Hugging Face endpoints, and local servers like Ollama, vLLM, or TGI. Use it as a drop-in proxy your apps call, or as a Python client inside your codebase. One interface, many backends.

What it does: You define models in a config.yaml (aliases + provider params), start the server, and then hit OpenAI-compatible routes (/v1/chat/completions, /v1/completions, /v1/embeddings) from any SDK/UI. It handles streaming, retries/fallbacks, load-balancing, budget/cost tracking, and rate limits so your clients don’t have to. Crucially, you can point model entries at local runners (Ollama, vLLM, HF/TGI) and keep everything on-box.

Notes:

  • Gateway, not a model: It translates and forwards OpenAI-style calls to whatever provider you choose; your code and UIs don’t change.

  • Load-balanced & resilient: Router supports cooldowns, retries, timeouts, fallbacks, and multi-deployment load balancing.

  • Budgets, spend, limits: Built-in cost tracking (per key/team/project) and rpm/tpm rate limits; headers report current limits.

  • Local friendly: First-class docs for Ollama and vLLM; Hugging Face pages cover managed or self-hosted TGI.

  • Keep it private: It’s a real HTTP server—bind to localhost or put it behind a reverse proxy + auth before exposing it. (Best-practices guide included.)



Quick start (proxy)

# 1) Install the proxy server
pip install "litellm[proxy]"
# 2) Create config.yaml (two models: OpenAI & local Ollama)
model_list:
  - model_name: gpt4o          # alias clients will use
    litellm_params:
      model: openai/gpt-4o
      api_key: "os.environ/OPENAI_API_KEY"
  - model_name: llama3-local
    litellm_params:
      model: ollama/llama3
      api_base: "http://localhost:11434"   # your Ollama
# 3) Run the gateway (defaults to port 4000)
litellm --config config.yaml
# 4) Call it like OpenAI (works with any OpenAI SDK/UI)
curl -s http://127.0.0.1:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-local-demo" \
  -d '{
    "model": "llama3-local",
    "messages": [{"role":"user","content":"Explain SIMD in one paragraph."}],
    "stream": true
  }'

Streams work the same way.


Why you’d pick LiteLLM

  • Standardize on one API while mixing providers/models freely. Great for “run local by default, burst to cloud when needed.

  • Control & observability out of the box: budgets, spend, limits, and Prometheus-friendly response headers.

  • Operational resilience without glue code: load-balancing, retries, fallbacks, and provider cooldowns.


Links:
GitHub (source & README): https://github.com/BerriAI/litellm
Docs (home): https://docs.litellm.ai/
Proxy quick start: https://docs.litellm.ai/docs/proxy/quick_start
Providers list (100+): https://docs.litellm.ai/docs/providers
Ollama via LiteLLM: https://docs.litellm.ai/docs/providers/ollama
vLLM via LiteLLM: https://docs.litellm.ai/docs/providers/vllm
Hugging Face/TGI paths: https://docs.litellm.ai/docs/providers/huggingface
Prod best practices: https://docs.litellm.ai/docs/proxy/prod
Spend tracking: https://docs.litellm.ai/docs/proxy/cost_tracking
Rate limits & keys: https://docs.litellm.ai/docs/proxy/users