OpenAI Compatibility
Use Claude models with the OpenAI SDK — drop-in compatible API. Works with any tool that supports OpenAI format.
LLMsRelay is an independently operated API gateway. It is not affiliated with or endorsed by Anthropic, PBC. Product and model names are used only to describe compatibility.
Base URL: https://api.llmsrelay.com/v1. Endpoint: POST /chat/completions. API key: sk-cs4-*. Models: Use IDs returned by GET /v1/models. Best for: Existing OpenAI SDKs and OpenAI-compatible tools.
When to Use This Route
- Use the OpenAI-compatible route with a Basic key for Claude models, or with a Codex key for OpenAI/GPT models.
- Use the native
/v1/messagesroute if you want the most Claude-native behavior, cleaner troubleshooting, or direct Anthropic-style SDK integration. - For Cursor, Cline, Roo Code, and similar OpenAI-style tools, choose the key group that matches the model family. Kilo Code has a separate OpenAI Responses provider for GPT/Codex models; see the Kilo Code guide.
Endpoint
POST https://api.llmsrelay.com/v1/chat/completions
Authentication
Use the standard Authorization: Bearer header with your LLMsRelay API key:
curl https://api.llmsrelay.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4.6",
"messages": [{"role": "user", "content": "Hello!"}]
}'Python (OpenAI SDK)
OpenAI SDK for Pythonpython
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.llmsrelay.com/v1"
)
response = client.chat.completions.create(
model="claude-sonnet-4.6",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is machine learning?"}
]
)
print(response.choices[0].message.content)When using the OpenAI SDK, set
base_url to https://api.llmsrelay.com/v1 (with /v1).TypeScript (OpenAI SDK)
OpenAI SDK for TypeScripttypescript
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.llmsrelay.com/v1",
});
const response = await client.chat.completions.create({
model: "claude-sonnet-4.6",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);Important Compatibility Notes
- Use
Authorization: Bearer YOUR_API_KEYand the/v1suffix. This route is not the same as the native Anthropic-format endpoint. - System and developer instructions may be treated as one combined top-level instruction rather than as fully independent turns.
- OpenAI-specific fields that are not part of Claude's native behavior may be ignored. Do not assume every OpenAI-only knob changes model behavior.
- For tool calling, you should not rely on strict schema guarantees just because your OpenAI client exposes a strict mode toggle.
- If a feature feels awkward to express through Chat Completions, switch to the native
/v1/messagesAPI instead of fighting the compatibility layer.
A practical rule: use OpenAI compatibility for migration and tooling convenience, and use the native Messages API when you want the cleanest Claude-specific integration path.