-
Notifications
You must be signed in to change notification settings - Fork 34
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
Open
FammasMaz
wants to merge
16
commits into
Mirrowel:dev
Choose a base branch
from
FammasMaz:feature/anthropic-endpoints
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,388
−5
Open
Changes from all commits
Commits
Show all changes
16 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 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.