{"slug": "how-to-switch-from-openai-to-claude-what-breaks-in-api-apps-and-agents", "title": "How to switch from OpenAI to Claude: what breaks in API apps and agents", "summary": "Migrating an app or agent from OpenAI to Claude requires moving requests to Anthropic's Messages API, and several changes return HTTP 400 errors, according to a migration guide citing Anthropic's and OpenAI's API documentation read on November 18, 2026. On API version 2026-10-21, sending temperature, top_p or top_k returns a 400 on every Claude model even at default values, and tool_choice \"required\" has no direct equivalent on Claude Opus 5.5, Sonnet 5.5 and Fable 5.2. The guide notes that Claude Sonnet 5.5 and GPT-6.2 Sol both list at $2 and $10 per million tokens, but differing tokenizers, thinking tokens and caching rules mean the bill per task does not match.", "body_md": "[← all posts](https://www.evalshift.dev/blog)\n\n# How to switch from OpenAI to Claude: what breaks in API apps and agents\n\nMoving an app or agent from OpenAI to Claude: the request mapped field by field, the changes that return a 400, cost per task, and how to test it.\n\nTo switch from OpenAI to Claude, move your requests from Chat Completions or the Responses API to Anthropic's Messages API. Then test the agent's behavior, not just its answers. The API differences are well documented and take a day to fix. The rest takes longer: Claude may call different tools with different arguments, and that only shows up when you replay real runs on both models and diff the results.\n\nMost of what breaks in the move is not in the obvious places:\n\n- +**`tool_choice: \"required\"` has no direct equivalent on the newest Claude models.** Claude\nOpus 5.5, Sonnet 5.5 and Fable 5.2 return a 400 for forced tool use. You use`auto` with strict\ntools and say in the prompt when the tool applies.\n- +**`temperature` is gone.** On API version`2026-10-21` , the default in the new Anthropic SDK\nmajors, a request that sends`temperature` ,`top_p` or`top_k` returns a 400 on every Claude\nmodel, even at the default value.\n- +**Tool calls and results change shape.** Claude returns tool arguments as an object, not a JSON\nstring. Results go back as`tool_result` blocks inside a user message, and the thinking blocks\nfrom the assistant turn must be sent back unchanged.\n- +**Same list price is not same cost.** Claude Sonnet 5.5 and GPT-6.2 Sol both cost $2 and $10 per\nmillion tokens. Tokenizers, thinking tokens and caching rules differ, so the bill per task does\nnot match.\n\nThis post maps an OpenAI request to Claude field by field and covers each change that can break an app or agent. It ends with a six-step migration whose core is replaying recorded runs on both models. The facts come from Anthropic's and OpenAI's API docs, read on November 18, 2026. Check the linked pages before you rely on a price or a model name, because both companies changed theirs in 2026.\n\nA disclosure: I build EvalShift, a tool for testing model changes on agents. It has a short section near the end. Everything before it works without it.\n\n## OpenAI vs Claude API: the request mapped field by field\n\n| OpenAI (Chat Completions / Responses) | Claude Messages API | What changes | \n|---|---|---|\n| `client.chat.completions.create` /`client.responses.create` | `client.messages.create` | One endpoint, `POST /v1/messages` | \n| `system` or`developer` message, Responses`instructions` | top-level `system` parameter | System text leaves the message list | \n| `max_completion_tokens` , optional | `max_tokens` , required | A request without it fails | \n| `tools: [{type: \"function\", function: {name, parameters}}]` | `tools: [{name, description, input_schema}]` | Schema key renamed, no wrapper | \n| `tool_choice: \"required\"` or a named function | `tool_choice: {type: \"any\"}` or`{type: \"tool\"}` | 400 on Opus 5.5, Sonnet 5.5 and Fable 5.2 | \n| `parallel_tool_calls: false` | `disable_parallel_tool_use: true` inside`tool_choice` | Moves into another object | \n| `function.arguments` , a JSON string | `tool_use.input` , an object | No `json.loads` | \n| `role: \"tool\"` message /`function_call_output` item | `tool_result` block in a`user` message | Results go in the user turn | \n| `response_format` /`text.format` with`json_schema` | `output_config.format` with`json_schema` | Different schema limits | \n| `reasoning_effort` /`reasoning.effort` | `output_config.effort` with adaptive thinking | Different levels and defaults | \n| `temperature` ,`top_p` | none | 400 on API version `2026-10-21` | \n| `finish_reason` | `stop_reason` | Adds `refusal` and`pause_turn` | \n| Chunks with `choices[].delta` , then`[DONE]` | Typed SSE events, no `[DONE]` | New stream parser | \n\nAnthropic's [Messages API reference ↗](https://platform.claude.com/docs/en/api/messages/create) and\nOpenAI's [Chat Completions reference ↗](https://developers.openai.com/api/reference/resources/chat)\nlist every field. The sections below cover the ones that change behavior, not just names.\n\n## System prompts become a top-level field\n\nOpenAI puts instructions in the message list. With recent models they go in a `developer` message,\nwhich [replaced `system` from o1 on ↗](https://developers.openai.com/api/reference/resources/chat),\nor in the Responses API's top-level `instructions`. Claude takes the system prompt as a separate\n`system` parameter, a string or a list of text blocks, and `messages` holds only `user` and\n`assistant` turns.\n\nIf your app adds instructions partway through a conversation, Claude has an equivalent. You append\na message with `role: \"system\"` to `messages`, and it applies from that point on. Anthropic's\n[mid-conversation system messages page ↗](https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages)\nlists the models that support it: Opus 5.5, Sonnet 5.5, Haiku 5.5 and the Fable models, but not\nSonnet 5. Such a message must follow a user turn, and either end `messages` or be followed by an\nassistant turn. On Sonnet 5.5 and Haiku 5.5 one placed right\nafter a tool result can be read as untrusted text, because those models are trained to resist\nprompt injection through tool results.\n\nTwo smaller rules come with the move. `max_tokens` is required on every Claude request, where\nOpenAI's `max_completion_tokens` is optional. And Claude 4.6 and later models reject a conversation\nthat ends on an assistant turn. Anthropic's [error reference ↗](https://platform.claude.com/docs/en/api/errors)\ngives the message, \"This model does not support assistant message prefill. The conversation must\nend with a user message.\" If you used a partial assistant message to steer the format, use\nstructured output or a system prompt instruction instead.\n\n## Tool calls and tool results change shape\n\nA tool definition loses its wrapper. OpenAI's Chat Completions nests the schema under\n`function.parameters`, and the Responses API flattens it. Claude takes `name`, `description` and\n`input_schema` at the top level. Claude allows tool names up to 128 characters, OpenAI up to 64, so\nnames carry over unchanged.\n\nThe response is where code breaks. OpenAI returns tool arguments as a JSON-encoded string that you\nparse. Claude returns a `tool_use` block whose `input` is already an object. A `json.loads` call\nleft in place raises a `TypeError` on the first tool call.\n\nTool results move too. OpenAI expects a `role: \"tool\"` message with a `tool_call_id`, or a\n`function_call_output` item in the Responses API. Claude expects a `tool_result` block inside the\nnext `user` message. Anthropic's [tool-call guide ↗](https://platform.claude.com/docs/en/agents-and-tools/tool-use/handle-tool-calls)\nsets three rules an OpenAI-style loop tends to break:\n\n- +**One result per call, all in one message.** When Claude calls several tools at once, every`tool_result` goes back together in the next user message.\n- +**Results come first.** In that message the`tool_result` blocks come before any text.\n- +**Nothing in between.** No message can sit between the assistant's tool call and the user\nmessage with the results.\n\nA failed tool gets a `tool_result` with `is_error: true` rather than being left out. To limit Claude\nto one tool call per turn, set `disable_parallel_tool_use: true` inside `tool_choice`. It is not a\ntop-level parameter like OpenAI's `parallel_tool_calls`.\n\n### Send the thinking blocks back\n\nCurrent Claude models think before they answer, and a tool-calling turn can contain `thinking`\nblocks next to the `tool_use` blocks. Anthropic's error reference says to \"pass back every\n`thinking` and `redacted_thinking` block from the assistant turn exactly as received\", and an edited\nblock is rejected. The simplest loop appends the whole `response.content` as the assistant message\ninstead of rebuilding it from the text and tool calls. OpenAI asks for the same with reasoning\nitems in the Responses API, so if your loop already passes those back, keep that pattern.\n\n## tool_choice \"required\" has no equivalent on the newest Claude models\n\nOpenAI's `tool_choice: \"required\"` makes the model call at least one tool, and a named function\nforces that tool. Claude's matching options are `{\"type\": \"any\"}` and\n`{\"type\": \"tool\", \"name\": ...}`. On current models they fail. Anthropic's\n[error reference ↗](https://platform.claude.com/docs/en/api/errors) says Fable 5.2, Opus 5.5,\nSonnet 5.5 and Fable 5.1 \"don't support forced tool use\", and the request returns a 400:\n\n```\ntool_choice: type \"tool\" and \"any\" are not supported for this model.\n```\n\nHaiku 5.5 still accepts forced tool use. On the other models Anthropic's advice is to \"use `auto`\nwith strict tool use to keep tool inputs schema-valid, or structured outputs when you need the\nresponse itself in a fixed JSON shape\", and to say in the prompt when the tool applies.\n\nThis is a behavior change, not only a syntax change. With `auto`, the model decides whether to call\nthe tool, so a route that always called `lookup_order` under OpenAI can now answer without it.\nThat is exactly the kind of change a replay catches and a read-through of the outputs misses.\n\n## Structured output: response_format becomes output_config.format\n\nOpenAI's Structured Outputs use `response_format` with a `json_schema` in Chat Completions and\n`text.format` in the Responses API. Claude uses `output_config.format`, also with a `json_schema`\ntype, and `strict: true` on a tool for schema-valid tool inputs. The schema rules differ, and a\nschema that works on one side can fail on the other.\n\n| Schema rule | OpenAI | Claude | \n|---|---|---|\n| Optional properties in strict mode | Not allowed, every field must be `required` | Allowed, up to 24 across all strict schemas | \n| Recursive schemas | Supported | Not supported | \n| `oneOf` | Not listed, use `anyOf` | Not supported, use `anyOf` | \n| `minimum` ,`maximum` | Supported | Not supported | \n| `minLength` ,`maxLength` | Not listed, only `pattern` and`format` | Not supported | \n| Strict tools per request | No stated cap | 20 | \n\nSources: Anthropic's [structured outputs page ↗](https://platform.claude.com/docs/en/build-with-claude/structured-outputs),\nOpenAI's [function calling ↗](https://developers.openai.com/api/docs/guides/function-calling) and\n[structured outputs ↗](https://developers.openai.com/api/docs/guides/structured-outputs) guides.\nAnthropic also notes that Claude doesn't guarantee the capitalization of string `enum` values, and\nthat the first request with a new schema pays a compilation step that is then cached for 24 hours\nfrom last use. Range checks that the schema did for you on OpenAI need to move into your own\nvalidation code.\n\n## temperature, top_p and top_k return a 400\n\nOn October 21, 2026 Anthropic released API version `2026-10-21`, which Python SDK 2.0.0 and\nTypeScript SDK 1.0.0 send by default. Its [migration page ↗](https://platform.claude.com/docs/en/api/migration-2026-10-21)\nsays a request that sends `temperature`, `top_p` or `top_k` \"returns a 400 error, even at the\nparameter's default value.\" On the older API version, current models already reject any\nnon-default value.\n\nIf your OpenAI code set `temperature=0` for repeatable output, delete it. Anthropic's Opus 5.5\nmigration guide points out that `temperature = 0` \"never guaranteed identical outputs\" anyway. To\ncompare models fairly without it, run each case several times rather than once. OpenAI is moving the\nsame way: its GPT-6.2 guide says to omit `temperature` and `top_p` when migrating Chat Completions\nrequests.\n\n## Reasoning effort becomes thinking and effort\n\nOpenAI controls reasoning with `reasoning_effort` in Chat Completions or `reasoning.effort` in the\nResponses API. Claude uses adaptive thinking, where the model decides how much to think, and sets\nthe depth with `output_config.effort`: `low`, `medium`, `high`, `xhigh` or `max`. The defaults\ndiffer by model, so set the level explicitly instead of relying on them.\n\n|  | Default effort | Can thinking be turned off? | \n|---|---|---|\n| Claude Opus 5.5 | `medium` | No, 400 for `{\"type\": \"disabled\"}` | \n| Claude Sonnet 5.5 | `high` | No, but `{\"type\": \"between_tools\"}` drops up-front thinking | \n| Claude Haiku 5.5 | `medium` | Yes, `{\"type\": \"disabled\"}` is accepted | \n| Claude Fable 5.2 | `high` | No | \n| OpenAI GPT-6.2 Astra / Sol | `medium` , the API default | No, the API rejects `none` | \n| OpenAI GPT-6 Luna | `medium` | Yes, `none` is supported | \n\nSources: Anthropic's [effort page ↗](https://platform.claude.com/docs/en/build-with-claude/effort) and\n[error reference ↗](https://platform.claude.com/docs/en/api/errors), OpenAI's\n[reasoning guide ↗](https://developers.openai.com/api/docs/guides/reasoning),\n[API reference ↗](https://developers.openai.com/api/reference/resources/chat) and\n[model pages ↗](https://developers.openai.com/api/docs/models). The `budget_tokens` setting you may\nknow from older Claude models is not accepted after Opus 4.6 and Sonnet 4.6.\n\nThinking text is hidden by default on current Claude models (`display: \"omitted\"`), but the tokens\nare still generated and billed as output. If you show reasoning to users while it streams, set\n`display: \"summarized\"`.\n\n## Streaming events are typed and there is no [DONE]\n\nOpenAI's Chat Completions stream sends chunks with `choices[].delta` and ends with `data: [DONE]`.\nClaude's [stream ↗](https://platform.claude.com/docs/en/build-with-claude/streaming) is a sequence of\ntyped events: `message_start`, then `content_block_start`, `content_block_delta` and\n`content_block_stop` for each block, one or more `message_delta` events and a final\n`message_stop`. There is no `[DONE]`. The stream can include `ping` events at any point, and new\nevent types may appear, so a parser should skip types it doesn't know.\n\nThree details catch hand-written parsers:\n\n- +**Tool arguments stream as partial JSON.**`input_json_delta` events carry fragments of a JSON\nstring, and only the finished`tool_use.input` is an object.\n- +**Usage in `message_delta` is cumulative** , not an increment to add up.\n- +**Errors can arrive inside a 200 stream** , for example an`error` event with`overloaded_error` .\n\nThe Anthropic SDK's stream helpers handle the first two. A mid-stream error still needs your own retry.\n\n## Stop reasons, refusals and overload errors\n\nOpenAI reports why a response ended in `finish_reason`: `stop`, `length`, `tool_calls` or\n`content_filter`. On Claude, `stop_reason` splits `stop` into `end_turn` and `stop_sequence`,\n`length` becomes `max_tokens` and `tool_calls` becomes `tool_use`. It adds `pause_turn`, when a\nserver-tool loop hits its iteration limit, and `model_context_window_exceeded`. The nearest thing\nto `content_filter` is `refusal`. Anthropic's\n[refusals page ↗](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback) says\nOpus 5.5, Sonnet 5.5, Haiku 5.5 and the Fable models have safety classifiers that can decline a\nrequest. A declined request comes back as a normal response with `stop_reason: \"refusal\"` and a\n`stop_details.category`, not as an error, so check `stop_reason` before reading the content. A beta\n`fallbacks` parameter can rerun a declined request on another model.\n\nOverload errors use a different status code. OpenAI returns 503 `server_is_overloaded`, while\nClaude returns 529 `overloaded_error` and can also send it mid-stream. Retry logic that only treats\n429 and 503 as retryable will not retry Claude's overloads. Anthropic's SDKs retry twice by default\nand honor the `retry-after` header.\n\n## Cost: prices match, bills don't\n\nAt list price the two lineups line up tier for tier:\n\n| Tier | Claude model | Claude price (input / output per 1M tokens) | OpenAI model | OpenAI price | \n|---|---|---|---|---|\n| Top | `claude-fable-5-2` | $8 / $40 | `gpt-6.2-astra` | $8 / $40 | \n| Upper middle | `claude-opus-5-5` | $4 / $20 | `gpt-5.6-sol` , previous generation | $4 / $20 | \n| Middle | `claude-sonnet-5-5` | $2 / $10 | `gpt-6.2-sol` | $2 / $10 | \n| Small | `claude-haiku-5-5` | $0.10 / $0.50 for prompts up to 100K tokens | `gpt-6-luna` | $0.10 / $0.50 | \n\nSources: Anthropic's [pricing page ↗](https://platform.claude.com/docs/en/about-claude/pricing) and\nOpenAI's [pricing page ↗](https://developers.openai.com/api/docs/pricing). OpenAI's current lineup\nhas nothing between $2 and $8 per million input tokens. Its closest model at Opus 5.5's price is\nthe previous-generation `gpt-5.6-sol`, and `gpt-6.1-sol`, which OpenAI describes as near-Astra\nperformance at a lower cost, is priced like GPT-6.2 Sol at $2 / $10.\n\nFour things make the cost per task differ even when the price per token matches:\n\n- +**Tokenizers.** The same text is a different number of tokens on each side. Anthropic says its\ntokenizer from Claude Opus 4.7 on produces about 30% more tokens than earlier Claude models, but\nneither company publishes a comparison with the other's. Count your own prompts with Claude's\nfree[token counting endpoint ↗](https://platform.claude.com/docs/en/build-with-claude/token-counting) instead of reusing OpenAI's counts.\n- +**Thinking tokens.** Both bill reasoning as output tokens, and the defaults differ (see the\neffort table above). A model that thinks more per turn costs more per task at the same price.\n- +**Long prompts.** Claude charges a flat rate up to the full 1M-token context, except Haiku 5.5,\nwhich costs $0.50 / $2.50 above 100K-token prompts. OpenAI doubles the input price and charges\n1.5 times for output above 272K input tokens.\n- +**Caching.** Both now charge 1.25 times the input price for a cache write. OpenAI does from\nGPT-5.6 on, with a 30-minute default lifetime, and Claude does for its 5-minute cache. Cache\nreads cost 0.05 times the input price on Opus 5.5, Sonnet 5.5 and GPT-6.2 Astra and Sol. The\ndifference is in what gets cached. OpenAI caches automatically from 1,024 tokens, while Claude\ncaches only when you add`cache_control` and from 512 tokens on current models. One top-level`cache_control` field turns on automatic caching. A prompt marked\nfor caching below the minimum is simply not cached, with no error.\n\nBoth companies take 50% off through their batch APIs. Latency depends on the same factors, effort and thinking first. Measure it on your own requests instead of trusting a benchmark chart.\n\n## Can I keep using the OpenAI SDK with Claude?\n\nFor testing, yes. Anthropic runs an [OpenAI SDK compatibility layer ↗](https://platform.claude.com/docs/en/cli-sdks-libraries/libraries/openai-sdk):\npoint the OpenAI client at `https://api.anthropic.com/v1/` with an Anthropic API key and the\nChat Completions calls reach Claude. Anthropic describes it as \"primarily intended to test and\ncompare model capabilities\", not \"a long-term or production-ready solution\", and its limits explain\nwhy:\n\n- +`strict` on tools is ignored, so tool inputs aren't guaranteed to match the schema.\n- +`tool_choice: \"required\"` and a named function still force a tool call, and some models return\na 400 for that, as above.\n- +`temperature` below 1 returns a 400 on Claude 4.7 and later models, so omit it.\n- +`response_format` accepts only`json_schema` with`strict: true` .`json_object` returns a 400.\n- +Prompt caching is not supported.\n- +Thinking is not returned, and `reasoning_effort` is ignored along with`seed` ,`logprobs` and\nmost other unsupported fields.\n\nUse it to try Claude on a few requests without rewriting code. For production, use the Anthropic SDK. Anthropic documents only the Chat Completions shape there, so Responses API code has to be moved either way.\n\n## Step 1: List the OpenAI features your code depends on\n\nGrep the code for every call to the OpenAI client and note, per route, what each one relies on:\n`tool_choice: \"required\"` or a named function, `parallel_tool_calls`, `response_format` and the\nschemas behind it, `temperature`, `reasoning_effort`, streaming, prefilled assistant messages,\n`seed`, `logprobs`, image or audio inputs, and prompt caching. Every item on that list maps to one\nof the sections above. The list tells you which routes are a rename and which change behavior.\n\nAlso check the retry and error handling around the client. It needs to treat Claude's 529 as\nretryable and handle a `refusal` stop reason that arrives as a success.\n\n## Step 2: Record real runs before you touch the code\n\nBefore you change anything, capture 100 to 300 real inputs per route from production. With them, record the tools the model called, their arguments in order, the structured fields it returned, and anything it refused. That is the baseline the Claude version has to match. Hand-written test prompts cover what you thought to test. Recorded traffic covers what users actually send, including the multi-turn conversations and odd tool sequences that break first.\n\n## Step 3: Translate the request to the Messages API\n\nHere is a typical OpenAI tool-calling request on `gpt-4.1`, which OpenAI shuts down on January 14,\n2027:\n\n``` python\nimport json\nfrom openai import OpenAI\n\nclient = OpenAI()\nresponse = client.chat.completions.create(\n    model=\"gpt-4.1\",\n    messages=[\n        {\"role\": \"system\", \"content\": SYSTEM_PROMPT},\n        {\"role\": \"user\", \"content\": user_message},\n    ],\n    tools=[{\n        \"type\": \"function\",\n        \"function\": {\"name\": \"lookup_order\", \"parameters\": ORDER_SCHEMA, \"strict\": True},\n    }],\n    tool_choice=\"required\",\n    temperature=0,\n)\ncall = response.choices[0].message.tool_calls[0]\nargs = json.loads(call.function.arguments)\n```\n\nOn GPT-6.2 Astra and Sol the same call would already need changes on OpenAI's side: OpenAI's\n[GPT-6.2 guide ↗](https://developers.openai.com/api/docs/guides/latest-model) says tool calling on\nthose models requires the Responses API, and to omit `temperature`. Here is the request on Claude:\n\n``` python\nimport anthropic\n\nclient = anthropic.Anthropic()\nmessages = [{\"role\": \"user\", \"content\": user_message}]\nresponse = client.messages.create(\n    model=\"claude-sonnet-5-5\",\n    max_tokens=16000,                # required\n    system=SYSTEM_PROMPT,            # top-level, not a message\n    messages=messages,\n    tools=[{\n        \"name\": \"lookup_order\",\n        \"description\": \"Look up an order by its ID. Call it whenever the user mentions an order.\",\n        \"input_schema\": ORDER_SCHEMA,\n        \"strict\": True,\n    }],\n    output_config={\"effort\": \"medium\"},  # set it, don't rely on the default\n    # no tool_choice: forced tool use is a 400 on this model, auto is the default\n    # no temperature: a 400 on API version 2026-10-21\n)\nif response.stop_reason == \"tool_use\":  # with auto, Claude may answer without a tool\n    # send response.content back unchanged, thinking blocks included,\n    # then every tool_result in one user message, before any text\n    messages.append({\"role\": \"assistant\", \"content\": response.content})\n    messages.append({\"role\": \"user\", \"content\": [\n        {\"type\": \"tool_result\", \"tool_use_id\": block.id, \"content\": run_tool(block.name, block.input)}\n        for block in response.content\n        if block.type == \"tool_use\"  # block.input is already a dict\n    ]})\n```\n\nBecause `tool_choice` is gone, the instruction that the tool should be called moves into its\ndescription and the system prompt. Anthropic's compatibility page warns that a heavily adjusted\nprompt is \"likely to be well-tuned to OpenAI specifically\". Plan to rework the prompt, not only the\nrequest.\n\n## Step 4: Pick the Claude model and effort per route\n\nStart each route on the Claude model at the same price as the OpenAI model it replaces: Sonnet 5.5\nfor GPT-6.2 Sol, Haiku 5.5 for GPT-6 Luna, Fable 5.2 for GPT-6.2 Astra. Then run the same cases at\na lower effort as well. Anthropic's [effort page ↗](https://platform.claude.com/docs/en/build-with-claude/effort)\nsuggests `medium` for well-specified agentic and multistep tool-use work, `high` for harder or\nlonger tasks, and `medium` or `low` for chat. Move a route up a tier only when the replay in step 5\nshows the cheaper setup failing it. Routes that truly need forced tool use can try Haiku 5.5, which\nstill accepts it, but Anthropic notes that forcing a tool also skips thinking on every model that\naccepts it.\n\n## Step 5: Replay the same runs on both models and diff them\n\nRun every recorded input from step 2 through the OpenAI model and the Claude version with identical history, tools and system prompt. Then compare each pair:\n\n- +**Tool calls** : same tools, same order, same arguments. Check them deterministically, not with a\njudge. A route that used`tool_choice: \"required\"` needs extra attention here.\n- +**Structured fields** : parse every output against the schema and compare values, not only\nvalidity.\n- +**Refusals and stop reasons** : count`refusal` and`max_tokens` stops per route.\n- +**Cost and latency per task** , from the usage each API reports, including thinking tokens.\n\nWithout `temperature`, each case varies from run to run, so sample each one several times. Then\ndecide with thresholds you wrote down before you saw the results. For example: no more than 5% of\ncases call a different tool, and every structured field matches. [What actually breaks when you\nswitch LLMs](https://www.evalshift.dev/blog/what-breaks-when-you-switch-llms) explains why the worst differences read as\ncorrect answers, which is why a text-only review misses them.\n\n## Step 6: Switch one route at a time\n\nPut the model choice behind a flag per route, move the routes that passed step 5 first, and keep the OpenAI path working until each route has run on Claude in production for a while. Watch error rates, including 529s and refusals, cost per task and latency per route. Keep the recorded suite: when Anthropic releases the next model, the same replay tells you whether to move again.\n\n## Doing this with EvalShift\n\nDisclosure again: I'm the founder of EvalShift, and steps 2 and 5 are the part it automates. The\ncapture SDK wraps the OpenAI client and records real runs with their tool calls, and `compare`\nreplays them on Claude:\n\n``` python\nfrom openai import OpenAI\nfrom evalshift import capture\nfrom evalshift.adapters.openai import wrap_openai\n\nclient = wrap_openai(OpenAI())  # each create() inside a capture records one model call\n\nTOOLS = [...]  # the tools the agent is offered, or [] for none\n\n@capture.agent(suite=\"support\", redact=True, tools=TOOLS)  # no-op unless EVALSHIFT_CAPTURE=1\ndef handle_ticket(message): ...\npip install evalshift\nEVALSHIFT_CAPTURE=1 python my_agent.py   # record production-shaped runs\nevalshift capture sync                   # recorded runs -> golden suite\nevalshift compare --suite-name support --to claude-sonnet-5-5\n```\n\nBoth arms are live calls through LiteLLM, which translates the recorded OpenAI requests into Claude\nones. EvalShift sends `temperature=0` on every call. When Claude rejects it, EvalShift resends\nwithout it and marks the run as non-deterministic in the report, so set\n`defaults.samples_per_example` above 1. A capture that recorded `tool_choice: \"required\"` replays it\nas Claude's `any`, which fails on Sonnet 5.5 the same way your app would. Fix the request, then\ncompare again. EvalShift's config has no effort setting, so `compare` measures Claude at the model's\ndefault effort. Docs: [/docs/sdk-adapters](https://www.evalshift.dev/docs/sdk-adapters), [/docs/captures](https://www.evalshift.dev/docs/captures),\n[/docs/migration-policy](https://www.evalshift.dev/docs/migration-policy).\n\n## FAQ\n\n**Can I use the OpenAI SDK to call Claude?** Yes, through Anthropic's OpenAI SDK compatibility\nlayer at `https://api.anthropic.com/v1/`. Anthropic says it is meant for testing and comparing\nmodels, not as a production solution: it ignores `strict` on tools, doesn't support prompt caching,\ndoesn't return thinking and ignores `reasoning_effort`. For production, use the Anthropic SDK.\n\n**Does Claude support tool_choice \"required\"?** Not on its newest models. Claude's equivalents,\n`tool_choice` `any` and `tool`, return a 400 on Claude Opus 5.5, Sonnet 5.5, Fable 5.2 and\nFable 5.1. Haiku 5.5 still accepts them. Anthropic recommends `auto` with strict tools, plus a\nprompt that says when the tool applies, or structured outputs when you need JSON back.\n\n**Why does Claude return a 400 for temperature?** API version `2026-10-21`, released October 21,\n2026 and sent by default from Python SDK 2.0.0 and TypeScript SDK 1.0.0, removed `temperature`,\n`top_p` and `top_k`. A request that sends any of them returns a 400 on every model, even at the\ndefault value. Remove the parameter, and sample each test case several times instead.\n\n**Is Claude more expensive than OpenAI?** Per token, the tiers match. Claude Sonnet 5.5 and GPT-6.2\nSol both cost $2 per million input tokens and $10 per million output tokens, and Fable 5.2 matches\nGPT-6.2 Astra at $8 and $40. Per task the cost differs, because the tokenizers, thinking defaults\nand caching rules differ. Count your own prompts with Claude's token counting endpoint and compare\nthe cost of real runs.\n\n**Which Claude model replaces GPT-6.2 Sol?** Claude Sonnet 5.5, at the same $2 and $10 per million\ntokens. For GPT-6 Luna the same-price model is Claude Haiku 5.5, and for GPT-6.2 Astra it is Claude\nFable 5.2. Start there and confirm with a replay of your own traffic before switching.\n\n**Does Claude support structured outputs?** Yes. Claude uses `output_config.format` with a JSON\nschema, and `strict: true` on tools for schema-valid tool inputs. The schema rules differ from\nOpenAI's. Claude allows optional properties in strict mode but doesn't support recursive schemas,\n`oneOf`, or `minimum`, `maximum` and length constraints.\n\n**Do I need to rewrite my prompts for Claude?** Usually some of them. Anthropic says a prompt tuned\nextensively for OpenAI is likely tuned to OpenAI specifically. When forced tool use goes, the\ninstruction to call a tool moves into the prompt and the tool's description. Replay real runs on\nboth models to find the prompts that need work.\n\n## Keep reading\n\n- +[What actually breaks when you switch LLMs](https://www.evalshift.dev/blog/what-breaks-when-you-switch-llms) — why the\nworst regressions from a model swap read as correct.\n- +[How to test an LLM model migration before you ship it](https://www.evalshift.dev/blog/test-llm-model-migration-before-you-ship) — step 5 as a full method.\n- +[Anthropic model deprecation schedule](https://www.evalshift.dev/blog/anthropic-model-deprecation-schedule) — every Claude\nretirement date, and what changes from Sonnet 4.5 to Sonnet 5.5.\n- +[Evaluating agent tool calls](https://www.evalshift.dev/blog/evaluating-agent-tool-calls) — the checks that see tool\nbehavior text evaluators miss.", "url": "https://wpnews.pro/news/how-to-switch-from-openai-to-claude-what-breaks-in-api-apps-and-agents", "canonical_source": "https://www.evalshift.dev/blog/switch-from-openai-to-claude", "published_at": "2026-11-19 16:17:01.239783+00:00", "updated_at": "2026-11-19 16:17:03.913639+00:00", "lang": "en", "topics": ["large-language-models", "ai-agents", "ai-tools", "developer-tools"], "entities": ["OpenAI", "Anthropic", "Claude", "Chat Completions API", "Responses API", "Messages API", "Claude Opus 5.5", "Claude Sonnet 5.5"], "also_reported_by": [], "takeaway": "On Anthropic API version 2026-10-21, remove temperature, top_p and top_k from requests (they return a 400 even at defaults), send tool arguments as an object instead of a JSON string, and replay recorded runs on both models to diff tool calls rather than answers.", "recommendation": {"advice": "When migrating from OpenAI to Claude, replay recorded agent runs on both models and diff tool calls and arguments, not just final answers, since Claude may call different tools with different arguments.", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/how-to-switch-from-openai-to-claude-what-breaks-in-api-apps-and-agents", "markdown": "https://wpnews.pro/news/how-to-switch-from-openai-to-claude-what-breaks-in-api-apps-and-agents.md", "text": "https://wpnews.pro/news/how-to-switch-from-openai-to-claude-what-breaks-in-api-apps-and-agents.txt", "jsonld": "https://wpnews.pro/news/how-to-switch-from-openai-to-claude-what-breaks-in-api-apps-and-agents.jsonld"}}