> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opper.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# LiteLLM

> Use Opper as the upstream router for a self-hosted LiteLLM gateway

[LiteLLM](https://docs.litellm.ai) is a self-hosted LLM gateway. Point it at Opper as its upstream router and every team behind your LiteLLM proxy gets the full Opper catalog through one Opper API key, with Opper handling provider routing, failover, and EU compliance.

## Setup

Opper's model IDs use the same `provider/model` convention as OpenRouter, so LiteLLM's OpenRouter-compatible provider works today:

```yaml theme={null}
model_list:
  - model_name: claude-haiku
    litellm_params:
      model: openrouter/anthropic/claude-haiku-4-5
      api_base: https://api.opper.ai/v3/compat
      api_key: os.environ/OPPER_API_KEY
```

<Note>
  A first-class `opper/` provider for LiteLLM is [in review upstream](https://github.com/BerriAI/litellm/pull/36075). Once merged, the config becomes `model: opper/anthropic/claude-haiku-4-5` with no `api_base` override, and cost tracking works on every dispatch path including streaming.
</Note>

## Cost tracking

Every Opper response includes `usage.cost` (USD). LiteLLM's OpenRouter path reads it into its spend tracking, so LiteLLM spend logs show Opper's actual billed cost instead of estimates from a static price map.

## Model discovery

`GET https://api.opper.ai/v3/compat/models` returns the models your key can use — filtered by your organization's compliance rules, with per-token pricing and per-model compliance metadata (region, ZDR status, GDPR residency). Sync your `model_list` from it, or filter it first, for example to EU-resident, zero-data-retention models only.

## Per-tenant usage attribution

Forward up to 8 tags per request with the `X-Opper-Tags` header, then group usage and cost by tag in Opper analytics:

```yaml theme={null}
model_list:
  - model_name: claude-haiku
    litellm_params:
      model: openrouter/anthropic/claude-haiku-4-5
      api_base: https://api.opper.ai/v3/compat
      api_key: os.environ/OPPER_API_KEY
      extra_headers: {"X-Opper-Tags": "tenant:acme,env:prod"}
```

```bash theme={null}
curl -s "https://api.opper.ai/v2/analytics/usage?group_by=tenant&fields=total_tokens" \
  -H "Authorization: Bearer $OPPER_API_KEY"
```

Tag limits, the other ways to attach tags, and more ways to slice usage are covered in [Tags and usage attribution](/build/gateway/usage-attribution).

## Related

<CardGroup cols={2}>
  <Card title="Tags and usage attribution" icon="tag" href="/build/gateway/usage-attribution">
    Group spend by tenant, environment, or app.
  </Card>

  <Card title="Model catalog" icon="list" href="/capabilities/models">
    IDs, pricing, and compliance metadata.
  </Card>
</CardGroup>
