Skip to content

Add Claude Opus 4.5 and Claude 4 model family to context limits #1

Description

@purposebuiltscott

Problem

The proxy server fails to optimize requests for newer Claude models, logging warnings like:

WARNING - Optimization failed: Unknown Anthropic model: claude-opus-4-5-20251101. Configure context_limits explicitly.

Missing Models

  • claude-opus-4-5-20251101 (Claude Opus 4.5)
  • claude-haiku-4-5-20251001 (Claude Haiku 4)

Impact

When an unknown model is used, optimization is skipped entirely for that request, defeating the purpose of the proxy.

Suggested Fix

Add the new models to both dictionaries in headroom/providers/anthropic.py:

ANTHROPIC_CONTEXT_LIMITS: dict[str, int] = {
    # ... existing models ...
    "claude-opus-4-5-20251101": 200000,
    "claude-sonnet-4-20250514": 200000,
}

ANTHROPIC_PRICING: dict[str, dict[str, float]] = {
    # ... existing models ...
    "claude-opus-4-5-20251101": {"input": 15.00, "output": 75.00, "cached_input": 1.50},
    "claude-sonnet-4-20250514": {"input": 3.00, "output": 15.00, "cached_input": 0.30},
}


Maybe add a mechanism to specify custom model limits without code changes (config file, environment variable, or API endpoint to fetch current models)?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions