Skip to content

fetchOptions - Type '{ dispatcher: any; }' is not assignable to type 'undefined'. #1555

Closed
@Cerlancism

Description

@Cerlancism

Confirm this is a Node library issue and not an underlying OpenAI API issue

  • This is an issue with the Node library

Describe the bug

Type error when configuring fetchOptions of new OpenAI instance

Type '{ dispatcher: ProxyAgent; }' is not assignable to type 'undefined'.ts(2322)
client.d.mts(64, 5): The expected type comes from property 'fetchOptions' which is declared here on type 'ClientOptions'
(property) ClientOptions.fetchOptions?: undefined
Additional RequestInit options to be passed to fetch calls. Properties will be overridden by per-request fetchOptions.

To Reproduce

  1. Follow "Configuring proxies" from README https://github.com/openai/openai-node?tab=readme-ov-file#configuring-proxies
  2. Observe TypeScript errors

Code snippets

import OpenAI from 'openai';
import * as undici from 'undici';

const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
const client = new OpenAI({
  fetchOptions: {
    dispatcher: proxyAgent,
  },
});

OS

Windows

Node version

Node v22.12.0

Library version

openai v5.7.0

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