This guide is published by the Oxyy.ai team. Anthropic's limitations are quoted from Anthropic's own documentation. Oxyy is an independent gateway, not affiliated with Anthropic or OpenAI.
Quick answer: You can call Claude with the official OpenAI SDK two ways.
Anthropic's compatibility layer: set base_url="https://api.anthropic.com/v1/", use a Claude API key and a Claude model name. It works, but Anthropic says it's "not considered a long-term or production-ready solution": no prompt caching, strict tool schemas are ignored, thinking is hidden, audio and file inputs return 400.
A gateway such as Oxyy: set base_url="https://api.oxyy.ai/v1", one key, and model="claude-sonnet-5-5" works next to gpt-6-sol and gemini-4-argon in the same client, at 40% of Anthropic's list price. If you only ever call Claude and need every Claude feature, use the Anthropic SDK instead.
Three Ways to Reach Claude, Compared
The OpenAI SDK will talk to anything that answers at its base_url in the Chat Completions shape, so the question isn't whether it can reach Claude but what answers on the other end. Anthropic runs a translation endpoint of its own, gateways run theirs, and the native Anthropic SDK skips translation entirely. The table lines the four options up on the things that actually bite in production: caching, strict schemas, thinking and price.
| Anthropic SDK → Anthropic | OpenAI SDK → Anthropic compat layer | OpenAI SDK → Oxyy gateway | Anthropic SDK → Oxyy gateway | |
|---|---|---|---|---|
| Base URL | default | https://api.anthropic.com/v1/ | https://api.oxyy.ai/v1 | https://api.oxyy.ai (no /v1) |
| Key | Claude API key | Claude API key (+ anthropic-workspace-id header for non-workspace keys) | Oxyy key | Oxyy key |
| Request format | Messages API | Chat Completions, translated by Anthropic | Chat Completions, translated by Oxyy | Messages API, passed through |
| Production-ready per vendor | Yes | No ("test and compare model capabilities") | Yes | Yes |
| Prompt caching | Yes, cache_control | No | Via Anthropic SDK route | Yes, per-block cache_control preserved |
strict tool schemas | Yes (strict tool use / structured outputs) | Ignored | response_format json_schema → structured output | Yes |
| Thinking | Full control, summarised thinking returned | Only via extra_body; adaptive → 400; thinking not returned | Effort/adaptive handled by gateway | Yes, enabled / adaptive / disabled |
| Other vendors on the same client | No | No | Yes, 170+ models | No (Claude only on this endpoint) |
| Price (Sonnet 5.5, per 1M) | $2.00 / $10.00 | $2.00 / $10.00 | $0.80 / $4.00 | $0.80 / $4.00 |
Sources: Anthropic "OpenAI SDK compatibility" page; oxyy.ai/docs/anthropic-sdk and /docs/chat-completions; checked November 15, 2027.
The honest summary of that table: the compatibility layer is the quickest way to run a Claude model inside code written for OpenAI, and the worst way to run it in production. The two gateway routes exist because most teams want Claude and something else behind one client, and they want it cheaper.
Route 1: Anthropic's OpenAI Compatibility Layer
Anthropic hosts an OpenAI-shaped endpoint at https://api.anthropic.com/v1/. Point the OpenAI SDK at it, swap the key, and use a Claude model ID:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["ANTHROPIC_API_KEY"],
base_url="https://api.anthropic.com/v1/",
# Needed only if your key is a personal or service-account key not scoped to a workspace:
# default_headers={"anthropic-workspace-id": "wrkspc_..."},
)
resp = client.chat.completions.create(
model="claude-sonnet-5-5",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"},
],
)
print(resp.choices[0].message.content)
The same works in TypeScript, Go, Java, C# and Ruby with the official OpenAI SDKs (there's no official OpenAI PHP SDK, so PHP users need the Anthropic SDK). Supported models cover the current lineup from Haiku 4.5 through Fable 5.2.

