SDK Guides
OpenAI Node.js
Configure the OpenAI Node.js SDK to use Yaha Gateway.
Install the official SDK:
npm install openaiBasic usage
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://gateway.yahagateway.io/v1",
apiKey: "yaha.YOUR_PROJECT_KEY",
});
const response = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Hello from Yaha" }],
});
console.log(response.choices[0]?.message?.content);Streaming
const stream = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Hello" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Environment variables
export OPENAI_BASE_URL="https://gateway.yahagateway.io/v1"
export OPENAI_API_KEY="yaha.YOUR_PROJECT_KEY"import OpenAI from "openai";
const client = new OpenAI(); // reads OPENAI_BASE_URL and OPENAI_API_KEYNotes
- Use your full
yaha.*key asapiKey, not an OpenAI provider key. - Pick a model on your project allowlist.
- For coding agents, see Integrations.
- For more languages and a reusable integration prompt, see Language examples.