openai compatible api endpoint for claude and gemini
Choose between official provider compatibility endpoints and one shared gateway endpoint for Claude and Gemini, with tested request patterns and clear credential boundaries.

Use https://api.anthropic.com/v1/ with a Claude API key for Anthropic's official compatibility layer, or https://generativelanguage.googleapis.com/v1beta/openai/ with a Gemini API key for Google's. For both providers behind one gateway credential, use https://api.crazyrouter.com/v1 and select a supported model in each request.
Crazyrouter is an AI API gateway that advertises 600+ models, documents OpenAI-, Anthropic-, and Gemini-compatible interfaces, and lists GPT-4o mini input at $0.0975 per million tokens.
What is an OpenAI-compatible endpoint?#
An OpenAI-compatible endpoint accepts a defined subset of the OpenAI API's request and response format. For ordinary chat, your client sends a model identifier and a list of messages, then reads the assistant's text from the returned choices. This can let you reuse an SDK without writing a separate HTTP client for every vendor.
Compatibility describes a protocol, not an account entitlement. Installing the OpenAI package does not make an OpenAI key valid at Anthropic or Google. The destination server decides which credentials and models it accepts. You must change the key, base URL, and model together when moving between direct providers.
The term also does not mean every endpoint is available. Chat Completions compatibility does not prove support for Responses, embeddings, image generation, or realtime audio. Optional fields such as tools, reasoning controls, caching, and structured output need model-specific checks.
openai compatible api endpoint for claude and gemini#
These are the relevant URL shapes as checked on 2026-10-14. The client base URL differs from the complete URL used by a raw HTTP request.
| Route | SDK base URL | Chat Completions URL | Credential |
|---|---|---|---|
| Anthropic official compatibility layer | https://api.anthropic.com/v1/ | https://api.anthropic.com/v1/chat/completions | Claude API key |
| Google official compatibility layer | https://generativelanguage.googleapis.com/v1beta/openai/ | https://generativelanguage.googleapis.com/v1beta/openai/chat/completions | Gemini API key |
| Crazyrouter shared gateway | https://api.crazyrouter.com/v1 | https://api.crazyrouter.com/v1/chat/completions | Crazyrouter API key |
| Cloudflare AI Gateway | Depends on account and configured gateway | Follow the selected gateway's current route documentation | Depends on the selected authentication mode |
Anthropic's OpenAI SDK compatibility documentation describes this layer primarily as a way to test and compare models. It recommends its native API for the full Claude feature set. Google's OpenAI compatibility documentation publishes the Gemini URL and supported request patterns.
A documentation page on GitHub or a Google developer blog can explain these interfaces, but it is not itself an inference endpoint. Copy the server URL from the current API documentation rather than treating a citation domain as a gateway provider.
Which route should you choose?#
Use a direct provider route when you need the provider's full native feature set and already operate its account. A common SDK can be useful for evaluation, but it should not hide limitations that affect your production workload. For example, verify native citations or cache controls before assuming they survive translation through a compatibility layer.
Use a managed gateway when you want one funded account and a common integration across supported providers. You still need to check its exact catalogue identifiers, data handling, and usage reporting. A common credential reduces setup work; it does not guarantee identical tool behavior or response quality.
When comparing costs, keep gateway rates separate from provider reference rates. When comparing reliability, measure successful requests against your own acceptance criteria. A valid HTTP response with an empty answer or truncated JSON is not a completed task.

How to configure Python, Node.js, and cURL#
Store the gateway credential in CRAZYROUTER_API_KEY on your backend. Install the official OpenAI SDK for Python or Node.js. These examples make the smallest useful text request without optional controls that could obscure an authentication problem.
Python#
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["CRAZYROUTER_API_KEY"],
base_url="https://api.crazyrouter.com/v1",
)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Reply with exactly: endpoint ready"}],
)
print(response.choices[0].message.content)
Node.js#
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.CRAZYROUTER_API_KEY,
baseURL: "https://api.crazyrouter.com/v1",
});
const response = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Reply with exactly: endpoint ready" }],
});
console.log(response.choices[0].message.content);
cURL#
curl --fail-with-body https://api.crazyrouter.com/v1/chat/completions \
-H "Authorization: Bearer $CRAZYROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Reply with exactly: endpoint ready"}]}'
Tested on 2026-10-14: Python, Node.js, and cURL each returned endpoint ready using the exact gpt-4o-mini request above. These checks cover basic gateway text completion, not the direct provider endpoints or every Claude and Gemini feature.
For Claude or Gemini through this gateway, change the model to a supported identifier such as claude-sonnet-4-6 or gemini-2.5-flash. Check each route independently before adding application-specific parameters. Browse the model catalogue and integration pages when configuring an existing tool.
Pricing as of 2026-10#
The GPT-4o mini pricing page lists Crazyrouter input at 0.39 per million tokens. Its provider reference rates are 0.60 output. This is one dated model comparison, not a price quote for Claude or Gemini.
Use the Claude Sonnet 4.6 price page and Gemini 2.5 Flash price page for their current figures. Output length, cache use, context tiers, and retries affect the final bill. Keep measured token usage beside the route's applicable rate rather than estimating from character count.
FAQ#
openai compatible api endpoint for claude and gemini#
The official compatibility bases are Anthropic's /v1/ server and Google's /v1beta/openai/ server listed above. To use one gateway key across supported Claude and Gemini routes, configure the Crazyrouter base and choose a catalogue model ID.
Can I use an OpenAI key at Anthropic's endpoint?#
Use a Claude API key for Anthropic's compatibility layer. The OpenAI SDK is a client library; it does not transfer credentials or billing between vendors.
Why does my request contain chat/completions twice?#
Most SDKs append the method path to their configured base URL. Configure the base ending in /v1, rather than the full /v1/chat/completions path, when the SDK already supplies that suffix.
Does OpenAI compatibility include Claude's native features?#
Do not assume full parity. Anthropic recommends its native API for its full feature set and documents limitations in the compatibility layer.
Does a shared endpoint make every model use the same price?#
Each model keeps its own applicable billing schedule. Confirm its live rate and returned usage before comparing costs across routes.
Summary#
Start by choosing the credential arrangement and exact model, then configure the matching URL. For a shared gateway evaluation, create an account, fund API usage, and run a small text request before testing streaming or tools.
<!-- crazyrouter-related-links -->




