Prepare a server-side project
Install the SDK and set the key in the process environment. Keep .env files and credentials out of Git.
npm install openai
export ROUTARA_API_KEY="your-key"Run one chat completion
Save this as first-request.mjs and run node first-request.mjs. The model alibaba-qwen-turbo is an example; confirm it in the live catalog first.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.ROUTARA_API_KEY,
baseURL: "https://api.routara.ai/v1",
});
const response = await client.chat.completions.create({
model: "alibaba-qwen-turbo",
messages: [{ role: "user", content: "Reply with one short integration tip." }],
max_tokens: 64,
});
console.log(response.id, response.model, response.usage);
console.log(response.choices[0]?.message?.content);Move traffic gradually
Inspect the first response, usage, and account balance. Keep your existing provider configuration available while testing. A 401 points to key setup; a 403 to policy or account access; a billing error to trial eligibility or wallet balance.
Before you ship
- Run on the server, never in public JavaScript.
- Use one small request before changing production traffic.
- Check your account’s actual usage after the response.