Why I wanted a gateway
By the end of the summer I had three small internal tools talking to four model providers, each with its own SDK, its own key in its own .env file, and its own idea of what a rate-limit error looks like. Switching one tool to a cheaper model meant a code change and a redeploy. Finding out what last month cost meant logging into four dashboards.
What I wanted was boring: one OpenAI-compatible endpoint inside the network, one key per app, a spend figure per key, and a way to fail over when a provider has a bad afternoon.
The setup
LiteLLM's proxy runs as a single container with a YAML file describing the models it can route to. Postgres is optional, but you need it for virtual keys and spend tracking, so I ran it from day one.
model_list:
- model_name: fast
litellm_params:
model: provider-a/small-model
api_key: os.environ/PROVIDER_A_KEY
- model_name: fast
litellm_params:
model: provider-b/small-model
api_key: os.environ/PROVIDER_B_KEY
router_settings:
routing_strategy: simple-shuffle
num_retries: 2
Two entries with the same model_name become a pool. The apps ask for fast and stop caring which provider answers. That alone was worth the afternoon it took.
What worked
- One endpoint, one client. All three apps now use the OpenAI client pointed at the proxy. Moving a tool to another model is a YAML change and a restart.
- Per-app keys with budgets. Each app gets a virtual key with a monthly cap. When the summariser went into a retry loop, it hit its cap instead of my card.
- Fallbacks I didn't have to write. When one provider returned errors for an evening, requests went to the other pool member and nobody noticed.
What got in the way
The configuration surface is large, and the docs move quickly. Twice I followed an example that used a setting name from an older release. Pin the image tag, read the changelog before upgrading, and keep the config in git.
The admin UI is useful for checking keys and spend, but I would not hand it to someone non-technical. Some of the features I reached for first, such as SSO, are in the enterprise tier.
The gateway becomes the single point every model call goes through. Treat it like a database: monitored, backed up, upgraded on purpose.