
openai.chat.completions.create(model: 'openai/gpt-5.4')
200 · 820ms · $0.004 · logged
import OpenAI from 'openai';−const openai = new OpenAI();+const openai = new OpenAI({ baseURL: "https://api.inworld.ai/v1" });// every existing OpenAI call now routes through Inworld// streaming, tool use, structured output all unchanged
import OpenAI from 'openai';−const openai = new OpenAI();+const openai = new OpenAI({ baseURL: "https://api.inworld.ai/v1" });// every existing OpenAI call now routes through Inworld// streaming, tool use, structured output all unchanged
for await (const chunk of stream) {process.stdout.write(chunk.choices[0].delta.content ?? '');}// Same SSE shape as OpenAI. Your parser doesn't care// which provider is actually streaming the tokens.// Tool use? Structured output? Passes through too.
for await (const chunk of stream) {process.stdout.write(chunk.choices[0].delta.content ?? '');}// Same SSE shape as OpenAI. Your parser doesn't care// which provider is actually streaming the tokens.// Tool use? Structured output? Passes through too.
import OpenAI from 'openai';
// Change the base URL. That's it.
const openai = new OpenAI({
baseURL: 'https://api.inworld.ai/v1',
apiKey: process.env.INWORLD_API_KEY,
});
// Your existing code keeps working
const response = await openai.chat.completions.create({
model: 'openai/gpt-5.4',
messages: [{ role: 'user', content: 'Hello' }],
stream: true,
tools: [/* unchanged */],
});
for await (const chunk of response) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}
// Swap providers: change one string
const claude = await openai.chat.completions.create({
model: 'anthropic/claude-sonnet-4-6',
messages: [{ role: 'user', content: 'Hello' }],
});