Skip to content

OpenAI Provider

Set your OpenAI API key:

Terminal window
export OPENAI_API_KEY=sk-...

llmist will automatically discover and use OpenAI.

ModelAliasBest For
gpt-5gpt5Complex reasoning, coding
gpt-5-minigpt5-miniFast, cost-effective tasks
gpt-4-turbogpt4-turboBalanced performance
gpt-4ogpt4oMultimodal tasks
o3o3Advanced reasoning Reasoning
o4-minio4-miniFast reasoning Reasoning
o3-minio3-miniCompact reasoning
ModelDescription
dall-e-3High-quality image generation
dall-e-2Faster, lower cost
ModelDescription
tts-1Text-to-speech, standard quality
tts-1-hdText-to-speech, high quality
import { LLMist } from 'llmist';
const answer = await LLMist.createAgent()
.withModel('gpt5')
.askAndCollect('Explain quantum computing');

OpenAI’s o-series models (o3, o4-mini) and GPT-5 family support reasoning. llmist maps ReasoningEffort to OpenAI’s native reasoning.effort parameter:

EffortOpenAI Value
"none""none"
"low""low"
"medium""medium"
"high""high"
"maximum""xhigh"
const answer = await LLMist.createAgent()
.withModel('o3')
.withReasoning('high')
.askAndCollect('Prove that √2 is irrational.');

See the Reasoning Models guide for full details.

GPT-4o and GPT-5 models support image input:

import { LLMist, imageFromUrl } from 'llmist';
const answer = await LLMist.createAgent()
.withModel('gpt4o')
.askWithImage(
'What is in this image?',
imageFromUrl('https://example.com/photo.jpg')
)
.askAndCollect();
import { LLMist, OpenAIChatProvider } from 'llmist';
const client = new LLMist({
autoDiscoverProviders: false,
adapters: [
new OpenAIChatProvider({
apiKey: process.env.OPENAI_API_KEY,
baseUrl: 'https://api.openai.com/v1', // Custom endpoint
organization: 'org-xxx', // Optional org ID
}),
],
});

llmist automatically tracks token usage and costs:

for await (const event of agent.run()) {
if (event.type === 'llm_call_complete') {
console.log('Tokens:', event.usage);
console.log('Cost:', event.cost);
}
}

OpenAI has rate limits. Use retry configuration for resilience:

const agent = LLMist.createAgent()
.withModel('gpt5')
.withRetry({
maxAttempts: 3,
retryOn: ['rate_limit', 'server_error'],
});