LiteLLM Integration
LiteLLM is a unified LLM proxy that provides a single interface to call 100+ LLM APIs. LangGuard integrates with LiteLLM to monitor all model traffic flowing through your proxy.
Overview
The LiteLLM integration enables LangGuard to:
- Monitor all LLM calls routed through your LiteLLM proxy
- Track usage per model and provider across your organization
- Capture request/response data for policy evaluation
- Analyze costs and performance across models
- Enforce policies in real time by auto-installing guardrails into your proxy
Prerequisites
- A running LiteLLM proxy instance
- LiteLLM master key or API key
- LangGuard admin role
Setup
Step 1: Get Your Credentials
From your LiteLLM deployment:
- Locate your Proxy URL (e.g.,
https://litellm.yourcompany.com) - Copy your Master Key or an API key with admin access
Step 2: Add Integration in LangGuard
- Navigate to Integrations in the sidebar
- Click Add Integration
- Select AI Gateways > LiteLLM
- Enter:
- Name: A friendly name (e.g., "Production LiteLLM Proxy")
- Proxy URL: Your LiteLLM proxy endpoint
- API Key: Your LiteLLM master key
- Poll interval (optional): how often LangGuard polls the proxy for discovery
- Install LangGuard guardrails (optional): auto-install real-time policy enforcement (see Real-time guardrails)
- Click Test Connection
- Click Save
Proxy URL requirements
LangGuard connects to your proxy from its own network. The requirements depend on where LangGuard runs.
| Where LangGuard runs | Proxy URL requirements |
|---|---|
| LangGuard cloud | The URL must use https://. The host name must resolve to public addresses only. The URL must not contain a user name or a password. |
| Private install | The proxy can be on your private network. http:// and private addresses are accepted. |
On LangGuard cloud, these URLs are refused:
http://localhost:4000and otherhttp://addresses- A private address, for example
https://10.0.0.5 - A host name that resolves to a private address
- A host name that does not resolve
If the URL is refused, the connection test and each sync fail with the message "LiteLLM base URL must be an https address of a public host."
To connect a proxy that is not reachable from the internet, use one of these options:
- Publish the proxy at a public
https://address and limit access with the master key and your network controls. - Use a private install of LangGuard on the same network as the proxy.
What Gets Captured
Model Requests
All requests proxied through LiteLLM are captured:
| Field | Description |
|---|---|
| Model | The model called (e.g., gpt-4, claude-3-sonnet) |
| Provider | The upstream provider |
| Input/Output Tokens | Token counts |
| Latency | Response time |
| Cost | Per-request cost |
| Status | Success or error |
| User | The LiteLLM user or API key that made the request |
Proxy Metadata
- Virtual model mappings (which model alias mapped to which provider)
- Rate limit and budget tracking per key
- Fallback and retry events
Real-time guardrails
Beyond monitoring, LangGuard can enforce policies on LiteLLM traffic in real time by installing guardrails into your LiteLLM proxy.
When you enable Install LangGuard guardrails during setup, LangGuard:
- Mints a scoped API key for the proxy
- Registers
pre_callandpost_callguardrail hooks in your LiteLLM configuration - Routes each call through LangGuard policy evaluation, which can allow, flag, or block the request
MCP tool calls through the LiteLLM MCP gateway follow the
Enforcement Mode. In Shadow mode (the default) LangGuard
never returns a block for an MCP tool call. It records what Enforce mode would do. Chat
requests do not use this setting. Shadow mode controls the LangGuard result only. If
LangGuard does not answer (a timeout, a request that is too large, or an internal
error), the unreachable_fallback: fail_closed setting that LangGuard installs makes
LiteLLM block the call. The MCP servers and tools that LiteLLM offers to agents follow
the mode too: in Enforce mode a server or tool set to Block on the MCP Enforcement
page is not offered, and in Shadow mode it is, with one exception (see
The AI Gateway tool list).
If LangGuard can't reach the LiteLLM admin API to push the configuration
automatically, the setup dialog provides a config.yaml snippet you can paste
into your proxy to wire up the guardrail manually.
Troubleshooting
No Traces Appearing
- Verify your proxy URL is accessible from LangGuard
- Check that your API key has the correct permissions
- Ensure your LiteLLM proxy is logging requests (check LiteLLM settings)
- Try triggering a manual sync
"LiteLLM base URL must be an https address of a public host"
On LangGuard cloud, the proxy URL must use https:// and resolve to public addresses. See Proxy URL requirements.
Connection Timeout
- Confirm the proxy URL is correct and includes the protocol (
https://) - Check network connectivity between LangGuard and your proxy
- Verify your proxy is running and healthy
Next Steps
- Integrations Overview — See all available integrations
- Trace Explorer — Analyze captured traces
- Cost Estimates — Configure cost-per-token rates