OpenAI SDK (JS) with idapt
The canonical three-line diff: baseURL, key, model id.
- 1
Install
bashnpm i openai - 2
Point it at idapt
tsimport OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://idapt.app/api/openai/v1", apiKey: process.env.IDAPT_API_KEY, }); const reply = await client.chat.completions.create({ model: "deepseek/deepseek-v4-flash", messages: [{ role: "user", content: "Three facts about ravens." }], }); - 3
Streaming
tsconst stream = await client.chat.completions.create({ model: "deepseek/deepseek-v4-flash", messages: [{ role: "user", content: "Stream a haiku." }], stream: true, }); for await (const part of stream) { process.stdout.write(part.choices[0]?.delta?.content ?? ""); }
GOOD TO KNOW
API keys and scopesOpenAI-compatible API referenceOpenRouter-compatible API referenceRate limits and errors