Agent stops working: "The AI service rejected the request due to an error. This could be caused by an invalid API key or an improperly formatted request." #4819
Replies: 8 comments 17 replies
-
Issues are for reproducible errors and I can’t reproduce this. However I will keep trying and handle the null content edge case. try to reproduce it reliably. Are you switching agents mid conversation? Switching endpoints? it could be a context window issue. |
Beta Was this translation helpful? Give feedback.
-
I dont' understand how I am the only other person with this issue. Brand new fresh Docker setup. Other containers work fine, other apps and services accept my OpenAI keys just fine. I know the difference between the tokens and the keys. I actually have a dev account and have API keys assigned to a project. The keys work and allow use of OpenAI chat just fine. Yours doesn't. Seems there may be a problem with your ability to save the save so that it can access it? it says "no_user_key" yet I very clearly and very carefully pasted the key in and saved it. When it didn't work, I went back and created a new API key, and it still didn't work.
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
My initial issue was related to agents using tools. I have the feeling that the discussion has diverged from that since I am reading a lot about .env variables etc. Don't know it that helps or if the issues were related.. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
This is also happening for me on my production instance with agents, but not with my dev box. It started happening after the commits on 30/01, on the very first message. Assistants and base models work fine. ![]() {"attemptNumber":1,"code":null,"error":{"code":null,"message":"You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer [REDACTED] (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.","param":null,"type":"invalid_request_error"},"headers":{"alt-svc":"h3=\":443\"; ma=86400","cf-cache-status":"DYNAMIC","cf-ray":"90a8f8f4ec882e0f-ARN","connection":"keep-alive","content-length":"496","content-type":"application/json; charset=utf-8","date":"Fri, 31 Jan 2025 10:21:02 GMT","server":"cloudflare","set-cookie":"__cf_bm=1IyFX9PktO.AheJueaFwPpqeqTCCyGOW0ECOwmBNWEs-1738318862-1.0.1.1-pgzG9zdXbwx4Piqr6D0FdwVPYDcOpSFtq2gD41.kHW_BTEAfu9Z0HOhw4M9U.5ga8oNpi6iQOYRmeKb3NmImPA; path=/; expires=Fri, 31-Jan-25 10:51:02 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None, _cfuvid=0G2gJtn9kf.jNco0Epff38FngBsqvRcHc26IRXA278A-1738318862039-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None","strict-transport-security":"max-age=31536000; includeSubDomains; preload","vary":"Origin","x-content-type-options":"nosniff","x-request-id":"req_e412a2fb6cefd744eed37a8f07e0e966"},"lc_error_code":"MODEL_AUTHENTICATION","level":"error","message":"[api/server/controllers/agents/client.js #sendCompletion] Unhandled error type 401 You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.\n\nTroubleshooting URL: https://js.langchain.com/docs/troubleshooting/errors/MODEL_AUTHENTICATION/\n","param":null,"pregelTaskId":"1cc27248-81ab-5b02-82b9-69f56a63bbc8","request_id":"req_e412a2fb6cefd744eed37a8f07e0e966","retriesLeft":6,"stack":"Error: 401 You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.\n\nTroubleshooting URL: https://js.langchain.com/docs/troubleshooting/errors/MODEL_AUTHENTICATION/\n\n at APIError.generate (/app/node_modules/openai/error.js:48:20)\n at OpenAI.makeStatusError (/app/node_modules/openai/core.js:293:33)\n at OpenAI.makeRequest (/app/node_modules/openai/core.js:337:30)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async /app/node_modules/@librechat/agents/node_modules/@langchain/openai/dist/chat_models.cjs:1481:29\n at async RetryOperation._fn (/app/node_modules/p-retry/index.js:50:12)","status":401,"type":"invalid_request_error"} Did you manage to work out what happened? |
Beta Was this translation helpful? Give feedback.
-
I was getting this error also after a clean installation today. My solution was to use |
Beta Was this translation helpful? Give feedback.
-
I'm also seeing this on a fresh install, when trying to use the Calculator with an agent:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What happened?
I've built multiple agents with tools (Dalle but also custom tools)
All Chats with various agents get this bug after a while. From that point on such a chat is completely broken.
You must start a new chat, otherwise you will always receive the error.
I cannot pin down what is causing it: Tool usage, long system prompts, or a specific model. For now I think it happens on all cases.
I have the feeling that the issue appears more on longer chats, but I am absolutely not sure about that.
I belive it hast nothing to do with any API key, as it just happens!
Steps to Reproduce
What browsers are you seeing the problem on?
No response
Relevant log output
Screenshots
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions