Skip to content

[chat.completions.create] 404 Problem When Call Azure OpenAI V1 Chat Completion Api #1684

@wuxiaojun514

Description

@wuxiaojun514

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

I want to call Azure openai v1 chat completion api
Ideally the request should like POST {endpoint}/openai/v1/chat/completions
But our node library send request like POST {endpoint}/openai/v1/deployments/{model}/chat/completions?api-version=preview which finally got 404 error

Image

I tried to update package to latest version 6.3.0 but it doesn't help.

I did a bit trouble shooting in source code and found that:

if the api address exists in _deployments_endpoints array, the it will set
/deployments/${model}${options.path} in the path (See https://github.com/openai/openai-node/blob/master/src/azure.ts#L134 )

I saw there is a similar issue #1607 ,but response api is not in the _deployments_endpoints array so it won't impact response api

To Reproduce

Run the code like following, then I got 404 error

const options: AzureClientOptions = {
        apiKey: AZURE_OPENAI_API_KEY,
        baseURL:AZURE_OPENAI_ENDPOINT.endsWith("/")? AZURE_OPENAI_ENDPOINT+"openai/v1/":AZURE_OPENAI_ENDPOINT+"/openai/v1/",
        deployment: "gpt-4.1",
        apiVersion:"preview",
        dangerouslyAllowBrowser: true,
      };

 this.client = new AzureOpenAI(options);
const stream = await this.client.chat.completions.create({
      model: "gpt-4.1",
      messages: [
        {
          role: "user",
          content: "Hello",
        },
      ],
      stream: true,
    });

Please let me know if there is other way to call azure openai v1 chat completion api successfully

Code snippets

OS

win11

Node version

Node v22

Library version

openai 6.3.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