OpenAI SDK
Call Chat Completions, Responses, and Image generation with the official OpenAI SDK.
Set the official OpenAI SDK's baseURL (base_url in Python) to https://api.outerlane.app/v1.
const client = new OpenAI({
- apiKey: process.env.OPENAI_API_KEY,
+ apiKey: process.env.OUTERLANE_API_KEY,
+ baseURL: "https://api.outerlane.app/v1",
});Configure the client
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.OUTERLANE_API_KEY,
baseURL: "https://api.outerlane.app/v1",
});Chat Completions
const response = await client.chat.completions.create({
model: "openai/gpt-6.1-sol",
reasoning_effort: "medium",
messages: [{ role: "user", content: "Explain the difference between Pick and Omit in TypeScript." }],
});
console.log(response.choices[0]?.message.content);Change the model ID to use another provider with the same code. For example, try anthropic/claude-sonnet-5-5 or google/gemini-4-neon.
Streaming
Set stream_options: { include_usage: true } to receive token usage at the end of the stream.
const stream = await client.chat.completions.create({
model: "anthropic/claude-sonnet-5-5",
stream: true,
stream_options: { include_usage: true },
messages: [{ role: "user", content: "Summarize this in three lines." }],
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
if (chunk.usage) console.log("\n", chunk.usage);
}Responses API
The Responses API is stateless. Include all prior turns in input to continue a conversation. See the Responses API reference for limitations.
const response = await client.responses.create({
model: "openai/gpt-6.1-sol",
instructions: "Answer concisely.",
input: "What should I know before using the Responses API?",
reasoning: { effort: "low" },
store: false,
});
console.log(response.output_text);Image generation
const image = await client.images.generate({
model: "openai/gpt-image-2",
prompt: "A glass cube on a white studio background, with soft natural light",
size: "1024x1024",
});
const base64 = image.data?.[0]?.b64_json;Notes
- Legacy
functionsandfunction_call, as well asaudio,prediction, andweb_search_options, are unsupported. Usetoolsto define functions. See Tool calling for the complete flow. - See Chat Completions, Responses API, and Image generation for request and response fields.