Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
186fd2e
Add adaptive thinking support for anthropic opus 4.6
Sameerlite Feb 6, 2026
f15dd69
Fix anthropic.claude-opus-4-6-v1 for bedrock
Sameerlite Feb 6, 2026
1bcd407
Add adaptive thiking for bedrock converse
Sameerlite Feb 6, 2026
039b37f
Add compaction type block in the output
Sameerlite Feb 6, 2026
c03ba83
Add compaction block in provider spcific fields streaming+ non streaming
Sameerlite Feb 6, 2026
24dda99
Handle compaction block in the input request
Sameerlite Feb 6, 2026
887a977
Add doc on how to enable compaction via chat completion
Sameerlite Feb 6, 2026
ea518a7
Apply suggestion from @greptile-apps[bot]
Sameerlite Feb 6, 2026
7a473f2
Apply suggestion from @greptile-apps[bot]
Sameerlite Feb 6, 2026
d0444f4
Add test for compaction in anthropic
Sameerlite Feb 6, 2026
1396813
The compact beta feature is not currently supported on the Converse a…
Sameerlite Feb 6, 2026
358a081
Add compaction support for vertex ai
Sameerlite Feb 6, 2026
0934a4a
Correct litellm/litellm/llms/anthropic/chat/transformation.py
Sameerlite Feb 6, 2026
1ec89b8
Feat: add inference_geo based pricing
Sameerlite Feb 6, 2026
a2b29d6
Add complete documentation for claude_opus_4_6
Sameerlite Feb 6, 2026
bfd21b5
Merge branch 'main' into litellm_opus_4.6_thinking
Sameerlite Feb 6, 2026
920fea9
feat: Add Unsupported Anthropic beta headers for each provider json
Sameerlite Feb 6, 2026
25a19b2
Add update_headers_with_filtered_beta in anthropic
Sameerlite Feb 6, 2026
3f9a7b1
Add update_headers_with_filtered_beta in all messages API providers
Sameerlite Feb 6, 2026
c1a4391
Add documentation related to new beta header json
Sameerlite Feb 6, 2026
786bd6e
Fix merge conflicts
Sameerlite Feb 6, 2026
40ff796
Add not_available in inference_geo
Sameerlite Feb 6, 2026
fa26c6e
fix mypy issue
Sameerlite Feb 6, 2026
05ce4c6
Fix: test_vertex_ai_partner_models_anthropic_remove_prompt_caching_sc…
Sameerlite Feb 6, 2026
2e0715b
Fix mypy issue
Sameerlite Feb 6, 2026
db8423b
Fix: test_json_response_nested_json_schema
Sameerlite Feb 6, 2026
285b2d2
add context_management header for compact_20260112 for messages
Sameerlite Feb 6, 2026
eab7a99
Merge pull request #20578 from BerriAI/litellm_claude_code_beta_headers
Sameerlite Feb 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 156 additions & 2 deletions docs/my-website/blog/claude_opus_4_6/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ slug: claude_opus_4_6
title: "Day 0 Support: Claude Opus 4.6"
date: 2026-02-05T10:00:00
authors:
- name: Sameer Kankute
title: SWE @ LiteLLM (LLM Translation)
url: https://www.linkedin.com/in/sameer-kankute/
image_url: https://pbs.twimg.com/profile_images/2001352686994907136/ONgNuSk5_400x400.jpg
- name: Ishaan Jaff
title: "CTO, LiteLLM"
url: https://www.linkedin.com/in/reffajnaahsi/
Expand Down Expand Up @@ -219,6 +223,156 @@ curl --location 'http://0.0.0.0:4000/chat/completions' \
</TabItem>
</Tabs>

## More Features Coming Soon
## Compaction

Litellm supports enabling compaction for the new claude-opus-4-6.

### Enabling Compaction

To enable compaction, add the `context_management` parameter with the `compact_20260112` edit type:

```bash
curl --location 'http://0.0.0.0:4000/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $LITELLM_KEY' \
--data '{
"model": "claude-opus-4-6",
"messages": [
{
"role": "user",
"content": "What is the weather in San Francisco?"
}
],
"context_management": {
"edits": [
{
"type": "compact_20260112"
}
]
},
"max_tokens": 100
}'
```
All the parameters supported for context_management by anthropic are supported and can be directly added. Litellm automatically adds the `compact-2026-01-12` beta header in the request.


### Response with Compaction Block

The response will include the compaction summary in `provider_specific_fields.compaction_blocks`:

```json
{
"id": "chatcmpl-a6c105a3-4b25-419e-9551-c800633b6cb2",
"created": 1770357619,
"model": "claude-opus-4-6",
"object": "chat.completion",
"choices": [
{
"finish_reason": "length",
"index": 0,
"message": {
"content": "I don't have access to real-time data, so I can't provide the current weather in San Francisco. To get up-to-date weather information, I'd recommend checking:\n\n- **Weather websites** like weather.com, accuweather.com, or wunderground.com\n- **Search engines** – just Google \"San Francisco weather\"\n- **Weather apps** on your phone (e.g., Apple Weather, Google Weather)\n- **National",
"role": "assistant",
"provider_specific_fields": {
"compaction_blocks": [
{
"type": "compaction",
"content": "Summary of the conversation: The user requested help building a web scraper..."
}
]
}
}
}
],
"usage": {
"completion_tokens": 100,
"prompt_tokens": 86,
"total_tokens": 186
}
}
```

### Using Compaction Blocks in Follow-up Requests

To continue the conversation with compaction, include the compaction block in the assistant message's `provider_specific_fields`:

```bash
curl --location 'http://0.0.0.0:4000/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $LITELLM_KEY' \
--data '{
"model": "claude-opus-4-6",
"messages": [
{
"role": "user",
"content": "How can I build a web scraper?"
},
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "Certainly! To build a basic web scraper, you'll typically use a programming language like Python along with libraries such as `requests` (for fetching web pages) and `BeautifulSoup` (for parsing HTML). Here's a basic example:\n\n```python\nimport requests\nfrom bs4 import BeautifulSoup\n\nurl = 'https://example.com'\nresponse = requests.get(url)\nsoup = BeautifulSoup(response.text, 'html.parser')\n\n# Extract and print all text\ntext = soup.get_text()\nprint(text)\n```\n\nLet me know what you're interested in scraping or if you need help with a specific website!"
}
],
"provider_specific_fields": {
"compaction_blocks": [
{
"type": "compaction",
"content": "Summary of the conversation: The user asked how to build a web scraper, and the assistant gave an overview using Python with requests and BeautifulSoup."
}
]
}
},
{
"role": "user",
"content": "How do I use it to scrape product prices?"
}
],
"context_management": {
"edits": [
{
"type": "compact_20260112"
}
]
},
"max_tokens": 100
}'
```

### Streaming Support

Compaction blocks are also supported in streaming mode. You'll receive:
- `compaction_start` event when a compaction block begins
- `compaction_delta` events with the compaction content
- The accumulated `compaction_blocks` in `provider_specific_fields`


## Effort Levels

Four effort levels available: `low`, `medium`, `high` (default), and `max`. Pass directly via the `effort` parameter:

```bash
curl --location 'http://0.0.0.0:4000/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $LITELLM_KEY' \
--data '{
"model": "claude-opus-4-6",
"messages": [
{
"role": "user",
"content": "Explain quantum computing"
}
],
"effort": "max"
}'
```

## 1M Token Context (Beta)

Opus 4.6 supports 1M token context. Premium pricing applies for prompts exceeding 200k tokens ($10/$37.50 per million input/output tokens). LiteLLM supports cost calculations for 1M token contexts.

## US-Only Inference

Available at 1.1× token pricing. LiteLLM supports this pricing model.

We're actively working on supporting new features for Claude Opus 4.6. Stay tuned for updates!
129 changes: 129 additions & 0 deletions docs/my-website/docs/tutorials/claude_code_beta_headers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import Image from '@theme/IdealImage';

# Claude Code - Fixing Invalid Beta Header Errors

When using Claude Code with LiteLLM and non-Anthropic providers (Bedrock, Azure AI, Vertex AI), you may encounter "invalid beta header" errors. This guide explains how to fix these errors locally or contribute a fix to LiteLLM.

## What Are Beta Headers?

Anthropic uses beta headers to enable experimental features in Claude. When you use Claude Code, it may send beta headers like:

```
anthropic-beta: prompt-caching-scope-2026-01-05,advanced-tool-use-2025-11-20
```

However, not all providers support all Anthropic beta features. When an unsupported beta header is sent to a provider, you'll see an error.

## Common Error Message

```bash
Error: The model returned the following errors: invalid beta flag
```

## How LiteLLM Handles Beta Headers

LiteLLM automatically filters out unsupported beta headers using a configuration file:

```
litellm/litellm/anthropic_beta_headers_config.json
```

This JSON file lists which beta headers are **unsupported** for each provider. Headers not in the unsupported list are passed through to the provider.

## Quick Fix: Update Config Locally

If you encounter an invalid beta header error, you can fix it immediately by updating the config file locally.

### Step 1: Locate the Config File

Find the file in your LiteLLM installation:

```bash
# If installed via pip
cd $(python -c "import litellm; import os; print(os.path.dirname(litellm.__file__))")

