feat: add Anthropic Messages to OpenAI ChatCompletions translator - #464
Open
khshanovskyi wants to merge 5 commits into
Open
feat: add Anthropic Messages to OpenAI ChatCompletions translator#464khshanovskyi wants to merge 5 commits into
khshanovskyi wants to merge 5 commits into
Conversation
khshanovskyi
force-pushed
the
feat/add-openai-responses-transaltor
branch
from
July 14, 2026 09:02
f5d9eab to
d733893
Compare
Add a FastAPI sub-app (aidial_adapter_bedrock/anthropic_translator/chat_completions/)
mounted at /to-chat-completions/anthropic, translating Anthropic Messages
requests (/v1/messages) into OpenAI Chat Completions API calls against
DIAL Core ({DIAL_URL}/openai/deployments/{deployment}/chat/completions)
and translating the streaming/non-streaming responses back into Anthropic
Messages shape. This lets an Anthropic-native client (e.g. Claude Code)
talk to a model that only speaks the OpenAI Chat Completions API.
- Support the bulk of the Anthropic Messages surface: system prompt
(string/blocks, including mid-conversation system-role turns merged
into one leading system message), user/assistant messages, tool_result/
tool_use, image/document blocks, tool_choice, reasoning-effort mapping
from output_config.effort, and cache_control propagated as DIAL Core's
custom_fields.cache_breakpoint. Unsupported features (top_k, thinking
budget, web_search/bash/text_editor/computer/code_execution tools,
mcp_servers, container) are dropped with a warning instead of being
rejected, so clients keep working. There is no count_tokens endpoint,
since Chat Completions has no token-counting API.
- Map DIAL Core and Chat Completions errors into Anthropic-shaped error
responses, for both the HTTP error body and the terminal SSE error
event.
- Promote openai from a test-only to a runtime dependency (1.107.3 ->
2.40.0) to reuse its typed Chat Completions client and SSE handling
for the outbound call to Core.
- Document the new interfaces.anthropicMessages DIAL Core config
pattern and the translator's feature-support/limitations table in
README.md.
- Add unit tests covering request/response conversion, the streaming
state machine, error mapping, and the mounted endpoints.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
khshanovskyi
force-pushed
the
feat/add-openai-responses-transaltor
branch
from
July 23, 2026 10:38
3f57ac5 to
5dcc092
Compare
Translate Anthropic's output_config.format (json_schema) to DIAL's response_format on the Chat Completions request; unsupported format types or a missing schema are dropped with a warning, consistent with the translator's other defensive-conversion behavior. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
# Conflicts: # poetry.lock
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Applicable issues
Description of changes
Add a FastAPI sub-app (aidial_adapter_bedrock/anthropic_translator/chat_completions/)
mounted at /to-chat-completions/anthropic, translating Anthropic Messages
requests (/v1/messages) into OpenAI Chat Completions API calls against
DIAL Core ({DIAL_URL}/openai/deployments/{deployment}/chat/completions)
and translating the streaming/non-streaming responses back into Anthropic
Messages shape. This lets an Anthropic-native client (e.g. Claude Code)
talk to a model that only speaks the OpenAI Chat Completions API.
Support the bulk of the Anthropic Messages surface: system prompt
(string/blocks, including mid-conversation system-role turns merged
into one leading system message), user/assistant messages, tool_result/
tool_use, image/document blocks, tool_choice, reasoning-effort mapping
from output_config.effort, and cache_control propagated as DIAL Core's
custom_fields.cache_breakpoint. Unsupported features (top_k, thinking
budget, web_search/bash/text_editor/computer/code_execution tools,
mcp_servers, container) are dropped with a warning instead of being
rejected, so clients keep working. There is no count_tokens endpoint,
since Chat Completions has no token-counting API.
Map DIAL Core and Chat Completions errors into Anthropic-shaped error
responses, for both the HTTP error body and the terminal SSE error
event.
Promote openai from a test-only to a runtime dependency (1.107.3 ->
2.40.0) to reuse its typed Chat Completions client and SSE handling
for the outbound call to Core.
Document the new interfaces.anthropicMessages DIAL Core config
pattern and the translator's feature-support/limitations table in
README.md.
Add unit tests covering request/response conversion, the streaming
state machine, error mapping, and the mounted endpoints.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.