[GH-ISSUE #3164] [BUG]: /v1/openai/chat/completions responds "401 Error: Unauthorized" when valid api key is provided, test two matchine ,the same result bug .help! #2032

Closed
opened 2026-02-22 18:27:50 -05:00 by yindo · 6 comments
Owner

Originally created by @jackzuan on GitHub (Feb 10, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3164

How are you running AnythingLLM?

Docker (local)

What happened?

/v1/openai/chat/completions responds "401 Error: Unauthorized" when valid api key is provided

Image

Image

curl -X 'POST' \ 'http://localhost:3001/api/v1/openai/chat/completions' \ -H 'accept: */*' \ -H 'Authorization: Bearer SDAAFCF-AYPM9TJ-GHSF8DA-X8R5722' \ -H 'Content-Type: application/json' \ -d '{ "messages": [ { "role": "system", "content": "You are a helpful assistant" }, { "role": "user", "content": "What is AnythingLLM?" }, { "role": "assistant", "content": "AnythingLLM is...." }, { "role": "user", "content": "Follow up question..." } ], "model": "deepseek-r1:1.5b", "stream": true, "temperature": 0.7 }'
// Responses
{ "message": "Invalid API Key" }

Are there known steps to reproduce?

No response

Originally created by @jackzuan on GitHub (Feb 10, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3164 ### How are you running AnythingLLM? Docker (local) ### What happened? /v1/openai/chat/completions responds "401 Error: Unauthorized" when valid api key is provided ![Image](https://github.com/user-attachments/assets/df3f619f-8588-490a-ba3e-9d6c3794b143) ![Image](https://github.com/user-attachments/assets/1a2b30a8-2a7d-4f0e-8bf7-1198fade2179) `curl -X 'POST' \ 'http://localhost:3001/api/v1/openai/chat/completions' \ -H 'accept: */*' \ -H 'Authorization: Bearer SDAAFCF-AYPM9TJ-GHSF8DA-X8R5722' \ -H 'Content-Type: application/json' \ -d '{ "messages": [ { "role": "system", "content": "You are a helpful assistant" }, { "role": "user", "content": "What is AnythingLLM?" }, { "role": "assistant", "content": "AnythingLLM is...." }, { "role": "user", "content": "Follow up question..." } ], "model": "deepseek-r1:1.5b", "stream": true, "temperature": 0.7 }'` // Responses `{ "message": "Invalid API Key" }` ### Are there known steps to reproduce? _No response_
yindo added the possible bug label 2026-02-22 18:27:50 -05:00
yindo closed this issue 2026-02-22 18:27:50 -05:00
Author
Owner

@timothycarambat commented on GitHub (Feb 10, 2025):

With our openai compatible endpoint model is a workspace slug so you can leverage the entire RAG corpus with a seamless OpenAI interface - it is not the model as you would normally use since we have support for multiple providers and models and a single model tag would not be differentiated enough to know what to do.

Reference the slug of a workspace - which you can view all from GET api/v1/openai/models

{
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant"
    },
    {
      "role": "user",
      "content": "What is AnythingLLM?"
    },
    {
      "role": "assistant",
      "content": "AnythingLLM is...."
    },
    {
      "role": "user",
      "content": "Follow up question..."
    }
  ],
  "model": "sample-workspace", <--- shows this in example and denotes it in description of endpoint
  "stream": true,
  "temperature": 0.7
}
@timothycarambat commented on GitHub (Feb 10, 2025): With our openai compatible endpoint `model` is a workspace slug so you can leverage the entire RAG corpus with a seamless OpenAI interface - it is not the `model` as you would normally use since we have support for multiple providers and models and a single model tag would not be differentiated enough to know what to do. Reference the slug of a workspace - which you can view all from `GET api/v1/openai/models` ```json { "messages": [ { "role": "system", "content": "You are a helpful assistant" }, { "role": "user", "content": "What is AnythingLLM?" }, { "role": "assistant", "content": "AnythingLLM is...." }, { "role": "user", "content": "Follow up question..." } ], "model": "sample-workspace", <--- shows this in example and denotes it in description of endpoint "stream": true, "temperature": 0.7 } ```
Author
Owner

@yangdezuan commented on GitHub (Feb 11, 2025):

Request/v1/workspace/{slug}/thread/{threadSlug}/chats will also display 'Invalid API Key', my API key is correct.

@yangdezuan commented on GitHub (Feb 11, 2025): <!-- Failed to upload "image.png" --> Request/v1/workspace/{slug}/thread/{threadSlug}/chats will also display 'Invalid API Key', my API key is correct.
Author
Owner

@yangdezuan commented on GitHub (Feb 11, 2025):

Oh, thank you. I understand now。These api need request Workspaces , not "/v1/openai/chat/completions" request.

@yangdezuan commented on GitHub (Feb 11, 2025): Oh, thank you. I understand now。These api need request [Workspaces](http://localhost:3001/api/docs/#/Workspaces) , not "/v1/openai/chat/completions" request.
Author
Owner

@miraculix95 commented on GitHub (May 5, 2025):

Can you help me understand? These api points are very difficult to understand for a beginner like me.

@miraculix95 commented on GitHub (May 5, 2025): Can you help me understand? These api points are very difficult to understand for a beginner like me.
yindo changed title from [BUG]: /v1/openai/chat/completions responds "401 Error: Unauthorized" when valid api key is provided, test two matchine ,the same result bug .help! to [GH-ISSUE #3164] [BUG]: /v1/openai/chat/completions responds "401 Error: Unauthorized" when valid api key is provided, test two matchine ,the same result bug .help! 2026-06-05 14:44:08 -04:00
Author
Owner

@jackzuan commented on GitHub (Feb 11, 2025):

Request/v1/workspace/{slug}/thread/{threadSlug}/chats will also display 'Invalid API Key', my API key is correct.

<!-- gh-comment-id:2650032015 --> @jackzuan commented on GitHub (Feb 11, 2025): <!-- Failed to upload "image.png" --> Request/v1/workspace/{slug}/thread/{threadSlug}/chats will also display 'Invalid API Key', my API key is correct.
Author
Owner

@jackzuan commented on GitHub (Feb 11, 2025):

Oh, thank you. I understand now。These api need request Workspaces , not "/v1/openai/chat/completions" request.

<!-- gh-comment-id:2650056244 --> @jackzuan commented on GitHub (Feb 11, 2025): Oh, thank you. I understand now。These api need request [Workspaces](http://localhost:3001/api/docs/#/Workspaces) , not "/v1/openai/chat/completions" request.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#2032