
POST /v1/chat/completions · OpenAI SDK
200 · 1,180 tokens · $0.004
new OpenAI({ apiKey: OPENAI_KEY,}).chat.completions.create({ model: 'gpt-5.4',})new OpenAI({ baseURL: 'https://api.inworld.ai/v1', apiKey: INWORLD_KEY,}).chat.completions.create({ model: 'openai/gpt-5.4', models: ['anthropic/claude-sonnet-4-6'],})new OpenAI({ apiKey: OPENAI_KEY,}).chat.completions.create({ model: 'gpt-5.4',})new OpenAI({ baseURL: 'https://api.inworld.ai/v1', apiKey: INWORLD_KEY,}).chat.completions.create({ model: 'openai/gpt-5.4', models: ['anthropic/claude-sonnet-4-6'],})import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.inworld.ai/v1',
apiKey: process.env.INWORLD_API_KEY,
});
// Use any model through the same endpoint
const completion = await client.chat.completions.create({
model: 'openai/gpt-5.4',
messages: [{ role: 'user', content: 'Hello' }],
stream: true,
});
for await (const chunk of completion) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}
// Need a fallback? Add one field.
const safe = await client.chat.completions.create({
model: 'openai/gpt-5.4',
messages: [{ role: 'user', content: 'Hello' }],
// @ts-expect-error extra_body
extra_body: {
models: ['anthropic/claude-sonnet-4-6', 'google/gemini-3.1-pro'],
},
});