# The config file is at:
# litellm/anthropic_beta_headers_config.json
```

### Step 2: Add the Unsupported Header

Open `anthropic_beta_headers_config.json` and add the problematic header to the appropriate provider's list:

```json title="anthropic_beta_headers_config.json"
{
"description": "Unsupported Anthropic beta headers for each provider. Headers listed here will be dropped. Headers not listed are passed through as-is.",
"anthropic": [],
"azure_ai": [],
"bedrock_converse": [
"prompt-caching-scope-2026-01-05",
"bash_20250124",
"bash_20241022",
"text_editor_20250124",
"text_editor_20241022",
"compact-2026-01-12",
"advanced-tool-use-2025-11-20",
"web-fetch-2025-09-10",
"code-execution-2025-08-25",
"skills-2025-10-02",
"files-api-2025-04-14"
],
"bedrock": [
"advanced-tool-use-2025-11-20",
"prompt-caching-scope-2026-01-05",
"structured-outputs-2025-11-13",
"web-fetch-2025-09-10",
"code-execution-2025-08-25",
"skills-2025-10-02",
"files-api-2025-04-14"
],
"vertex_ai": [
"prompt-caching-scope-2026-01-05"
]
}
```

### Step 3: Restart Your Application

After updating the config file, restart your LiteLLM proxy or application:

```bash
# If using LiteLLM proxy
litellm --config config.yaml

# If using Python SDK
# Just restart your Python application
```

The updated configuration will be loaded automatically.

## Contributing a Fix to LiteLLM

Help the community by contributing your fix! If your local changes work, please raise a PR with the addition of the header and we will merge it.


## How Beta Header Filtering Works

When you make a request through LiteLLM:

```mermaid
sequenceDiagram
participant CC as Claude Code
participant LP as LiteLLM
participant Config as Beta Headers Config
participant Provider as Provider (Bedrock/Azure/etc)

CC->>LP: Request with beta headers
Note over CC,LP: anthropic-beta: header1,header2,header3

LP->>Config: Load unsupported headers for provider
Config-->>LP: Returns unsupported list

Note over LP: Filter headers:<br/>- Remove unsupported<br/>- Keep supported

LP->>Provider: Request with filtered headers
Note over LP,Provider: anthropic-beta: header2<br/>(header1, header3 removed)

Provider-->>LP: Success response
LP-->>CC: Response
```
1 change: 1 addition & 0 deletions docs/my-website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const sidebars = {
"tutorials/claude_mcp",
"tutorials/claude_non_anthropic_models",
"tutorials/claude_code_plugin_marketplace",
"tutorials/claude_code_beta_headers",
]
},
"tutorials/opencode_integration",
Expand Down
30 changes: 30 additions & 0 deletions litellm/anthropic_beta_headers_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"description": "Unsupported Anthropic beta headers for each provider. Headers listed here will be dropped. Headers not listed are passed through as-is.",
"anthropic": [],
"azure_ai": [],
"bedrock_converse": [
"prompt-caching-scope-2026-01-05",
"bash_20250124",
"bash_20241022",
"text_editor_20250124",
"text_editor_20241022",
"compact-2026-01-12",
"advanced-tool-use-2025-11-20",
"web-fetch-2025-09-10",
"code-execution-2025-08-25",
"skills-2025-10-02",
"files-api-2025-04-14"
],
"bedrock": [
"advanced-tool-use-2025-11-20",
"prompt-caching-scope-2026-01-05",
"structured-outputs-2025-11-13",
"web-fetch-2025-09-10",
"code-execution-2025-08-25",
"skills-2025-10-02",
"files-api-2025-04-14"
],
"vertex_ai": [
"prompt-caching-scope-2026-01-05"
]
}
Loading
Loading