Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Typescript Agent SDK fails to connect with Ollama #136

Open
@ratulsaha2025

Description

@ratulsaha2025

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')

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions