mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-08 22:21:35 +00:00
v1 guide
This commit is contained in:
parent
9e3e6f3528
commit
244720d8a3
1 changed files with 69 additions and 0 deletions
|
|
@ -0,0 +1,69 @@
|
|||
# Claude Code - Track Customer Usage
|
||||
|
||||
Track usage per customer when using Claude Code with LiteLLM proxy. This enables per-customer cost tracking and budget management for Claude Code users.
|
||||
|
||||
## How It Works
|
||||
|
||||
LiteLLM supports standard customer ID headers that work out-of-the-box with Claude Code's custom headers feature. Set `ANTHROPIC_CUSTOM_HEADERS` to pass a customer ID with every request.
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable | Description | Example |
|
||||
|----------|-------------|---------|
|
||||
| `ANTHROPIC_BASE_URL` | LiteLLM proxy URL | `http://localhost:4000` |
|
||||
| `ANTHROPIC_API_KEY` | LiteLLM API key (master key or virtual key) | `sk-1234` |
|
||||
| `ANTHROPIC_CUSTOM_HEADERS` | Custom headers in `header-name: value` format | `x-litellm-customer-id: my-customer` |
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Set Environment Variables
|
||||
|
||||
```bash
|
||||
export ANTHROPIC_BASE_URL=http://localhost:4000
|
||||
export ANTHROPIC_API_KEY=sk-1234
|
||||
export ANTHROPIC_CUSTOM_HEADERS="x-litellm-customer-id: claude-ishaan-local"
|
||||
```
|
||||
|
||||
The `ANTHROPIC_CUSTOM_HEADERS` format is `header-name: value`. LiteLLM automatically tracks requests with `x-litellm-customer-id` or `x-litellm-end-user-id` headers.
|
||||
|
||||
### 2. Use Claude Code
|
||||
|
||||
```bash
|
||||
claude
|
||||
```
|
||||
|
||||
All requests will now be tracked under the customer ID `claude-ishaan-local`.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### 3. View Customer Usage
|
||||
|
||||
Navigate to the **Logs** tab in the LiteLLM UI.
|
||||
|
||||

|
||||
|
||||
Click on a request to see details.
|
||||
|
||||

|
||||
|
||||
Filter by customer ID to see all requests for that customer.
|
||||
|
||||

|
||||
|
||||
## Supported Headers
|
||||
|
||||
LiteLLM checks these headers automatically (no configuration required):
|
||||
|
||||
- `x-litellm-customer-id`
|
||||
- `x-litellm-end-user-id`
|
||||
|
||||
## Related
|
||||
|
||||
- [Claude Code Quickstart](./claude_responses_api.md)
|
||||
- [Customer Budgets](../proxy/customers.md)
|
||||
- [Track Usage for Coding Tools](./cost_tracking_coding.md)
|
||||
|
||||
Loading…
Add table
Reference in a new issue