One of the most common pain points for AI developers is managing multiple SDKs for different model providers. OpenAI uses the openai package. Anthropic uses the anthropic package. Google uses google-generativeai. Each has its own API format, authentication method, and feature set. This fragmentation makes codebases harder to maintain and slows down development.
The solution? A unified API gateway that translates between SDK formats. With Bring AI, you can use the OpenAI SDK to call Claude, or the Anthropic SDK to call GPT. This guide shows you exactly how.
The Problem: Different SDKs for Different Models
Consider a typical scenario: you’re building an application that uses GPT-4o for general chat and Claude 3.5 Sonnet for coding tasks. Without a unified gateway, your code looks like this:
# Without a gateway — two SDKs, two formats, two auth methods
import openai
import anthropic
openai_client = openai.OpenAI(api_key="sk-... OpenAI key")
anthropic_client = anthropic.Anthropic(api_key="sk-ant-... Anthropic key")
# OpenAI format
gpt_response = openai_client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
)
# Anthropic format — different structure!
claude_response = anthropic_client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}],
)
print(claude_response.content[0].text) # Different response structure too
The issues are clear:
- Two API keys to manage and secure.
- Two API formats —
chat.completions.createvsmessages.create. - Different request structures — OpenAI uses
max_tokensas optional, Anthropic requires it. - Different response structures —
response.choices[0].message.contentvsresponse.content[0].text. - Different streaming APIs — different event formats, different chunk structures.
- Different function calling formats — OpenAI uses
toolsarray, Anthropic usestoolswith different schema.
This complexity multiplies when you add Gemini, DeepSeek, or other providers.
The Solution: Unified API Gateway
A unified API gateway like Bring AI solves this by providing a single endpoint that accepts requests in multiple formats and translates them to each provider’s native API. Bring AI supports three API formats:
/v1/chat/completions— OpenAI Chat Completions API format/v1/messages— Anthropic Messages API format/v1/responses— OpenAI Responses API format
This means you can:
- Use the OpenAI SDK to call Claude, Gemini, DeepSeek, or any of 200+ models.
- Use the Anthropic SDK to call GPT-4o, Gemini, or any other model.
- Switch models by changing a single parameter — no code rewrites.
Step-by-Step Guide: Using Claude with the OpenAI SDK
Prerequisites
- An Bring AI API key (sign up at bring.buatjalan.xyz)
- The
openaiPython package (pip install openai) or Node.js package (npm install openai)
Python Example
from openai import OpenAI
# Initialize the OpenAI SDK with Bring AI as the base URL
client = OpenAI(
base_url="https://bring.buatjalan.xyz/v1",
api_key="bring-your-api-key",
)
# Call Claude using the OpenAI SDK — it just works!
response = client.chat.completions.create(
model="claude-3-5-sonnet",
messages=[
{"role": "system", "content": "You are an expert Python developer."},
{"role": "user", "content": "Write a decorator that caches function results with a TTL."},
],
max_tokens=1024,
)
print(response.choices[0].message.content)
That’s it. The OpenAI SDK, pointed at Bring AI, can call Claude seamlessly. The response structure is identical to an OpenAI response — response.choices[0].message.content — so your existing code works without changes.
Node.js Example
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://bring.buatjalan.xyz/v1",
apiKey: "bring-your-api-key",
});
async function callClaude(prompt) {
const response = await client.chat.completions.create({
model: "claude-3-5-sonnet",
messages: [
{ role: "system", content: "You are an expert JavaScript developer." },
{ role: "user", content: prompt },
],
max_tokens: 1024,
});
return response.choices[0].message.content;
}
const result = await callClaude(
"Write a debounce function with TypeScript types."
);
console.log(result);
Switching Between Models
The real power of a unified gateway is how easily you can switch models:
models = {
"fast": "claude-3-5-haiku", # Fast and cheap
"smart": "claude-3-5-sonnet", # High quality
"budget": "gemini-2.0-flash", # Cheapest
"openai": "gpt-4o", # OpenAI's best
}
def chat(message: str, tier: str = "smart") -> str:
"""Chat with different models based on tier."""
response = client.chat.completions.create(
model=models[tier],
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": message},
],
)
return response.choices[0].message.content
# Use Claude for complex reasoning
answer = chat("Explain how transformers work.", tier="smart")
# Use Gemini Flash for simple, cheap tasks
answer = chat("What is 2+2?", tier="budget")
# Use GPT-4o when you need OpenAI's model
answer = chat("Generate an image prompt.", tier="openai")
Using the Anthropic SDK to Call GPT
The reverse also works — you can use the Anthropic SDK to call GPT-4o or any other model:
import anthropic
# Initialize the Anthropic SDK with Bring AI as the base URL
client = anthropic.Anthropic(
base_url="https://bring.buatjalan.xyz",
api_key="bring-your-api-key",
)
# Call GPT-4o using the Anthropic SDK!
response = client.messages.create(
model="gpt-4o",
max_tokens=1024,
messages=[
{"role": "user", "content": "Write a haiku about programming."}
],
)
print(response.content[0].text)
This is particularly useful for teams that have built their infrastructure around the Anthropic SDK but want to access other models without adding a new SDK dependency.
Node.js with Anthropic SDK
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://bring.buatjalan.xyz",
apiKey: "bring-your-api-key",
});
async function callGPT(prompt) {
const response = await client.messages.create({
model: "gpt-4o",
max_tokens: 1024,
messages: [{ role: "user", content: prompt }],
});
return response.content[0].text;
}
const result = await callGPT("Explain closures in JavaScript.");
console.log(result);
Streaming Claude Responses
Streaming is essential for responsive chat applications. Bring AI supports full SSE streaming for Claude and all other models through the OpenAI SDK:
stream = client.chat.completions.create(
model="claude-3-5-sonnet",
messages=[
{"role": "user", "content": "Write a step-by-step guide to deploying a Go app."}
],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="", flush=True)
The streaming format is identical to OpenAI’s streaming format — chunk.choices[0].delta.content — so any streaming code you’ve written for OpenAI works with Claude through Bring AI.
Streaming with the Anthropic SDK
# Stream GPT-4o through the Anthropic SDK
with client.messages.stream(
model="gpt-4o",
max_tokens=1024,
messages=[{"role": "user", "content": "Explain async programming."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
Node.js Streaming
// Stream Claude through the OpenAI SDK in Node.js
const stream = await client.chat.completions.create({
model: "claude-3-5-sonnet",
messages: [{ role: "user", content: "Write a poem about the ocean." }],
stream: true,
});
for await (const chunk of stream) {
const content = chunk.choices[0]?.delta?.content;
if (content) process.stdout.write(content);
}
Function Calling Across Models
Function calling (tool use) is one of the most powerful features of modern LLMs. However, OpenAI and Anthropic have different function calling formats. Bring AI translates between them automatically.
Using OpenAI SDK Format with Claude
import json
from openai import OpenAI
client = OpenAI(
base_url="https://bring.buatjalan.xyz/v1",
api_key="bring-your-api-key",
)
# Define tools in OpenAI format
tools = [
{
"type": "function",
"function": {
"name": "get_stock_price",
"description": "Get the current stock price for a given ticker symbol",
"parameters": {
"type": "object",
"properties": {
"symbol": {
"type": "string",
"description": "Stock ticker symbol, e.g., AAPL"
}
},
"required": ["symbol"]
}
}
}
]
# Use Claude with OpenAI-format function calling
response = client.chat.completions.create(
model="claude-3-5-sonnet",
messages=[
{"role": "user", "content": "What's the price of AAPL stock?"}
],
tools=tools,
tool_choice="auto",
)
# Handle the function call
message = response.choices[0].message
if message.tool_calls:
tool_call = message.tool_calls[0]
args = json.loads(tool_call.function.arguments)
print(f"Claude wants to call: {tool_call.function.name}({args})")
# Execute the function and continue the conversation
# ... your function implementation ...
# Send the function result back
response = client.chat.completions.create(
model="claude-3-5-sonnet",
messages=[
{"role": "user", "content": "What's the price of AAPL stock?"},
message,
{
"role": "tool",
"tool_call_id": tool_call.id,
"content": json.dumps({"symbol": "AAPL", "price": 175.43}),
},
],
tools=tools,
)
print(response.choices[0].message.content)
The same tools array works with GPT-4o, Claude, Gemini, and any other model that supports function calling. Bring AI translates the tool definitions and responses between providers’ native formats.
Multi-Step Function Calling
def chat_with_tools(messages, tools, model="claude-3-5-sonnet"):
"""Run a chat conversation with function calling."""
while True:
response = client.chat.completions.create(
model=model,
messages=messages,
tools=tools,
tool_choice="auto",
)
message = response.choices[0].message
messages.append(message)
if not message.tool_calls:
return message.content
for tool_call in message.tool_calls:
# Execute each function call
result = execute_function(
tool_call.function.name,
json.loads(tool_call.function.arguments),
)
messages.append({
"role": "tool",
"tool_call_id": tool_call.id,
"content": json.dumps(result),
})
# Works with Claude, GPT-4o, or any model — just change the model parameter
answer = chat_with_tools(conversation, tools, model="claude-3-5-sonnet")
answer = chat_with_tools(conversation, tools, model="gpt-4o")
Performance Considerations
Bring AI adds less than 200ms of routing overhead to each request. This overhead includes:
- API format translation (OpenAI ↔ Anthropic)
- Authentication and key management
- Rate limiting and spending cap checks
- Logging and usage tracking
For most applications, this overhead is imperceptible compared to model inference time (which typically ranges from 500ms to 30s depending on the model and prompt length).
Latency Tips
- Use streaming: Streaming delivers the first token in 200-500ms, vs. waiting for the full response.
- Choose faster models: Claude 3.5 Haiku and Gemini 2.0 Flash are significantly faster than Sonnet or GPT-4o.
- Minimize prompt length: Shorter prompts = faster processing. Use prompt caching for repeated system prompts.
- Use connection pooling: Reuse HTTP connections to avoid TCP handshake overhead.
FAQ
Can I really use the OpenAI SDK to call Claude?
Yes. Bring AI is fully compatible with the OpenAI SDK. Point the SDK at https://bring.buatjalan.xyz/v1, use your Bring AI API key, and set the model to claude-3-5-sonnet. Everything else — request format, response structure, streaming, function calling — works identically to calling GPT.
Does function calling work with Claude through the OpenAI SDK?
Yes. Define your tools in OpenAI format, and Bring AI translates them to Anthropic’s native tool format. The model’s response is translated back to OpenAI format, so your function-calling code works without changes.
Can I use the Anthropic SDK to call GPT-4o?
Yes. Bring AI supports the Anthropic Messages API format (/v1/messages). Point the Anthropic SDK at https://bring.buatjalan.xyz and set the model to gpt-4o. The response is returned in Anthropic format.
How much latency does the API gateway add?
Bring AI adds less than 200ms of routing overhead. The Go-based backend is optimized for low-latency proxying. For streaming requests, the first token arrives with minimal additional delay.
Do I need separate API keys for different models?
No. One Bring AI API key gives you access to all 200+ models. You can also create separate keys for different applications or environments with individual spending caps.
Is using Claude through the OpenAI SDK exactly the same as using it directly?
The request and response formats are identical to OpenAI’s. However, model-specific features (like Claude’s prompt caching or GPT-4o’s vision capabilities) may require provider-specific parameters. Bring AI passes through all provider-specific parameters transparently.
What models can I access through Bring AI?
Bring AI provides access to 200+ models including Claude 3.5 Sonnet/Haiku, GPT-4o/4o-mini, Gemini 2.0 Flash/Pro, DeepSeek V3, GLM-4, Kimi, Llama 3.3, and many more. See the models page for the full list.
How do I get started?
- Sign up at bring.buatjalan.xyz
- Generate an API key from the dashboard
- Set your SDK’s
base_urltohttps://bring.buatjalan.xyz/v1and use your Bring AI key - Start calling any model — it’s that simple
See the docs for full API reference and more examples. Learn more about AI API gateways and check pricing for cost details.
Conclusion
Managing multiple SDKs for different AI model providers is a thing of the past. With a unified API gateway like Bring AI, you can use the OpenAI SDK to call Claude, the Anthropic SDK to call GPT, or any combination you prefer. The key insight is that a good gateway translates between API formats so you can use whichever SDK you’re most comfortable with, with whichever model best suits your task.
This approach simplifies your codebase, reduces dependency management overhead, and makes it trivial to switch models as new ones are released. Get started with Bring AI today and unify your AI API access.
Related articles: