-
-
Notifications
You must be signed in to change notification settings - Fork 61
Anthropic endpoint for claude code #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Mirrowel
merged 40 commits into
Mirrowel:dev
from
FammasMaz:feature/anthropic-endpoints
Jan 15, 2026
Merged
Changes from 30 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
b4df352
feat(proxy): add Anthropic Messages API endpoint for Claude Code comp…
FammasMaz 7e229f4
feat(anthropic): add extended thinking support to /v1/messages endpoint
FammasMaz 7aea08e
feat(anthropic): force high thinking budget for Opus models by default
FammasMaz 05d89a2
fix: ensure max_tokens exceeds thinking budget and improve error hand…
FammasMaz e35f3f0
fix(anthropic): properly close all content blocks in streaming wrapper
FammasMaz 4ec92ec
fix(anthropic): add missing uuid import for /v1/messages endpoint
FammasMaz b70efdf
fix(anthropic): always set custom_reasoning_budget when thinking is e…
FammasMaz 4bd879b
feat(openai): auto-enable full thinking budget for Opus
FammasMaz 758b4b5
fix(anthropic): add missing JSONResponse import for non-streaming res…
FammasMaz f2d7288
fix(anthropic): ensure message_start is sent before message_stop in s…
FammasMaz de88557
feat: add /context endpoint for anthropic routes
FammasMaz beed0bc
Revert "feat(openai): auto-enable full thinking budget for Opus"
FammasMaz 2c93a68
Revert "fix(anthropic): always set custom_reasoning_budget when think…
FammasMaz b19526c
refactor: Move Anthropic translation layer to rotator_library
FammasMaz d91f98b
fix(anthropic): improve model detection and document thinking budget
FammasMaz 16c889f
fix(anthropic): handle images in tool results for Claude Code
FammasMaz 545d0d5
fix(anthropic): force Claude thinking budget and interleaved hint
FammasMaz 765df7a
fix(anthropic): read thinking budget from client request
FammasMaz 5af1f10
fix(anthropic): handle thinking toggle for text-only assistant messages
FammasMaz 0bb8a52
fix(anthropic): strengthen interleaved thinking hint
FammasMaz 991a8e3
fix(antigravity): remove unreachable is_claude condition in thinking …
FammasMaz 354ac17
fix(antigravity): add debug logging for non-data URL images
FammasMaz b81ca57
fix(anthropic): correct cache token handling in usage responses
FammasMaz 97ef2d1
feat(anthropic): add 5 translation improvements from reference
FammasMaz dc19691
fix(antigravity): make interleaved thinking hint more explicit
FammasMaz 5a8258c
fix(antigravity): reject requests exceeding Claude's 64K max_tokens l…
FammasMaz bbc1060
experimental: try to be more explicit about must think instruction
FammasMaz 3fc1436
Merge origin/dev into feature/anthropic-endpoints
FammasMaz d4ad8af
feat(anthropic): respect explicit thinking_budget from Anthropic routes
FammasMaz 9d568fe
feat(anthropic): always use max thinking budget (31999) for Claude
FammasMaz 67ffea5
fix(anthropic): inject [Continue] for fresh thinking turn when histor…
FammasMaz b7b5d07
fix(token-count): include Antigravity preprompt tokens in count
FammasMaz 4aa703f
Merge remote-tracking branch 'origin/dev' into feature/anthropic-endp…
FammasMaz 9d4799e
Merge origin/dev into feature/anthropic-endpoints
FammasMaz 49d2e47
fix(antigravity): remove stale interleaved thinking references
FammasMaz aa88eb3
Merge origin/dev into feature/anthropic-endpoints
Mirrowel 8e10a66
refactor(rotator_library): 🔨 standardize thinking budget mapping and …
Mirrowel d9f2ddb
feat(logging): ✨ implement nested transaction logging for anthropic c…
Mirrowel 6d9f9cc
fix(anthropic-compat): 🐛 handle null tool_calls in streaming delta
Mirrowel 1798e75
docs: 📚 document anthropic api compatibility layer and client usage
Mirrowel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| """ | ||
| Anthropic API compatibility module for rotator_library. | ||
|
|
||
| This module provides format translation between Anthropic's Messages API | ||
| and OpenAI's Chat Completions API, enabling any OpenAI-compatible provider | ||
| to work with Anthropic clients like Claude Code. | ||
|
|
||
| Usage: | ||
| from rotator_library.anthropic_compat import ( | ||
| AnthropicMessagesRequest, | ||
| AnthropicMessagesResponse, | ||
| translate_anthropic_request, | ||
| openai_to_anthropic_response, | ||
| anthropic_streaming_wrapper, | ||
| ) | ||
| """ | ||
|
|
||
| from .models import ( | ||
| AnthropicTextBlock, | ||
| AnthropicImageSource, | ||
| AnthropicImageBlock, | ||
| AnthropicToolUseBlock, | ||
| AnthropicToolResultBlock, | ||
| AnthropicMessage, | ||
| AnthropicTool, | ||
| AnthropicThinkingConfig, | ||
| AnthropicMessagesRequest, | ||
| AnthropicUsage, | ||
| AnthropicMessagesResponse, | ||
| AnthropicCountTokensRequest, | ||
| AnthropicCountTokensResponse, | ||
| ) | ||
|
|
||
| from .translator import ( | ||
| anthropic_to_openai_messages, | ||
| anthropic_to_openai_tools, | ||
| anthropic_to_openai_tool_choice, | ||
| openai_to_anthropic_response, | ||
| translate_anthropic_request, | ||
| ) | ||
|
|
||
| from .streaming import anthropic_streaming_wrapper | ||
|
|
||
| __all__ = [ | ||
| # Models | ||
| "AnthropicTextBlock", | ||
| "AnthropicImageSource", | ||
| "AnthropicImageBlock", | ||
| "AnthropicToolUseBlock", | ||
| "AnthropicToolResultBlock", | ||
| "AnthropicMessage", | ||
| "AnthropicTool", | ||
| "AnthropicThinkingConfig", | ||
| "AnthropicMessagesRequest", | ||
| "AnthropicUsage", | ||
| "AnthropicMessagesResponse", | ||
| "AnthropicCountTokensRequest", | ||
| "AnthropicCountTokensResponse", | ||
| # Translator functions | ||
| "anthropic_to_openai_messages", | ||
| "anthropic_to_openai_tools", | ||
| "anthropic_to_openai_tool_choice", | ||
| "openai_to_anthropic_response", | ||
| "translate_anthropic_request", | ||
| # Streaming | ||
| "anthropic_streaming_wrapper", | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When PROXY_API_KEY is not set or empty (open access mode), this function will always raise an HTTPException because neither condition will match. This is inconsistent with verify_api_key at line 794 which allows access when PROXY_API_KEY is not set. Consider adding a check similar to line 794 to allow open access mode.