/api/chat/completion endpoint returns 400 Bad Request despite valid payload and API key #2941

Closed
opened 2025-11-11 15:17:59 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @riazsomc on GitHub (Dec 6, 2024).

Description:
The /api/chat/completion endpoint consistently returns a 400 Bad Request response even when using a valid payload and API key. According to the documentation, this endpoint should accept a prompt and produce a completion, but currently it’s not functioning as expected.

Steps to Reproduce:

Make a POST request to /api/chat/completion with a properly formatted JSON body:

{
  "model": "llama3.1",
  "messages": [
    {"role": "user", "content": "Hello, world!"}
  ]
}

Include a valid API key in the headers (e.g., Authorization: Bearer <API_KEY>).
Observe the response.
Expected Behavior:
A 200 OK response with a completion result should be returned.

Actual Behavior:
The endpoint returns a 400 Bad Request error every time, regardless of the payload or model used.

Additional Context:

Confirmed that the API key works for other endpoints.
Verified that payload format matches the documentation.
Tested different model names and message structures without success.
Environment:

Operating system: Ubuntu 20.04
Open-WebUI version: v0.4.7
Installation method: Docker
It would be helpful to clarify if the endpoint is still supported or if there have been recent changes that might have broken this functionality. If additional logs or details are needed, please let me know.

Originally created by @riazsomc on GitHub (Dec 6, 2024). **Description:** The /api/chat/completion endpoint consistently returns a 400 Bad Request response even when using a valid payload and API key. According to the documentation, this endpoint should accept a prompt and produce a completion, but currently it’s not functioning as expected. Steps to Reproduce: Make a POST request to /api/chat/completion with a properly formatted JSON body: ``` { "model": "llama3.1", "messages": [ {"role": "user", "content": "Hello, world!"} ] } ``` Include a valid API key in the headers (e.g., Authorization: Bearer <API_KEY>). Observe the response. Expected Behavior: A 200 OK response with a completion result should be returned. Actual Behavior: The endpoint returns a 400 Bad Request error every time, regardless of the payload or model used. Additional Context: Confirmed that the API key works for other endpoints. Verified that payload format matches the documentation. Tested different model names and message structures without success. Environment: Operating system: Ubuntu 20.04 Open-WebUI version: v0.4.7 Installation method: Docker It would be helpful to clarify if the endpoint is still supported or if there have been recent changes that might have broken this functionality. If additional logs or details are needed, please let me know.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#2941