[GH-ISSUE #3032] [BUG]: /v1/openai/chat/completions responds "401 Error: Unauthorized" when valid api key is provided #1940

Closed
opened 2026-02-22 18:27:20 -05:00 by yindo · 1 comment
Owner

Originally created by @hehua2008 on GitHub (Jan 26, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3032

How are you running AnythingLLM?

AnythingLLM desktop app

What happened?

Curl

curl -X 'POST' \
  'http://localhost:3001/api/v1/openai/chat/completions' \
  -H 'accept: */*' \
  -H 'Authorization: Bearer MQ10WCV-895M03P-P83ZN1D-CSF76YF' \
  -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": "MLX-Python",
  "stream": true,
  "temperature": 0.7
}'

Request URL

http://localhost:3001/api/v1/openai/chat/completions

Server response

Code Details
401 Error: Unauthorized
Response headers
access-control-allow-origin: http://localhost:3001
connection: keep-alive
content-length: 0
date: Sun,26 Jan 2025 16:35:50 GMT
keep-alive: timeout=5
vary: Origin
x-powered-by: Express

Are there known steps to reproduce?

No response

Originally created by @hehua2008 on GitHub (Jan 26, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3032 ### How are you running AnythingLLM? AnythingLLM desktop app ### What happened? <div class="curl-command" style="box-sizing: border-box; position: relative; color: rgb(181, 186, 201); font-family: sans-serif; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgba(72, 203, 144, 0.1); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><h4 style="box-sizing: border-box; color: rgb(181, 186, 201); font-family: sans-serif; font-size: 12px; margin: 10px 0px 5px;">Curl</h4><div class="copy-to-clipboard" style="box-sizing: border-box; align-items: center; background: rgb(124, 129, 146); border: none; border-radius: 4px; bottom: 5px; display: flex; height: 20px; justify-content: center; position: absolute; right: 10px; width: 20px;"><button style="box-sizing: inherit; background: url(&quot;data:image/svg+xml;charset=utf-8,<svg xmlns=\&quot;http://www.w3.org/2000/svg\&quot; width=\&quot;16\&quot; height=\&quot;16\&quot; aria-hidden=\&quot;true\&quot;><path fill=\&quot;%23fff\&quot; fill-rule=\&quot;evenodd\&quot; d=\&quot;M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z\&quot;/></svg>&quot;) 50% center no-repeat; color: rgb(191, 191, 191); font-family: sans-serif; font-size: 16px; line-height: 1.15; margin: 0px; overflow: visible; text-transform: none; appearance: button; cursor: pointer; border: none; flex-grow: 1; flex-shrink: 1; height: 18px;"></button></div><div style="box-sizing: border-box;"><pre class="curl microlight" style="box-sizing: border-box; font-family: monospace; font-size: 12px; max-height: 400px; min-height: 6em; overflow: auto; background: rgb(51, 51, 51); border-radius: 4px; hyphens: auto; margin: 0px; padding: 0.5em; white-space: pre-wrap; word-break: break-word; overflow-wrap: break-word; color: white; font-weight: 600; display: block;"><code class="language-bash" style="box-sizing: border-box; font-family: Consolas, monaco, monospace; font-size: 1em; white-space: pre;"><span style="box-sizing: inherit;">curl -X </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);">'POST'</span><span style="box-sizing: inherit;"> \ </span><span style="box-sizing: inherit;"> </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);">'http://localhost:3001/api/v1/openai/chat/completions'</span><span style="box-sizing: inherit;"> \ </span><span style="box-sizing: inherit;"> -H </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);">'accept: */*'</span><span style="box-sizing: inherit;"> \ </span><span style="box-sizing: inherit;"> -H </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);">'Authorization: Bearer MQ10WCV-895M03P-P83ZN1D-CSF76YF'</span><span style="box-sizing: inherit;"> \ </span><span style="box-sizing: inherit;"> -H </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);">'Content-Type: application/json'</span><span style="box-sizing: inherit;"> \ </span><span style="box-sizing: inherit;"> -d </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);">'{ </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> "messages": [ </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> { </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> "role": "system", </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> "content": "You are a helpful assistant" </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> }, </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> { </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> "role": "user", </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> "content": "What is AnythingLLM?" </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> }, </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> { </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> "role": "assistant", </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> "content": "AnythingLLM is...." </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> }, </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> { </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> "role": "user", </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> "content": "Follow up question..." </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> } </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> ], </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> "model": "MLX-Python", </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> "stream": true, </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);"> "temperature": 0.7 </span><span style="box-sizing: inherit; color: rgb(162, 252, 162);">}'</span></code></pre></div></div><div style="box-sizing: border-box; color: rgb(181, 186, 201); font-family: sans-serif; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgba(72, 203, 144, 0.1); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="request-url" style="box-sizing: border-box;"><h4 style="box-sizing: border-box; color: rgb(181, 186, 201); font-family: sans-serif; font-size: 12px; margin: 10px 0px 5px;">Request URL</h4><pre class="microlight" style="box-sizing: border-box; font-family: monospace; font-size: 12px; background: rgb(65, 68, 78); border-radius: 4px; hyphens: auto; margin: 0px; padding: 10px; white-space: pre-wrap; word-break: break-word; overflow-wrap: break-word; color: rgb(255, 255, 255); font-weight: 600;">http://localhost:3001/api/v1/openai/chat/completions</pre></div></div><h4 style="box-sizing: border-box; color: rgb(181, 186, 201); font-family: sans-serif; font-size: 12px; margin: 10px 0px 5px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgba(72, 203, 144, 0.1); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Server response</h4> Code Details 401 Error: Unauthorized Response headers access-control-allow-origin: http://localhost:3001 connection: keep-alive content-length: 0 date: Sun,26 Jan 2025 16:35:50 GMT keep-alive: timeout=5 vary: Origin x-powered-by: Express ### Are there known steps to reproduce? _No response_
yindo added the possible bug label 2026-02-22 18:27:20 -05:00
yindo closed this issue 2026-02-22 18:27:20 -05:00
Author
Owner

@hehua2008 commented on GitHub (Jan 26, 2025):

Close it.
I should use "mlx-python" instead of "MLX-Python" for "model".

@hehua2008 commented on GitHub (Jan 26, 2025): Close it. I should use "mlx-python" instead of "MLX-Python" for "model".
yindo changed title from [BUG]: /v1/openai/chat/completions responds "401 Error: Unauthorized" when valid api key is provided to [GH-ISSUE #3032] [BUG]: /v1/openai/chat/completions responds "401 Error: Unauthorized" when valid api key is provided 2026-06-05 14:43:35 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#1940