Skip to main content

Variable: openai

const openai: (modelId, config?) => ModelConfig & object

Defined in: packages/core/src/providers/factories.ts:43

OpenAI. The API key defaults to OPENAI_API_KEY.

Type Declaration​

models​

models: (config?) => Promise<ModelInfo[]>

List the OpenAI models the configured key can see, newest-first.

Parameters​

config?​

ProviderConfig

Returns​

Promise<ModelInfo[]>

Examples​

With reasoning

const bot = new Baleybot({
model: openai('gpt-5', {
baseUrl: 'https://api.custom.com/v1',
reasoning: { effort: 'high' }
})
});

With custom fetch (logging, proxy)

const bot = new Baleybot({
model: openai('gpt-5.6-luna', {
fetch: (url, init) => {
console.log('model request', url);
return globalThis.fetch(url, init);
}
})
});

Retries belong to the AI SDK: pass maxRetries where the call is made rather than wrapping fetch.