Developing

OpenAI Chat Completions to Anthropic Messages compatibility

Read the release-matched openai anthropic compatibility documentation and its scope.

Praxis AI v0.10.0 (alpha) 4 min read

Switching projects opens that project’s default documentation release.

Versions marked “overview” do not contain this page. Selecting one opens that version’s documentation overview.

On this page

This note defines the compatibility behavior of the OpenAI Chat Completions request translator for Anthropic Messages. It does not make unsupported fields generally permissive: the translator continues to reject fields and content shapes outside the explicit contract below.

Request contract

OpenAI Chat Completions inputAnthropic Messages outputBehavior
modelselected Anthropic modelThe client model is retained for the Chat Completions response; the configured target model is sent to Anthropic.
max_completion_tokensmax_tokensTakes precedence when present and must be a positive integer.
max_tokensmax_tokensUsed when max_completion_tokens is absent; must be a positive integer.
Neither token fieldmax_tokens: 4096Uses this translator’s compatibility default.
Both token fieldsmax_tokensmax_completion_tokens wins, including when the values differ. This precedence is explicit and covered by tests.
useromittedAccepted only as a string, then discarded. User identity is not forwarded.
nomittedAccepted only as a positive integer, then discarded. This does not request multiple completions.
seedomittedAccepted only as an integer, then discarded. This does not make generation deterministic.
parallel_tool_callsomittedAccepted only as a boolean, then discarded. It does not constrain provider tool scheduling.
Text contentAnthropic text blockPreserved in order.
Base64 image_url data URLAnthropic base64 image sourceJPEG, PNG, GIF, and WebP are accepted when the base64 payload is non-empty, decodable, and has a matching format signature.
HTTPS image_urlAnthropic URL image sourceThe URL is passed through; the translator does not fetch it.

Image conversion is supported in user messages only. Assistant image blocks are rejected rather than silently dropped or moved to another role. System, developer, and tool-result content remains text-only in this translator.

image_url.detail accepts auto, low, or high and is discarded because Anthropic Messages has no equivalent quality control. Unknown top-level or nested fields, malformed values, unsupported content block types, non-HTTPS remote image URLs, embedded URL credentials, and malformed or unsupported data URLs remain rejected with HTTP 400. The translator does not accept arbitrary OpenAI options and silently drop them.

Tool declarations, tool choices, assistant tool calls, and tool results retain their existing validation and conversion behavior. The compatibility options above do not alter response conversion or the incremental SSE translator.

Body limits

Request and response buffering limits are independent:

SettingDefaultMaximumPurpose
max_request_body_bytes2 MiB16 MiBComplete Chat Completions request needed for validation and translation.
max_response_body_bytes1 MiB16 MiBNon-streaming Anthropic JSON response retained for conversion.

These are filter limits, not overrides of the listener’s body ceilings. Praxis listeners default to 10 MiB for both body_limits.max_request_bytes and body_limits.max_response_bytes. To use a filter limit above 10 MiB, also raise the corresponding listener ceiling to accommodate it. A lower listener ceiling still takes precedence.

For existing configurations, max_body_bytes remains supported as a shared limit. A direction-specific setting takes precedence over the shared setting for that direction. If neither direction-specific nor shared value is set, the defaults in the table apply. Zero and values above the maximum are rejected during configuration validation. Streaming responses continue to use their independent event-size controls.

The request limit is checked before provider-format branching. Consequently, an OpenAI-compatible candidate using this request filter has the same request cap even though its body is passed through after the selected target model is rewritten. The response limit applies only to buffered Anthropic JSON response conversion; it does not change SSE processing.

Validation

Run the focused converter tests with:

cargo test -p praxis-ai-apis anthropic::openai_chat_completions_to_anthropic

The tests cover token defaults and precedence, ignored compatibility fields, strict rejection of invalid inputs, image source conversion and ordering, selected target model identity, and independent request/response limits.