Skip to content
Home

OpenAI SDK

OdiRouter’s LLM API is OpenAI-compatible. Existing OpenAI SDK clients can call OdiRouter by setting the API key and Base URL.

RequirementValue
Python packageopenai
Node.js packageopenai
Base URLhttps://www.odirouter.ai/v1
API KeyOdiRouter API key
ModelAn OdiRouter LLM model ID
Окно терминала
pip install openai
npm install openai
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://www.odirouter.ai/v1",
)
response = client.chat.completions.create(
model="gpt-5.5",
messages=[
{"role": "user", "content": "Reply with a one-line integration test."}
],
)
print(response.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.ODIROUTER_API_KEY,
baseURL: "https://www.odirouter.ai/v1",
});
const response = await client.chat.completions.create({
model: "gpt-5.5",
messages: [
{ role: "user", content: "Reply with a one-line integration test." },
],
});
console.log(response.choices[0].message.content);
const stream = await client.chat.completions.create({
model: "gpt-5.5",
messages: [{ role: "user", content: "Stream three short bullets." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
SymptomFix
SDK calls OpenAI instead of OdiRouterConfirm base_url or baseURL is set to https://www.odirouter.ai/v1
401 or invalid keyUse an OdiRouter API key
Model not foundUse a model returned by GET https://www.odirouter.ai/v1/models
Browser build exposes keyMove the SDK call to a server route or backend process