What the compatibility layer does well
Simple chat, streaming, max_tokens, stop, basic function calling with tool_choice: auto, image input, and response_format with json_schema + strict: true all map cleanly. Rate limits are Anthropic's normal Messages API limits. For an A/B test of Claude against GPT inside an existing OpenAI codebase, it does the job in ten minutes.
What breaks, in Anthropic's own words
Anthropic's documentation lists the limitations plainly; these are the ones that bite in production:
| Feature | Compatibility-layer behaviour | What to do instead |
|---|---|---|
| Prompt caching | Not supported. Every request pays full input price | Anthropic SDK with cache_control, or a gateway that preserves it |
strict: true on tools | Ignored. Tool JSON isn't guaranteed to match the schema | Native structured outputs or strict tool use |
response_format: json_object or text | Returns 400; only json_schema + strict: true accepted | Use json_schema |
| Audio and file inputs | Return 400 | Native Messages API (PDF support) |
| Thinking | Must be sent as extra_body={"thinking": {...}}; adaptive returns 400; the response never includes thinking | Anthropic SDK for summarised thinking and effort |
| System / developer messages | All hoisted and concatenated into one top-level system, wherever they appear | Mid-conversation system messages, native API only |
top_p | Claude 4.7+ returns 400 for any value except the default 0.99 | Omit it |
| OpenTelemetry spans | Not emitted | Native API |
| Unsupported fields | Mostly silently ignored, not errored | Audit your request before trusting it |
The caching line alone decides it for most workloads. A coding agent that re-sends 60K tokens of context per turn pays $0.12 per turn on Sonnet 5.5 through the compat layer and about $0.02 with caching through the Anthropic SDK. Anthropic's note that the layer is "primarily intended to test and compare model capabilities" is not modesty; it's a description of the pricing you'll get.
Route 2: OpenAI SDK → a Gateway That Speaks Both
A unified gateway accepts OpenAI Chat Completions requests and translates them to each vendor's native API behind the scenes. For Claude on Oxyy:
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.oxyy.ai/v1",
api_key=os.environ["OXYY_API_KEY"],
)
for model in ["claude-sonnet-5-5", "gpt-6-sol", "gemini-4-argon"]:
resp = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": "Summarise this ticket in one line: 'Invoice shows two charges.'"}],
)
print(model, "->", resp.choices[0].message.content, resp.usage)
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.oxyy.ai/v1", apiKey: process.env.OXYY_API_KEY });
const resp = await client.chat.completions.create({
model: "claude-sonnet-5-5",
messages: [{ role: "user", content: "Summarise this ticket in one line: 'Invoice shows two charges.'" }],
});
console.log(resp.choices[0].message.content, resp.usage);
Three things change compared with Route 1. The model ID is the only per-vendor difference, so a fallback from Claude to GPT to Gemini is a list of strings rather than three SDKs and three billing accounts. The price is 40% of Anthropic's list: Sonnet 5.5 at $0.80 / $4.00, Opus 5.5 at $1.60 / $8.00, Haiku 5.5 at $0.04 / $0.20. And rate limits are set per Oxyy key by tier, with X-RateLimit-* headers on every response, instead of depending on your Anthropic organisation's spend history.
The caveat is the same as any translation layer: OpenAI's request shape has no field for cache_control blocks, effort, or between_tools. Oxyy's Chat Completions endpoint handles the common cases (streaming, tools, response_format json_schema, reasoning), but if you need per-block cache control or Anthropic-specific parameters, use Route 3.
Route 3: Anthropic SDK → the Same Gateway
This is the route for teams that want the full Claude feature set and the gateway price. The Anthropic SDK talks to Oxyy's /v1/messages endpoint, which passes the Messages API through rather than translating it:
import os
import anthropic
client = anthropic.Anthropic(
api_key=os.environ["OXYY_API_KEY"],
base_url="https://api.oxyy.ai", # no /v1: the SDK adds /v1/messages itself
)
msg = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=1024,
system=[{
"type": "text",
"text": open("style_guide.md").read(),
"cache_control": {"type": "ephemeral"}, # preserved -> read at $0.08 / 1M on Oxyy
}],
thinking={"type": "adaptive"},
output_config={"effort": "medium"},
messages=[{"role": "user", "content": "Review this draft for tone."}],
)
print(msg.content[-1].text)
print(msg.usage.cache_read_input_tokens, msg.usage.output_tokens)
What survives the trip, per Oxyy's documentation: system as a string or block array with per-block cache_control, thinking (enabled, adaptive, disabled, with budget_tokens converted to an effort level on models that use one), tools and every tool_choice mode, server tools, output_config.format as structured output, metadata, service_tier, betas (mapped to the anthropic-beta header), and native streaming events. POST /v1/messages/count_tokens is free and doesn't spend your rate limit. Two things don't: non-Claude models (a 400 in Anthropic's error shape; use the OpenAI SDK for those) and the retired Text Completions API.
The practical pattern is to use both SDKs against the same key: the Anthropic SDK for Claude where caching and effort matter, the OpenAI SDK for everything else and for cheap cross-vendor fallbacks.
Which Route Should You Use?
The route follows from two questions: does your code only ever call Claude, and does it need Claude's full feature set?
- Testing whether Claude beats GPT on your prompts, in existing OpenAI code → Route 1 or 2. Fastest to set up; use Route 2 if you also want Gemini or DeepSeek in the same run.
- Production app that only calls Claude and needs caching, PDFs, citations or thinking → Anthropic SDK direct, or Route 3 for the same features at 40% of list.
- Production app calling Claude plus other vendors through one client → Route 2. One SDK, one key, one bill, fallback by model string.
- Coding agent with long cached context on Claude → Route 3. Cache reads at 5% of input are the whole economics.
- Frameworks that speak OpenAI format only (LangChain's OpenAI class, n8n, Vercel AI SDK openai provider, Cline, Cursor BYOK) → Route 2. The framework can't send Messages API; the gateway translates for it.
Never ship Route 1 for a workload with repeated context. It's the only route of the four where Anthropic explicitly tells you not to.
Migrating From the Compatibility Layer to a Gateway
If you're already on Route 1, the move to Route 2 is two string changes:
# before client = OpenAI(api_key=os.environ["ANTHROPIC_API_KEY"], base_url="https://api.anthropic.com/v1/") # after client = OpenAI(api_key=os.environ["OXYY_API_KEY"], base_url="https://api.oxyy.ai/v1")
Model IDs stay the same (claude-sonnet-5-5, claude-opus-5-5, claude-haiku-5-5). Drop the anthropic-workspace-id header if you added one. Remove extra_body={"thinking": ...} hacks and any top_p you were sending. Then check usage on a few responses: the token counts should match what you saw before, and the invoice should be 40% of it.
The OpenAI SDK can call Claude, but how you point it matters. Anthropic's compatibility layer is a test harness: no caching, no strict schemas, no visible thinking, and Anthropic's own warning not to build on it. A gateway gives the same OpenAI SDK a production path to Claude alongside every other vendor, and the Anthropic SDK pointed at the same gateway keeps the full Claude feature set. Through Oxyy both routes run Sonnet 5.5 at $0.80 / $4.00 and Opus 5.5 at $1.60 / $8.00, served by Anthropic upstream.
Get a free Oxyy key and call Claude from the OpenAI SDK at 40% of list →
Related: Chat Completions on Oxyy · Anthropic SDK on Oxyy · Prompt caching · Structured outputs · Claude API pricing on Oxyy · Claude Opus 5.5 vs Sonnet 5.5 vs Haiku 5.5 · Claude Code with a cheaper API
Frequently Asked Questions
Can I use the OpenAI SDK with Claude?
Yes. Either point it at Anthropic's compatibility endpoint (https://api.anthropic.com/v1/) with a Claude API key, or at an OpenAI-compatible gateway such as Oxyy (https://api.oxyy.ai/v1) and use a Claude model ID like claude-sonnet-5-5.
Is Anthropic's OpenAI SDK compatibility layer production-ready?
Anthropic says no: it's "primarily intended to test and compare model capabilities, and is not considered a long-term or production-ready solution for most use cases". It lacks prompt caching, ignores strict tool schemas, hides thinking and rejects audio and file inputs.
Does prompt caching work through the OpenAI SDK with Claude?
Not through Anthropic's compatibility layer. To cache, use the Anthropic SDK (directly or against a gateway such as Oxyy, which preserves per-block cache_control).
Why are my Claude tool calls not matching the schema through the OpenAI SDK?
The compatibility layer ignores strict: true on function definitions. Use response_format with json_schema and strict: true, or move to the native Messages API with structured outputs or strict tool use.
How do I enable thinking when calling Claude via the OpenAI SDK?
Through Anthropic's compat layer, send it as an extra body field: extra_body={"thinking": {"type": "enabled", "budget_tokens": 2000}} in Python. adaptive returns a 400 and the response won't include the thinking text. Through the Anthropic SDK you get full control and summarised thinking.
What is the anthropic-workspace-id header?
If your Claude API key is a personal or service-account key not scoped to a workspace, Anthropic requires an anthropic-workspace-id header on every compatibility-layer request. Pass it via default_headers (Python) or defaultHeaders (TypeScript). Gateway keys don't need it.
Which Claude models work with the OpenAI SDK?
On Anthropic's compat layer: the current lineup including Claude Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.1/5.2 and the 4.x models. On Oxyy, every Claude model in the catalog works through both the OpenAI SDK and the Anthropic SDK.
Can one OpenAI client call Claude, GPT and Gemini?
Yes, through a unified gateway. On Oxyy the same OpenAI(base_url="https://api.oxyy.ai/v1") client accepts claude-sonnet-5-5, gpt-6-sol, gemini-4-argon, deepseek-v4-pro and 170+ other model IDs.
Is Claude cheaper through a gateway than through the OpenAI compatibility layer?
Through Anthropic's compat layer you pay Anthropic list price ($2 / $10 for Sonnet 5.5). Through Oxyy the same model costs $0.80 / $4.00, and you regain prompt caching if you use the Anthropic SDK route.
Should I just use the Anthropic SDK instead?
If your code only talks to Claude, yes: it's the only way to get every feature (PDF input, citations, summarised thinking, effort, between_tools, mid-conversation system messages). You can still point it at a gateway for the price. Use the OpenAI SDK when the rest of your stack already speaks OpenAI format.

