Skip to navigation
Native Mode

OpenAI (Native Mode)

Use the OpenAI SDK with Enterprise Router

Setup

Install the OpenAI SDK:

pip install openai

Configure the client to point at your gateway:

from openai import OpenAI
client = OpenAI(
api_key="sk-proxy-YOUR_KEY_HERE",
base_url="https://api.enterpriserouter.com/openai/v1"
)

That’s it. Use the client exactly as you would with OpenAI directly.

Basic chat completion

response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing in one paragraph."}
]
)
print(response.choices[0].message.content)

Streaming

stream = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Write a haiku about APIs."}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")

Function calling

import json
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"]
}
}
}
]
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "What's the weather in Tokyo?"}],
tools=tools,
tool_choice="auto"
)
tool_call = response.choices[0].message.tool_calls[0]
print(f"Function: {tool_call.function.name}")
print(f"Arguments: {tool_call.function.arguments}")

TypeScript

import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-proxy-YOUR_KEY_HERE",
baseURL: "https://api.enterpriserouter.com/openai/v1",
});
const response = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);

Streaming (TypeScript)

const stream = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Write a haiku about APIs." }],
stream: true,
});
for await (const chunk of stream) {
const content = chunk.choices[0]?.delta?.content;
if (content) process.stdout.write(content);
}

Supported models

All OpenAI models work through native mode, including:

  • gpt-4o, gpt-4o-mini
  • gpt-5.4, gpt-5.4-mini, gpt-5.4-nano
  • o3, o3-mini, o4-mini

Any new model OpenAI releases will work automatically — the gateway proxies requests without modification.