Skip to content

OpenAI API vs Anthropic API: Comparison and llm-connector Compatibility Audit

1. API Comparison

1.1 Interface Design

DimensionOpenAI Chat CompletionsAnthropic Messages
Message modelmessages array with role/content per itemmessages array + separate system field
Rolesuser, assistant, system, tooluser, assistant (system in separate field)
Content formatcontent as string or content blocks arrayAlways content blocks array
Endpoint/v1/chat/completions/v1/messages
StyleMature, many parameters, broad compatibilityClean structure, XML support, consistent output

1.2 Authentication

DimensionOpenAIAnthropic
Primary authAuthorization: Bearer {api_key}x-api-key: {api_key}
Version headerNone requiredanthropic-version: 2023-06-01
Azure variantapi-key + api-versionBearer via Vertex/Bedrock proxy

1.3 Request/Response Format

FieldOpenAIAnthropic
Modelmodelmodel
Max tokensmax_tokens optionalmax_tokens required
Temperaturetemperaturetemperature
Outputchoices[] with messageSingle content[], no choices
Token statsusage.prompt_tokens / completion_tokensusage.input_tokens / output_tokens
Stop reasonfinish_reasonstop_reason

1.4 Error Codes

HTTPOpenAIAnthropic
400invalid_request_errorinvalid_request_error
401authentication_errorauthentication_error
403permission_errorpermission_error
429rate_limit_errorrate_limit_error
500+Server errorServer error
Specialcontext_length_exceeded (code)Detected via message content

1.5 Streaming

DimensionOpenAIAnthropic
ProtocolSSESSE
Eventsdata: lines, choices[0].deltamessage_start, content_block_delta, message_delta, message_stop
StructureIncremental deltaBlock-level delta + metadata
tool_callsIncremental accumulation by indexParse content_block_delta for tool_use

1.6 Function Calling

DimensionOpenAIAnthropic
Definitiontools[].function (name/description/parameters)tools[].input_schema (JSON Schema)
Callstool_calls[] with id/function/name/argumentstool_use blocks in content
Resultstool role + tool_call_idtool_result in user role
tool_choiceauto/none/required/functionNo direct equivalent, prompt-based control

1.7 Multimodal

DimensionOpenAIAnthropic
Image inputimage_url (URL or base64)image (base64, type: image/source)
Blockstext, image_urltext, image
FormatsURL and base64Primarily base64

1.8 Rate Limits

Both use RPM/TPM, per-model; OpenAI exposes x-ratelimit-* headers; both return 429 with Retry-After behavior.

1.9 Pricing

Both charge by token; input/output rates differ. llm-connector does not implement billing.

1.10 SDK Ecosystem

Both provide official Python and TypeScript SDKs. llm-connector offers a unified Rust layer.


2. Version Evolution (since 2022)

OpenAI

DateMilestone
2022Chat Completions release
2023Function calling, Vision, GPT-4 Turbo
2024o1 reasoning, structured outputs, reasoning_content
2025-03Responses API released, recommended for new projects
2025-05MCP, Code Interpreter, Image generation, Background mode
2026-08Assistants API planned sunset

Anthropic

DateMilestone
2023Messages API, anthropic-version: 2023-06-01
2024Tool use (function calling), extended thinking
2025Version updates, built-in tools
2026-02Built-in tools GA

3. llm-connector Compatibility Audit

3.1 OpenAI Coverage

Endpoint/FeatureSupportedNotes
POST /chat/completions
└ model, messages, temperature, max_tokens, top_p
└ frequency_penalty, presence_penalty
└ stream, tools, tool_choice, response_format
└ stop, logit_bias, user, seedNot mapped to OpenAIRequest
GET /models
Streamingdelta.content, tool_calls accumulation, reasoning_content

Unmapped (ChatRequest → OpenAIRequest): stop, logit_bias, user, seed

3.2 Anthropic Coverage

Endpoint/FeatureSupportedNotes
POST /v1/messages
└ model, max_tokens, messages, system, temperature, top_p, stream
└ tools, tool_choice, response_formatNot implemented
Streamingmessage_start, content_block_delta, message_delta
tool_use streamingTool results converted to user text, no real tool support
models listmodels_endpoint returns None

3.3 Gap Matrix and Priority

IDGapTypePriorityDescription
D1Anthropic toolsMissingP0No function calling
D2Anthropic tool streamingMissingP0tool_use not parsed
D3OpenAI stop/logit_bias/user/seedUnmappedP1Affects advanced usage
D4Anthropic models endpointMissingP1fetch_models unsupported
D5OpenAI logprobsUnmappedP2Low priority
D6response_format (Anthropic)MissingP2Limited structured output
D7Tool role → user textSemantic mismatchP1Tool results treated as plain user messages

4. Adaptation Plan

4.1 New Modules

  • OpenAI Responses Protocol: Add OpenAIResponsesProtocol for /v1/responses; see OpenAI Responses API Analysis
  • Optional: Anthropic tools adapter for input_schemafunction.parameters mapping

4.2 Refactoring

ModuleChanges
anthropic.rsAdd tools, tool_choice in build_request; tool_use in parse_response / parse_stream_response
openai.rsOptionally add stop, logit_bias, user, seed to OpenAIRequest
types/request.rsAdd or extend ResponsesRequest if adopting Response API

4.3 Integration Tests

  • openai_tools_e2e: Non-streaming + streaming tool calls
  • anthropic_tools_e2e: Anthropic tool use (requires API key or mock)
  • anthropic_stream_tool_use: Anthropic streaming tool_use parsing
  • openai_stop_sequences: stop parameter behavior
  • responses_api_migrate: Response API basic request/response (once implemented)

4.4 Documentation and Examples

  • README: Anthropic tools support
  • Providers: Anthropic capability matrix
  • Tools: Anthropic tool use example
  • examples/: Add anthropic_tool_use.rs if implemented

4.5 Milestones and Acceptance

MilestoneScopeAcceptance
M1Anthropic tools (P0)≥95% unit, ≥90% integration, zero P0 defects
M2OpenAI unmapped fields (P1)Same
M3OpenAI Responses APISame + dedicated Response API tests
M4Docs and examplesAll above updates done

Released under the MIT License.