LLM gateways: when does a small team need LiteLLM, and when is the SDK enough?

AIWister Xue3 repliesThis topic is about BerriAI/litellm

3
Wister XueMember#1

A gateway sits between your applications and the model providers and presents one API. LiteLLM is the project most people mean; "gateway" has also become a pattern with several implementations. Notes on when it earns its place.

What LiteLLM does. As a library, it translates one call shape (the OpenAI format) to over a hundred providers. As a proxy (litellm --config config.yaml), it adds the things a team needs: virtual API keys per user or project with budgets, spend logging per key and per model, fallbacks when a provider errors or rate-limits, retries, and routing between deployments. The core is MIT; some enterprise features are paid. The proxy needs Postgres once you use keys and budgets.

When you need it. More than one provider in use, or the plan to switch. More than one team or application sharing a bill and needing to know who spent what. A provider outage that must not be an incident. Any of these is enough.

When you do not. One application, one provider, one key. The SDK is fine, and the gateway is an extra hop, an extra process and an extra config file to keep in sync with the model names. Add it when the second provider arrives, not before.

The hidden cost. Model names. A gateway gives you aliases (gpt-4o can point anywhere), which is the feature, and also means the name in your code no longer tells you what you are calling. Name the aliases by purpose (chat-fast, extract-json) rather than by model, or the indirection buys nothing.

/learn/llm-gateway covers the pattern; /compare/gateway-vs-litellm compares LiteLLM with another implementation of it.

3 replies

MarsMember#2

On overhead: the extra hop is single-digit milliseconds on the same network, which is noise next to a generation that takes seconds. The cost that does show up is streaming through a proxy that buffers; LiteLLM streams properly, but if you put nginx in front of it, see the Open WebUI thread on the Help board for the proxy_buffering off lesson. Same problem, same fix.

EricMember#3

The fallback configuration is the part worth getting right on day one, because you only find out it is wrong during the outage. The two things that trip people: the fallback model must have the same capabilities (a vision call falling back to a text-only model fails differently, later), and the fallback provider needs its own rate limit headroom, or you move the outage rather than absorb it.

Wister XueAuthorMember#4

In reply to Eric (#3)

Both true, and the second one is why "fallback" is not the same as "redundancy". A fallback provider you have never sent traffic to has a rate limit you have never tested.