Open
Description
Issue
Typescript Agent SDK fails to run with Ollama models
Debug information
- Agents SDK version: (e.g.
v0.0.8
) - Runtime environment (e.g.
Node.js 22.16.0
)
Reproduction steps
import { OpenAI } from 'openai';
import { Agent, OpenAIChatCompletionsModel, setDefaultOpenAIClient, run } from '@openai/agents';
const ollamaClient = new OpenAI({ baseURL: 'http://localhost:11434/v1/', apiKey: 'ollama' });
setDefaultOpenAIClient(ollamaClient);
const ollamaModel = new OpenAIChatCompletionsModel({
model: 'llama3.2',
client: ollamaClient,
});
const agent = new Agent({
name: 'Haiku Agent',
instructions: 'Always respond in haiku form.',
model: ollamaModel,
});
const result = await run(
agent,
'Write a haiku about recursion in programming.',
);
console.log(result.finalOutput);
Expected behavior
Agent SDK should connect to Ollama
Actual behavior
const completion = await this.#client.chat.completions.create(requestData, {
TypeError: Cannot read properties of undefined (reading 'completions')