OpenAI Node.js SDK
npm install openai
Before​
import OpenAI from 'openai';
const client = new OpenAI({ apiKey: 'sk-...' });
After​
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://gateway.autraceai.com/v1',
apiKey: 'aut_live_YOUR_KEY',
});
Full example​
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://gateway.autraceai.com/v1',
apiKey: process.env.AUTRACE_KEY,
});
const response = await client.chat.completions.create({
model: 'openai/gpt-5.5',
messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(response.choices[0].message.content);
Streaming​
const stream = await client.chat.completions.stream({
model: 'openai/gpt-5.5',
messages: [{ role: 'user', content: 'Write a haiku.' }],
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}