[GH-ISSUE #9801] CORS error: request header field openai-beta is not allowed #6410

Closed
opened 2026-04-12 17:57:30 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @keadex on GitHub (Mar 16, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/9801

What is the issue?

Hi there! I'm trying to send a request to the local Ollama instance, but I encounter the following issue:

Access to fetch at 'http://localhost:11434/v1/chat/completions' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field openai-beta is not allowed by Access-Control-Allow-Headers in preflight response.

Which is caused by openai-beta request header.

Here is a snippet of code to reproduce the issue:

fetch("http://localhost:11434/v1/chat/completions", {
  method: "POST",
  headers: {
    authorization: "Bearer ollama",
    "content-type": "application/json",
    "openai-beta": "assistants=v2",
  },
  body: JSON.stringify({
    messages: [
      { role: "system", content: "You are a helpful assistant." },
      {
        role: "user",
        content: "<content>",
      },
    ],
    model: "deepseek-r1:8b",
    max_tokens: 2048,
    stream: false,
  })
})

Relevant log output

Access to fetch at 'http://localhost:11434/v1/chat/completions' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field openai-beta is not allowed by Access-Control-Allow-Headers in preflight response.

OS

Windows

GPU

Intel

CPU

Intel

Ollama version

0.6.1

Originally created by @keadex on GitHub (Mar 16, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/9801 ### What is the issue? Hi there! I'm trying to send a request to the local Ollama instance, but I encounter the following issue: ```bash Access to fetch at 'http://localhost:11434/v1/chat/completions' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field openai-beta is not allowed by Access-Control-Allow-Headers in preflight response. ``` Which is caused by `openai-beta` request header. Here is a snippet of code to reproduce the issue: ```typescript fetch("http://localhost:11434/v1/chat/completions", { method: "POST", headers: { authorization: "Bearer ollama", "content-type": "application/json", "openai-beta": "assistants=v2", }, body: JSON.stringify({ messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "<content>", }, ], model: "deepseek-r1:8b", max_tokens: 2048, stream: false, }) }) ``` ### Relevant log output ```shell Access to fetch at 'http://localhost:11434/v1/chat/completions' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field openai-beta is not allowed by Access-Control-Allow-Headers in preflight response. ``` ### OS Windows ### GPU Intel ### CPU Intel ### Ollama version 0.6.1
GiteaMirror added the bug label 2026-04-12 17:57:30 -05:00
Author
Owner

@ParthSareen commented on GitHub (Mar 17, 2025):

Hey @keadex is there a reason for using the beta completions and not regular? We mainly have compatibility for: https://platform.openai.com/docs/api-reference/chat/create

<!-- gh-comment-id:2730513287 --> @ParthSareen commented on GitHub (Mar 17, 2025): Hey @keadex is there a reason for using the beta completions and not regular? We mainly have compatibility for: https://platform.openai.com/docs/api-reference/chat/create
Author
Owner

@keadex commented on GitHub (Mar 17, 2025):

Hi @ParthSareen, that header is injected by the async-openai Rust crate, so there are no ways to change it.
Disabling the CORS checks resolves the issue. It seems it's a matter of allowing that header.

<!-- gh-comment-id:2731163425 --> @keadex commented on GitHub (Mar 17, 2025): Hi @ParthSareen, that header is injected by the [async-openai](https://github.com/64bit/async-openai) Rust crate, so there are no ways to change it. Disabling the CORS checks resolves the issue. It seems it's a matter of allowing that header.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#6410