IntegrationsSDKs
OpenAI SDK
As a drop-in replacement for OpenAI API with full compatibility and enhanced features.
OpenAI SDK Integration
The gateway is fully compatible with official OpenAI SDKs. Just point the base URL to your gateway.
Python SDK
Installation
pip install openaiConfiguration
from openai import OpenAI
client = OpenAI(
base_url="https://viprouter.com/v1",
api_key="your-api-key"
)Usage
# Chat completion
response = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
# Streaming
stream = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Count to 10"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")Node.js SDK
Installation
npm install openaiConfiguration
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://viprouter.com/v1",
apiKey: "your-api-key",
});Usage
// Chat completion
const response = await client.chat.completions.create({
model: "openai/gpt-4o-mini",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);
// Streaming
const stream = await client.chat.completions.create({
model: "openai/gpt-4o-mini",
messages: [{ role: "user", content: "Count to 10" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
}Model Selection
Use the provider/model format to select any configured provider:
# OpenAI
response = client.chat.completions.create(
model="openai/gpt-4o",
messages=[...]
)
# Anthropic
response = client.chat.completions.create(
model="anthropic/claude-sonnet-4-20250514",
messages=[...]
)
# Google
response = client.chat.completions.create(
model="gemini-2.5-pro",
messages=[...]
)Environment Variables
export OPENAI_BASE_URL=https://viprouter.com/v1
export OPENAI_API_KEY=your-api-keyNext Steps
- Quickstart - More examples
- Streaming - Real-time responses
