LiteLLM
LiteLLM is an open-source proxy with an OpenAI-compatible API. In the context of WEBCON, it acts as a bridge between AI Proxy and language models — both hosted locally (e.g., Llama, Mistral via Ollama) and at external cloud providers (OpenAI, Azure, Anthropic). It allows you to use AI features without depending on a single provider.
When to choose LiteLLM
You want to run language models in your own infrastructure — without sending data to external AI providers.
Requirements
- a running LiteLLM instance (self-hosted),
- a LiteLLM virtual key (
master_keyor a key generated via/key/generate).
If your organization requires OIDC authentication, the following are also needed:
- an OIDC token server supporting the
client_credentialsflow (e.g., Keycloak, Azure AD), ClientIdandClientSecretof a registered OIDC client.
Step 1: Prepare LiteLLM
Run LiteLLM
The following example configures LiteLLM with models hosted locally via Ollama — with no connection to external AI providers.
# litellm_config.yaml
model_list:
- model_name: llama3
litellm_params:
model: ollama/llama3
api_base: http://ollama:11434
- model_name: mistral
litellm_params:
model: ollama/mistral
api_base: http://ollama:11434
general_settings:
master_key: sk-litellm-master-key
docker run -d \
-p 4000:4000 \
-v ./litellm_config.yaml:/app/config.yaml \
ghcr.io/berriai/litellm:main-latest \
--config /app/config.yaml
Full LiteLLM configuration documentation is available at docs.litellm.ai.
Create a virtual key
LiteLLM virtual keys provide access control and resource limits per client.
curl -X POST http://localhost:4000/key/generate \
-H "Authorization: Bearer sk-litellm-master-key" \
-H "Content-Type: application/json" \
-d '{"models": ["llama3", "mistral"], "max_budget": 10}'
The response contains a key field — this is the LiteLLM virtual key that will be used by AI Proxy.
Step 2: Configure AI Proxy
Choose one of three authentication variants depending on your LiteLLM instance configuration.
Variant A — standard Authorization header (recommended)
The simplest variant: AI Proxy passes the virtual key as Authorization: Bearer <key>. No changes to LiteLLM are required.
aiconfiguration.json
{
"ProviderConnections": {
"LiteLlm": {
"Description": "LiteLLM — standard Authorization Bearer",
"Type": "OpenAiApiCompatible",
"ProviderConfiguration": {
"Endpoint": "http://litellm:4000",
"ApiKey": "sk-your-litellm-virtual-key",
"InlineFileAttachments": true,
"InlineFileAttachmentsMaxBytes": 20971520
}
}
}
}
The ApiKey value is sent automatically by the SDK as Authorization: Bearer <ApiKey>. Enter only the key itself — without the Bearer prefix.
docker-compose.yml
environment:
- ProviderConnections__LiteLlm__ProviderConfiguration__Endpoint=http://litellm:4000
- ProviderConnections__LiteLlm__ProviderConfiguration__ApiKey=sk-your-litellm-virtual-key
Variant B — custom HTTP header with virtual key
Use this variant if you want LiteLLM to read the virtual key from a custom HTTP header instead of the standard Authorization header. This requires a change to the LiteLLM configuration.
litellm_config.yaml
Add the litellm_key_header_name option in the general_settings section:
general_settings:
master_key: sk-litellm-master-key
litellm_key_header_name: "x-litellm-key" # LiteLLM will look for the key in this header
aiconfiguration.json
{
"ProviderConnections": {
"LiteLlm": {
"Description": "LiteLLM — custom header with virtual key",
"Type": "OpenAiApiCompatible",
"ProviderConfiguration": {
"Endpoint": "http://litellm:4000",
"Headers": {
"x-litellm-key": "Bearer sk-your-litellm-virtual-key"
},
"InlineFileAttachments": true,
"InlineFileAttachmentsMaxBytes": 20971520
}
}
}
}
Header value must include the Bearer prefix
Headers defined in the Headers section are passed verbatim. If LiteLLM expects the format Bearer <key> in the x-litellm-key header, the value in the configuration must contain the full Bearer sk-....
docker-compose.yml
environment:
- ProviderConnections__LiteLlm__ProviderConfiguration__Endpoint=http://litellm:4000
- ProviderConnections__LiteLlm__ProviderConfiguration__Headers__x-litellm-key=Bearer sk-your-litellm-virtual-key
Variant C — OIDC authentication (client_credentials)
Use this variant if your LiteLLM instance requires an access token from an OIDC server instead of a static key.
aiconfiguration.json
{
"ProviderConnections": {
"LiteLlm": {
"Description": "LiteLLM — OIDC client_credentials",
"Type": "OpenAiApiCompatible",
"ProviderConfiguration": {
"Endpoint": "http://litellm:4000",
"OidcAuthorization": {
"TokenEndpoint": "https://your-oidc-provider/realms/your-realm/protocol/openid-connect/token",
"ClientId": "your-client-id",
"ClientSecret": "your-client-secret"
},
"InlineFileAttachments": true,
"InlineFileAttachmentsMaxBytes": 20971520
}
}
}
}
docker-compose.yml
environment:
- ProviderConnections__LiteLlm__ProviderConfiguration__Endpoint=http://litellm:4000
- ProviderConnections__LiteLlm__ProviderConfiguration__OidcAuthorization__TokenEndpoint=https://your-oidc-provider/realms/your-realm/protocol/openid-connect/token
- ProviderConnections__LiteLlm__ProviderConfiguration__OidcAuthorization__ClientId=your-client-id
- ProviderConnections__LiteLlm__ProviderConfiguration__OidcAuthorization__ClientSecret=your-client-secret
Model and routing configuration
The ProviderModels and AiTaskTypesConfiguration sections are shared across all variants:
{
"ProviderModels": [
{
"Id": "11111111-1111-1111-1111-111111111111",
"ConnectionName": "LiteLlm",
"Priority": 100,
"Name": "LiteLLM Llama3",
"Description": "",
"TextModel": {
"ModelName": "llama3"
}
},
{
"Id": "22222222-2222-2222-2222-222222222222",
"ConnectionName": "LiteLlm",
"Priority": 90,
"Name": "LiteLLM Mistral",
"Description": "",
"TextModel": {
"ModelName": "mistral"
}
}
],
"AiTaskTypesConfiguration": {
"ConciergePrompt": [ "11111111-1111-1111-1111-111111111111" ],
"ConciergeExecuteTool": [ "22222222-2222-2222-2222-222222222222" ]
}
}
Step 3: Full docker-compose.yml example
The following example uses Variant A (standard Authorization Bearer):
name: aiproxy_containers
services:
ai-proxy:
image: webconbps/aiproxy:1.0.0.235
container_name: ai-proxy
restart: unless-stopped
ports:
- "5298:8080"
- "7033:8081"
environment:
- ASPNETCORE_ENVIRONMENT=Production
- AppConfiguration__SelfHosted__Certificate__Path=/app/https/certificate.pem
- Logging__LogLevel__Default=Information
- Logging__LogLevel__Microsoft=Warning
# LiteLLM connection configuration
- ProviderConnections__LiteLlm__ProviderConfiguration__Endpoint=http://litellm:4000
- ProviderConnections__LiteLlm__ProviderConfiguration__ApiKey=sk-your-litellm-virtual-key
volumes:
- ./certificates/certificate.pem:/app/https/certificate.pem:ro
- ./aiconfiguration.json:/app/aiconfiguration.json:ro
Overriding values with environment variables
Environment variables in the ProviderConnections__LiteLlm__ProviderConfiguration__Endpoint format are loaded by ASP.NET Core after JSON files and override their values. This allows you to keep the configuration structure in aiconfiguration.json while providing secrets and URLs exclusively through docker-compose.yml — without storing them in files.
Step 4: Startup
# Make sure you have prepared the following files:
# - ./certificates/certificate.pem
# - ./aiconfiguration.json (with ProviderConnections and ProviderModels filled in)
# Start the container
docker-compose up -d
# Check logs
docker-compose logs -f ai-proxy
Troubleshooting
Error: 401 Unauthorized
Possible causes:
- the LiteLLM virtual key is invalid or has expired,
- the OIDC token was not retrieved correctly (Variant C).
Solution:
# Variant A/B: verify the virtual key is correct
# Variant C: test the OIDC token manually:
# curl -X POST <TokenEndpoint> \
# -d "grant_type=client_credentials" \
# -d "client_id=<ClientId>" \
# -d "client_secret=<ClientSecret>"
# Restart the container
docker-compose restart ai-proxy
Error: 404 Not Found / Model not found
Possible causes:
- the model name in
ModelNamedoes not exist in the LiteLLM configuration, - the LiteLLM instance is not reachable at the configured address.
Solution:
# Check available models in LiteLLM:
# curl http://<litellm-host>:4000/models \
# -H "Authorization: Bearer <virtual-key>"
# Verify that Endpoint points to a running server
# Update ModelName in aiconfiguration.json
docker-compose restart ai-proxy
Error: 429 Too Many Requests
Possible cause:
- the LiteLLM virtual key has a budget or TPM limit that has been exceeded.
Solution:
- check the limits assigned to the key in the LiteLLM dashboard (
/key/info), - consider increasing the budget or generating a new key with a higher limit.
OIDC server connection error (Variant C)
Possible causes:
- the
TokenEndpointaddress is incorrect, - the AI Proxy container does not have network access to the OIDC server.
Solution:
# Check if the token endpoint is reachable from the container:
# docker exec ai-proxy curl -s <TokenEndpoint>
# Verify Docker network configuration
docker-compose logs -f ai-proxy