Skip to content

OpenAI SDK

The official OpenAI libraries work unchanged. Set the base URL to https://api.inferray.com/v1 and use an Inferray key; every text model, including Claude and Gemini, then answers on chat.completions and responses.

JavaScript and TypeScript

npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.inferray.com/v1",
  apiKey: process.env.INFERRAY_API_KEY,
});

const completion = await client.chat.completions.create({
  model: "claude-sonnet-4-6",
  messages: [{ role: "user", content: "Hello" }],
});

Python

pip install openai
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.inferray.com/v1", api_key=os.environ["INFERRAY_API_KEY"])

completion = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Hello"}],
)

The async client, AsyncOpenAI, takes the same arguments.

Without changing code

The OpenAI SDKs read their base URL and key from the environment. An app that constructs new OpenAI() with no arguments can be pointed at Inferray from outside:

export OPENAI_BASE_URL="https://api.inferray.com/v1"
export OPENAI_API_KEY="inferray_..."

Then change the model names the app uses to Inferray model IDs.

What works

SDK methodInferray endpoint
chat.completions.create, .parse, .streamChat Completions
responses.create, .retrieve, .parseResponses
embeddings.createEmbeddings
images.generate, images.editImage generation, editing
audio.speech.create, audio.transcriptions.createSpeech, transcription
videos.create, .retrieve, .downloadContentVideo generation
moderations.createModeration
models.listModels

Not offered: the legacy completions endpoint, models.retrieve for a single model, files, fine-tuning, batches, assistants, vector stores, and realtime. A method the SDK has but Inferray doesn't answers 404 or 405.

Other languages

The official Go, Java, .NET and Ruby libraries, and community ones, take a base URL option too — option.WithBaseURL in Go, baseUrl in Java, Endpoint in .NET. Use https://api.inferray.com/v1.