The OpenAI-Compatible API: Why It Became the Standard
The accidental standard
When OpenAI released their Chat Completions API in 2023, they didn't set out to create an industry standard. They just built a clean, simple API for their own models. But the format was so well-designed that every other LLM provider adopted it.
Today, the OpenAI-compatible API format is the universal interface for LLMs. Every major provider — Anthropic, Google, Mistral, DeepSeek, Cohere, xAI — supports it. And tools like LangChain, LlamaIndex, and Vercel AI SDK all consume it natively.
What makes it OpenAI-compatible
An OpenAI-compatible API implements the same request/response format:
Request format
POST /v1/chat/completions
Authorization: Bearer <api-key>
Content-Type: application/json
{
"model": "gpt-5.6",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is 2+2?"}
],
"temperature": 0.7,
"max_tokens": 100,
"stream": false
}Response format
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1699999999,
"model": "gpt-5.6",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "2 + 2 = 4"
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 8,
"total_tokens": 28
}
}Streaming format (SSE)
data: {"choices":[{"delta":{"content":"2"}}]}
data: {"choices":[{"delta":{"content":" + "}}]}
data: {"choices":[{"delta":{"content":"2 = 4"}}]}
data: [DONE]Any API that follows these formats is "OpenAI-compatible."
Why it won
1. Simplicity
The format is minimal. One endpoint, one request shape, one response shape. No GraphQL complexity, no SOAP envelopes, no custom auth schemes.
2. Ecosystem
Because OpenAI was first, the entire AI tooling ecosystem built around their format:
- LangChain — uses OpenAI format natively
- Vercel AI SDK — OpenAI format by default
- OpenAI Python SDK — the most installed AI library on PyPI
- curl — works with any HTTP client
3. Provider neutrality
Providers realized that supporting the OpenAI format meant instant compatibility with the entire ecosystem. Instead of asking developers to learn a new API, they just implement the OpenAI format and developers can switch by changing one URL.
4. Drop-in replacement
# Before: using OpenAI directly
client = OpenAI(api_key="sk-...", base_url="https://api.openai.com/v1")
# After: using Riven (just change the base_url)
client = OpenAI(api_key="rvn_...", base_url="https://api.rivenai.io/v1")One line changes. That's the power of a standard.
Using the OpenAI-compatible API with Riven
Riven implements the full OpenAI-compatible API specification with 75+ models:
Python SDK
from openai import OpenAI
client = OpenAI(
api_key="rvn_...",
base_url="https://api.rivenai.io/v1"
)
# Use any model — same code, different model name
response = client.chat.completions.create(
model="gpt-5.6",
messages=[{"role": "user", "content": "Hello!"}]
)
# Switch to Claude
response = client.chat.completions.create(
model="claude-opus-5",
messages=[{"role": "user", "content": "Hello!"}]
)
# Switch to DeepSeek
response = client.chat.completions.create(
model="deepseek-v3",
messages=[{"role": "user", "content": "Hello!"}]
)JavaScript/TypeScript
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "rvn_...",
baseURL: "https://api.rivenai.io/v1",
});
const response = await client.chat.completions.create({
model: "glm-5.2",
messages: [{ role: "user", content: "Hello!" }],
});curl
curl https://api.rivenai.io/v1/chat/completions \
-H "Authorization: Bearer rvn_..." \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6",
"messages": [{"role": "user", "content": "Hello!"}],
"max_tokens": 100
}'LangChain
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-5.6",
api_key="rvn_...",
base_url="https://api.rivenai.io/v1"
)
response = llm.invoke("What is the capital of France?")Beyond chat completions
The OpenAI-compatible format has expanded beyond just chat:
Models listing
GET /v1/models
# Response
{
"data": [
{"id": "gpt-5.6", "object": "model"},
{"id": "claude-opus-5", "object": "model"},
{"id": "glm-5.2", "object": "model"},
...
]
}Embeddings
POST /v1/embeddings
{
"model": "text-embedding-3-large",
"input": "The quick brown fox"
}Function calling
{
"model": "gpt-5.6",
"messages": [...],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"}
}
}
}
}]
}Vision
{
"model": "gpt-5.6",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What's in this image?"},
{"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}}
]
}]
}Why use Riven instead of going direct
You could call OpenAI, Anthropic, and DeepSeek directly. Why use a gateway?
- One key, one bill — No separate accounts, no separate billing
- Switch models instantly — Change one parameter, not your SDK config
- Automatic failover — If OpenAI is down, retry with Claude
- Unified usage analytics — See all your AI spend in one dashboard
- Rate limiting and budgets — Per-key limits across all providers
- Self-hosted option — Route to your own GPUs for cost savings
- Compliance logging — Full audit trail for SOC 2 / HIPAA
Conclusion
The OpenAI-compatible API won because it's simple, well-designed, and came first. By using a gateway like Riven that implements this standard across 75+ models, you get provider neutrality, cost optimization, and operational controls — all while keeping your application code clean and portable.
Start free on Riven — one key, 75+ models, OpenAI-compatible API.