An OpenAI API proxy acts as an intermediary between your application and AI model providers, allowing you to route requests through a single endpoint while accessing multiple models. This guide walks through everything you need to know about setting up and using an OpenAI API proxy with Bring AI — from basic curl commands to advanced configurations like streaming, function calling, and model routing.
What Is an OpenAI API Proxy?
An OpenAI API proxy is a server or service that accepts requests in the OpenAI API format (/v1/chat/completions, /v1/completions, /v1/embeddings) and forwards them to one or more backend AI model providers. The proxy translates between the OpenAI API format and the backend provider’s native format, so your application code only needs to know the OpenAI SDK.
Key characteristics of a good OpenAI API proxy:
- OpenAI SDK compatibility: Your existing
openaiPython or Node.js code works without modification. - Multi-model routing: Access GPT, Claude, Gemini, DeepSeek, GLM, and more from one endpoint.
- Transparent streaming: Server-sent events (SSE) stream through without buffering delays.
- Function calling support: Tool use and function calling work across all compatible models.
- Low overhead: The proxy should add minimal latency. Bring AI adds <200ms.
Why Use an OpenAI API Proxy?
1. Avoid Vendor Lock-In
When you hardcode the OpenAI SDK with OpenAI’s API key, switching to Claude or Gemini requires rewriting your application. With a proxy, you change one parameter — the model name — and everything else stays the same.
2. Access 200+ Models Through One Integration
Instead of integrating the OpenAI SDK, Anthropic SDK, Google AI SDK, and DeepSeek SDK separately, you integrate once with the proxy and get access to all models. Bring AI provides 200+ models through a single API key.
3. Unified Billing and Monitoring
A proxy consolidates all AI API usage into a single bill and dashboard. Track spending across all models, set spending caps, and monitor usage from one place.
4. Built-in Failover and Load Balancing
If one provider goes down, the proxy can automatically failover to another. Bring AI supports configurable failover chains — if GPT-4o is unavailable, route to Claude Sonnet automatically.
5. Global Accessibility
Some AI providers have regional restrictions or payment limitations. Bring AI supports QRIS, crypto, and card payments, making it accessible to developers worldwide.
How to Set Up Bring AI as an OpenAI Proxy
Setting up Bring AI as your OpenAI API proxy takes less than 5 minutes. You’ll need an Bring AI API key — sign up at bring.buatjalan.xyz.
Step 1: Get Your API Key
After registering at Bring AI, generate an API key from the dashboard. Save it securely — you’ll use it as your OPENAI_API_KEY.
Step 2: Using curl
The simplest way to test the proxy is with curl:
curl https://bring.buatjalan.xyz/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer bring-your-api-key" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
"max_tokens": 100
}'
To use a different model, just change the model field:
# Use Claude instead of GPT
curl https://bring.buatjalan.xyz/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer bring-your-api-key" \
-d '{
"model": "claude-3-5-sonnet",
"messages": [
{"role": "user", "content": "Write a Python function to check if a number is prime."}
]
}'
Step 3: Using Python (OpenAI SDK)
Bring AI is fully compatible with the official OpenAI Python SDK. Just change the base_url and api_key:
from openai import OpenAI
# Point the OpenAI SDK at Bring AI
client = OpenAI(
base_url="https://bring.buatjalan.xyz/v1",
api_key="bring-your-api-key",
)
# Use any model — GPT-4o, Claude, Gemini, DeepSeek, etc.
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a senior software engineer."},
{"role": "user", "content": "Explain async/await in Python with an example."},
],
max_tokens=500,
)
print(response.choices[0].message.content)
Switching to Claude requires changing only the model name:
# Same code, different model
response = client.chat.completions.create(
model="claude-3-5-sonnet",
messages=[
{"role": "system", "content": "You are a senior software engineer."},
{"role": "user", "content": "Explain async/await in Python with an example."},
],
max_tokens=500,
)
Step 4: Using Node.js (OpenAI SDK)
The setup is equally simple in Node.js:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://bring.buatjalan.xyz/v1",
apiKey: "bring-your-api-key",
});
async function chat(message: string, model: string = "gpt-4o") {
const response = await client.chat.completions.create({
model: model,
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: message },
],
max_tokens: 500,
});
return response.choices[0].message.content;
}
// Use GPT-4o
const gptResponse = await chat("Explain React Server Components.");
// Use Claude — same function, different model
const claudeResponse = await chat("Explain React Server Components.", "claude-3-5-sonnet");
// Use DeepSeek for budget-friendly coding
const deepseekResponse = await chat("Write a Rust HTTP server.", "deepseek-v3");
Step 5: Using Environment Variables
For production applications, store your configuration in environment variables:
# .env
OPENAI_API_KEY=bring-your-api-key
OPENAI_BASE_URL=https://bring.buatjalan.xyz/v1
# Python — automatically reads from environment
from openai import OpenAI
client = OpenAI() # Reads OPENAI_API_KEY and OPENAI_BASE_URL from env
// Node.js — use dotenv
import "dotenv/config";
import OpenAI from "openai";
const client = new OpenAI(); // Reads OPENAI_API_KEY and OPENAI_BASE_URL
Advanced Configuration
Streaming Responses
Streaming is essential for responsive chat applications. Bring AI fully supports server-sent events (SSE) streaming with sub-200ms overhead:
stream = client.chat.completions.create(
model="claude-3-5-sonnet",
messages=[{"role": "user", "content": "Write a short story about a robot."}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="", flush=True)
const stream = await client.chat.completions.create({
model: "claude-3-5-sonnet",
messages: [{ role: "user", content: "Write a short story about a robot." }],
stream: true,
});
for await (const chunk of stream) {
const content = chunk.choices[0]?.delta?.content;
if (content) process.stdout.write(content);
}
Function Calling
Function calling (tool use) works across all models that support it. Bring AI transparently translates function calling formats between OpenAI, Anthropic, and other providers:
import json
from openai import OpenAI
client = OpenAI(
base_url="https://bring.buatjalan.xyz/v1",
api_key="bring-your-api-key",
)
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City and state, e.g., 'San Francisco, CA'",
}
},
"required": ["location"],
},
},
}
]
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "What's the weather in Tokyo?"}],
tools=tools,
)
# The model will return a function call
tool_call = response.choices[0].message.tool_calls[0]
print(f"Model called: {tool_call.function.name}")
print(f"Arguments: {tool_call.function.arguments}")
# Same function calling works with Claude
response = client.chat.completions.create(
model="claude-3-5-sonnet",
messages=[{"role": "user", "content": "What's the weather in Tokyo?"}],
tools=tools,
)
Model Routing
Bring AI supports model routing — automatically selecting the best model based on your criteria. Configure routing rules via the API:
# Set up a routing rule: use DeepSeek for coding, GPT-4o for general
curl -X POST https://bring.buatjalan.xyz/v1/routing \
-H "Authorization: Bearer bring-your-api-key" \
-d '{
"rules": [
{
"condition": {"category": "coding"},
"model": "deepseek-v3"
},
{
"condition": {"category": "general"},
"model": "gpt-4o"
},
{
"condition": {"category": "long_context"},
"model": "claude-3-5-sonnet"
}
]
}'
Or use model aliases in your API calls:
# Use an alias that routes to the cheapest available model
response = client.chat.completions.create(
model="auto-cheapest", # Bring AI picks the cheapest model
messages=[{"role": "user", "content": "Summarize this article."}],
)
Using the Anthropic API Format
Bring AI also supports the native Anthropic API format (/v1/messages), so you can use the Anthropic SDK directly:
import anthropic
client = anthropic.Anthropic(
base_url="https://bring.buatjalan.xyz",
api_key="bring-your-api-key",
)
# Use the Anthropic SDK to call any model, including GPT
response = client.messages.create(
model="gpt-4o", # GPT through the Anthropic SDK!
max_tokens=500,
messages=[{"role": "user", "content": "Hello, how are you?"}],
)
print(response.content[0].text)
Bring AI supports three API formats: /v1/chat/completions (OpenAI), /v1/messages (Anthropic), and /v1/responses (OpenAI Responses API). See the docs for full API reference.
Comparison with Other OpenAI API Proxies
| Feature | Bring AI | OpenRouter | LiteLLM (self-hosted) | Portkey |
|---|---|---|---|---|
| Models | 200+ | 500+ | 100+ | 200+ |
| Backend | Go | Node.js | Python | TypeScript |
| OpenAI SDK compatible | ✅ | ✅ | ✅ | ✅ |
| Anthropic SDK compatible | ✅ | ❌ | ❌ | ✅ |
| Streaming | ✅ (<200ms overhead) | ✅ | ✅ | ✅ |
| Function calling | ✅ | ✅ | ✅ | ✅ |
| Self-host option | ❌ (managed) | ❌ | ✅ | ✅ |
| Payment options | QRIS + crypto + card | Card | N/A | Card |
| Pricing | Pay-per-use USD | Markup on provider | Free (self-hosted) | Subscription + usage |
Bring AI’s key advantages are its Go-based backend (lower latency and memory footprint than Python/Node.js proxies), dual SDK compatibility (both OpenAI and Anthropic SDKs work), and flexible payment options (QRIS, crypto, card).
FAQ
What is an OpenAI API proxy?
An OpenAI API proxy is a service that accepts requests in the OpenAI API format and routes them to one or more AI model providers. It lets you use the OpenAI SDK to access models from Anthropic, Google, DeepSeek, and other providers without changing your code.
Is using an OpenAI API proxy secure?
Yes, when using a reputable proxy like Bring AI. Your API key is stored encrypted, all traffic uses HTTPS, and you can set spending caps and IP allowlists. See our AI API security best practices guide for details.
Does the OpenAI SDK work with Bring AI without code changes?
Almost — you only need to change the base_url to https://bring.buatjalan.xyz/v1 and use your Bring AI API key. All other code (chat completions, streaming, function calling, embeddings) works identically.
Can I use the Anthropic SDK with Bring AI?
Yes. Bring AI supports the native Anthropic API format (/v1/messages). You can use the Anthropic SDK to call any model available on Bring AI, including GPT-4o and Gemini. Learn more about using Claude with the OpenAI SDK and vice versa.
How much latency does the proxy add?
Bring AI adds less than 200ms of routing overhead. The Go-based backend is optimized for low-latency proxying with minimal memory usage. For most applications, the proxy overhead is imperceptible compared to model inference time.
Does streaming work through the proxy?
Yes. Bring AI supports full server-sent events (SSE) streaming. Tokens are forwarded to your application as they arrive from the model provider, with no buffering delay. Streaming works with all compatible models across all SDK formats.
What models are available through the Bring AI OpenAI proxy?
Bring AI provides access to 200+ models including GPT-4o, Claude 3.5 Sonnet/Haiku, Gemini 2.0 Flash/Pro, DeepSeek V3, GLM-4, Kimi, Llama 3.3, and many more. See the full model list for details.
How much does Bring AI cost?
Bring AI uses pay-per-use USD pricing — you only pay for the tokens you consume, with no monthly subscription. Prices are competitive with direct provider pricing. See the pricing page for details.
Conclusion
Setting up an OpenAI API proxy with Bring AI is straightforward: change your base_url, use your Bring AI API key, and you instantly get access to 200+ AI models through the OpenAI SDK you already know. With sub-200ms routing overhead, full streaming support, function calling across models, and flexible payment options (QRIS, crypto, card), Bring AI is the simplest way to build multi-model AI applications.
Ready to get started? Sign up at bring.buatjalan.xyz and explore the documentation for more details. To learn more about AI API gateways in general, read our introduction guide.
Related articles: