OpenAI SDK
OpenAI SDK compatible API gateway
Point OpenAI SDK clients at Aiduct API to access GPT, Claude, image, video, audio, and embedding models through one base URL.
Use one base URL for OpenAI-shaped routes
Aiduct exposes OpenAI-compatible /v1 endpoints for chat completions, responses, images, audio, video, embeddings, and model catalog calls. Existing OpenAI SDK clients only need a baseURL and API key change.
Keep Claude Code separate when native Messages matters
OpenAI SDK clients should use the /v1 base URL. Claude Code should use the gateway root through ANTHROPIC_BASE_URL so it can call the native Messages route.
OpenAI SDK setup
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.AIDUCT_API_KEY,
baseURL: "https://api.aiduct.ai/v1",
});
const response = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Say hello in one sentence." }],
});