Skip to content

[Feat] Add Support for Claude Code Max/OAuth 2 on LiteLLM AI Gateway #19453

Merged
ishaan-jaff merged 14 commits intomainfrom
litellm_claude_code_max
Jan 21, 2026
Merged

[Feat] Add Support for Claude Code Max/OAuth 2 on LiteLLM AI Gateway #19453
ishaan-jaff merged 14 commits intomainfrom
litellm_claude_code_max

Conversation

@ishaan-jaff
Copy link
Copy Markdown
Contributor

@ishaan-jaff ishaan-jaff commented Jan 21, 2026

[Feat] Add Support for Claude Code Max/OAuth 2 on LiteLLM AI Gateway

  • If developers have Claude Code Max accounts, they need to sign in to claude code max and use claude code max to LiteLLM
  • In this scenario their requests go from Claude Code (Using Oauth Tokens) -> LiteLLM -> Anthropic API

Enables developers using Claude Code Max to authenticate with LiteLLM proxy by supporting OAuth tokens (sk-ant-oat01-*) alongside regular LiteLLM API keys.

What Changed

Authentication Flow:

  • OAuth Token Detection: Detects Claude Code Max OAuth tokens (sk-ant-oat01-* prefix) in Authorization header
  • Dual Authentication: Uses x-litellm-api-key header for LiteLLM proxy auth, forwards OAuth token to Anthropic API
  • Header Forwarding: Automatically adds required OAuth headers (anthropic-beta, anthropic-dangerous-direct-browser-access)

Fixes: #13380

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

🆕 New Feature
✅ Test

Changes

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
litellm Ready Ready Preview, Comment Jan 21, 2026 1:22am

Request Review

@ishaan-jaff ishaan-jaff merged commit ddebdd4 into main Jan 21, 2026
5 of 9 checks passed
rcII added a commit to jamraca/litellm that referenced this pull request Feb 8, 2026
…ssthrough

When OAuth tokens (sk-ant-oat*) are forwarded through the proxy,
Anthropic requires the 'anthropic-dangerous-direct-browser-access: true'
header to accept them from non-Claude-Code clients. Without this,
Anthropic rejects with "credential only authorized for Claude Code".

This mirrors upstream PR BerriAI#19453's optionally_handle_anthropic_oauth()
but keeps the token as Authorization: Bearer (no x-api-key conversion).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support for pass-through OAuth for Anthropic

1 participant