Skip to content

feat: add Anthropic Messages to OpenAI ChatCompletions translator - #464

Open
khshanovskyi wants to merge 5 commits into
developmentfrom
feat/add-openai-responses-transaltor
Open

feat: add Anthropic Messages to OpenAI ChatCompletions translator#464
khshanovskyi wants to merge 5 commits into
developmentfrom
feat/add-openai-responses-transaltor

Conversation

@khshanovskyi

@khshanovskyi khshanovskyi commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Applicable issues

  • fixes #

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.

@khshanovskyi
khshanovskyi requested a review from adubovik as a code owner July 14, 2026 08:59
@khshanovskyi
khshanovskyi force-pushed the feat/add-openai-responses-transaltor branch from f5d9eab to d733893 Compare July 14, 2026 09:02
@khshanovskyi khshanovskyi changed the title feat: add Anthropic Messages to OpenAI Responses translator feat: add Anthropic Messages to OpenAI ChatCompletions translator Jul 23, 2026
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
khshanovskyi force-pushed the feat/add-openai-responses-transaltor branch from 3f57ac5 to 5dcc092 Compare July 23, 2026 10:38
khshanovskyi and others added 4 commits July 23, 2026 16:49
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>
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.

1 participant