[GH-ISSUE #3419] [backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }). #2205

Closed
opened 2026-02-22 18:28:38 -05:00 by yindo · 3 comments
Owner

Originally created by @NCNeo on GitHub (Mar 7, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3419

Issue: recently install Anything LLM on my Mac Pro 2012 - chip inter E5 + 2 graphical cards.

Deploy Docker and Docker Compose thru Brew
Pull Docker Imagen from official site

  • docker pull mintplexlabs/anythingllm

Mount Storage as documentation says
export STORAGE_LOCATION=$HOME/anythingllm &&
mkdir -p $STORAGE_LOCATION &&
touch "$STORAGE_LOCATION/.env" &&
docker run -d -p 3001:3001
--cap-add SYS_ADMIN
-v ${STORAGE_LOCATION}:/app/server/storage
-v ${STORAGE_LOCATION}/.env:/app/server/.env
-e STORAGE_DIR="/app/server/storage"
mintplexlabs/anythingllm

Start service running good in https://localhost:3001

When I select the model (OpenAI with API Key), Ollama installed locally, Get in UI "Failed To Fecht" when I review the Log, get this.

025-03-07 17:49:56 [backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).
2025-03-07 17:49:56 at new OpenAI (/app/server/node_modules/openai/index.js:53:19)
2025-03-07 17:49:56 at openAiModels (/app/server/utils/helpers/customModels.js:91:18)
2025-03-07 17:49:56 at getCustomModels (/app/server/utils/helpers/customModels.js:43:20)
2025-03-07 17:49:56 at /app/server/endpoints/system.js:960:41
2025-03-07 17:49:56 at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5)
2025-03-07 17:49:56 at next (/app/server/node_modules/express/lib/router/route.js:149:13)
2025-03-07 17:49:56 at /app/server/utils/middleware/multiUserProtected.js:60:7
2025-03-07 17:49:56 at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5)
2025-03-07 17:49:56 at next (/app/server/node_modules/express/lib/router/route.js:149:13)
2025-03-07 17:49:56 at validatedRequest (/app/server/utils/middleware/validatedRequest.js:20:5)
2025-03-07 17:49:57 [backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).
2025-03-07 17:49:57 at new OpenAI (/app/server/node_modules/openai/index.js:53:19)
2025-03-07 17:49:57 at openAiModels (/app/server/utils/helpers/customModels.js:91:18)
2025-03-07 17:49:57 at getCustomModels (/app/server/utils/helpers/customModels.js:43:20)
2025-03-07 17:49:57 at /app/server/endpoints/system.js:960:41
2025-03-07 17:49:57 at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5)
2025-03-07 17:49:57 at next (/app/server/node_modules/express/lib/router/route.js:149:13)
2025-03-07 17:49:57 at /app/server/utils/middleware/multiUserProtected.js:60:7
2025-03-07 17:49:57 at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5)
2025-03-07 17:49:57 at next (/app/server/node_modules/express/lib/router/route.js:149:13)
2025-03-07 17:49:57 at validatedRequest (/app/server/utils/middleware/validatedRequest.js:20:5)
2025-03-07 17:50:04 [backend] error: TypeError: fetch failed
2025-03-07 17:50:04 at node:internal/deps/undici/undici:12618:11
2025-03-07 17:50:04 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2025-03-07 17:50:04 at async ollamaAIModels (/app/server/utils/helpers/customModels.js:346:18)
2025-03-07 17:50:04 at async getCustomModels (/app/server/utils/helpers/customModels.js:49:14)
2025-03-07 17:50:04 at async /app/server/endpoints/system.js:960:35
2025-03-07 17:50:04 [backend] error: TypeError: fetch failed
2025-03-07 17:50:04 at node:internal/deps/undici/undici:12618:11
2025-03-07 17:50:04 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2025-03-07 17:50:04 at async ollamaAIModels (/app/server/utils/helpers/customModels.js:346:18)
2025-03-07 17:50:04 at async getCustomModels (/app/server/utils/helpers/customModels.js:49:14)
2025-03-07 17:50:04 at async /app/server/endpoints/system.js:960:35

I try to find the solution thru Github or Discord, but non of this issue. Please see attached file to support the case. If there already solution of this please helpmeet to refer the documentation.

Image
Image
Image
Image
Image

Originally created by @NCNeo on GitHub (Mar 7, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3419 Issue: recently install Anything LLM on my Mac Pro 2012 - chip inter E5 + 2 graphical cards. Deploy Docker and Docker Compose thru Brew Pull Docker Imagen from official site - docker pull mintplexlabs/anythingllm Mount Storage as documentation says export STORAGE_LOCATION=$HOME/anythingllm && \ mkdir -p $STORAGE_LOCATION && \ touch "$STORAGE_LOCATION/.env" && \ docker run -d -p 3001:3001 \ --cap-add SYS_ADMIN \ -v ${STORAGE_LOCATION}:/app/server/storage \ -v ${STORAGE_LOCATION}/.env:/app/server/.env \ -e STORAGE_DIR="/app/server/storage" \ mintplexlabs/anythingllm Start service running good in https://localhost:3001 When I select the model (OpenAI with API Key), Ollama installed locally, Get in UI "Failed To Fecht" when I review the Log, get this. 025-03-07 17:49:56 [backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }). 2025-03-07 17:49:56 at new OpenAI (/app/server/node_modules/openai/index.js:53:19) 2025-03-07 17:49:56 at openAiModels (/app/server/utils/helpers/customModels.js:91:18) 2025-03-07 17:49:56 at getCustomModels (/app/server/utils/helpers/customModels.js:43:20) 2025-03-07 17:49:56 at /app/server/endpoints/system.js:960:41 2025-03-07 17:49:56 at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5) 2025-03-07 17:49:56 at next (/app/server/node_modules/express/lib/router/route.js:149:13) 2025-03-07 17:49:56 at /app/server/utils/middleware/multiUserProtected.js:60:7 2025-03-07 17:49:56 at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5) 2025-03-07 17:49:56 at next (/app/server/node_modules/express/lib/router/route.js:149:13) 2025-03-07 17:49:56 at validatedRequest (/app/server/utils/middleware/validatedRequest.js:20:5) 2025-03-07 17:49:57 [backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }). 2025-03-07 17:49:57 at new OpenAI (/app/server/node_modules/openai/index.js:53:19) 2025-03-07 17:49:57 at openAiModels (/app/server/utils/helpers/customModels.js:91:18) 2025-03-07 17:49:57 at getCustomModels (/app/server/utils/helpers/customModels.js:43:20) 2025-03-07 17:49:57 at /app/server/endpoints/system.js:960:41 2025-03-07 17:49:57 at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5) 2025-03-07 17:49:57 at next (/app/server/node_modules/express/lib/router/route.js:149:13) 2025-03-07 17:49:57 at /app/server/utils/middleware/multiUserProtected.js:60:7 2025-03-07 17:49:57 at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5) 2025-03-07 17:49:57 at next (/app/server/node_modules/express/lib/router/route.js:149:13) 2025-03-07 17:49:57 at validatedRequest (/app/server/utils/middleware/validatedRequest.js:20:5) 2025-03-07 17:50:04 [backend] error: TypeError: fetch failed 2025-03-07 17:50:04 at node:internal/deps/undici/undici:12618:11 2025-03-07 17:50:04 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 2025-03-07 17:50:04 at async ollamaAIModels (/app/server/utils/helpers/customModels.js:346:18) 2025-03-07 17:50:04 at async getCustomModels (/app/server/utils/helpers/customModels.js:49:14) 2025-03-07 17:50:04 at async /app/server/endpoints/system.js:960:35 2025-03-07 17:50:04 [backend] error: TypeError: fetch failed 2025-03-07 17:50:04 at node:internal/deps/undici/undici:12618:11 2025-03-07 17:50:04 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 2025-03-07 17:50:04 at async ollamaAIModels (/app/server/utils/helpers/customModels.js:346:18) 2025-03-07 17:50:04 at async getCustomModels (/app/server/utils/helpers/customModels.js:49:14) 2025-03-07 17:50:04 at async /app/server/endpoints/system.js:960:35 I try to find the solution thru Github or Discord, but non of this issue. Please see attached file to support the case. If there already solution of this please helpmeet to refer the documentation. ![Image](https://github.com/user-attachments/assets/47fa2836-d082-4314-b82e-22f62c779b71) ![Image](https://github.com/user-attachments/assets/7b54914d-91e8-49b2-a734-90b4f148adcc) ![Image](https://github.com/user-attachments/assets/927bbd59-3021-46ed-84c2-131fb22a404d) ![Image](https://github.com/user-attachments/assets/3f3bb976-11a6-430f-85d4-07ebc0d38e24) ![Image](https://github.com/user-attachments/assets/ad4b0231-9f56-4f1f-9486-274a43bd1f33)
yindo closed this issue 2026-02-22 18:28:38 -05:00
Author
Owner

@timothycarambat commented on GitHub (Mar 9, 2025):

because localhost does not work in docker for Ollama. You need to use host.docker.internal to reach the host OS localhost. So in your case http://host.docker.internal:11434 to reach ollama. This should be auto-detected for you if you select Ollama

@timothycarambat commented on GitHub (Mar 9, 2025): because `localhost` does not work in docker for Ollama. You need to use `host.docker.internal` to reach the host OS localhost. So in your case `http://host.docker.internal:11434` to reach ollama. This should be auto-detected for you if you select Ollama
Author
Owner

@NCNeo commented on GitHub (Mar 14, 2025):

Timothy in my case I used openAI and Ollama with your configuration suggested, but still have same problem. Another option?

@NCNeo commented on GitHub (Mar 14, 2025): Timothy in my case I used openAI and Ollama with your configuration suggested, but still have same problem. Another option?
Author
Owner

@nepomuc commented on GitHub (Sep 7, 2025):

@timothycarambat Same problem. :/ Can you help? I simply used the run-command from you doc and want to only set up AnythingLLM with my ollama instance on my LAN.

anythingllm  | [backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).
anythingllm  |     at new OpenAI (/app/server/node_modules/openai/index.js:72:19)
anythingllm  |     at openAiModels (/app/server/utils/helpers/customModels.js:100:18)
anythingllm  |     at getCustomModels (/app/server/utils/helpers/customModels.js:46:20)
anythingllm  |     at /app/server/endpoints/system.js:973:41
anythingllm  |     at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5)
anythingllm  |     at next (/app/server/node_modules/express/lib/router/route.js:149:13)
anythingllm  |     at /app/server/utils/middleware/multiUserProtected.js:60:7
anythingllm  |     at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5)
anythingllm  |     at next (/app/server/node_modules/express/lib/router/route.js:149:13)
anythingllm  |     at validatedRequest (/app/server/utils/middleware/validatedRequest.js:20:5)
anythingllm  | [backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).
anythingllm  |     at new OpenAI (/app/server/node_modules/openai/index.js:72:19)
anythingllm  |     at openAiModels (/app/server/utils/helpers/customModels.js:100:18)
anythingllm  |     at getCustomModels (/app/server/utils/helpers/customModels.js:46:20)
anythingllm  |     at /app/server/endpoints/system.js:973:41
anythingllm  |     at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5)
anythingllm  |     at next (/app/server/node_modules/express/lib/router/route.js:149:13)
anythingllm  |     at /app/server/utils/middleware/multiUserProtected.js:60:7
anythingllm  |     at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5)
anythingllm  |     at next (/app/server/node_modules/express/lib/router/route.js:149:13)
anythingllm  |     at validatedRequest (/app/server/utils/middleware/validatedRequest.js:20:5)
anythingllm  | [backend] error: TypeError: fetch failed
anythingllm  |     at node:internal/deps/undici/undici:12637:11
anythingllm  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
anythingllm  |     at async ollamaAIModels (/app/server/utils/helpers/customModels.js:358:18)
anythingllm  |     at async getCustomModels (/app/server/utils/helpers/customModels.js:52:14)
anythingllm  |     at async /app/server/endpoints/system.js:973:35
anythingllm  | [backend] error: TypeError: fetch failed
anythingllm  |     at node:internal/deps/undici/undici:12637:11
anythingllm  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
anythingllm  |     at async ollamaAIModels (/app/server/utils/helpers/customModels.js:358:18)
anythingllm  |     at async getCustomModels (/app/server/utils/helpers/customModels.js:52:14)
anythingllm  |     at async /app/server/endpoints/system.js:973:35
anythingllm  | [backend] error: TypeError: fetch failed
anythingllm  |     at node:internal/deps/undici/undici:12637:11
anythingllm  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
anythingllm  |     at async ollamaAIModels (/app/server/utils/helpers/customModels.js:358:18)
anythingllm  |     at async getCustomModels (/app/server/utils/helpers/customModels.js:52:14)
anythingllm  |     at async /app/server/endpoints/system.js:973:35
anythingllm  | [backend] info: EmbeddingEngine changed from undefined to native - resetting undefined namespaces
anythingllm  | [backend] info: [Event Logged] - workspace_vectors_reset
anythingllm  | [backend] info: Resetting anythingllm managed vector namespaces for 
anythingllm  | /usr/local/bin/docker-entrypoint.sh: line 24:   117 Illegal instruction     (core dumped) node /app/server/index.js
anythingllm exited with code 132

Setting it up with openai at the onboarding also results in an error:

anythingllm  | [backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).
anythingllm  |     at new OpenAI (/app/server/node_modules/openai/index.js:72:19)
anythingllm  |     at openAiModels (/app/server/utils/helpers/customModels.js:100:18)
anythingllm  |     at getCustomModels (/app/server/utils/helpers/customModels.js:46:20)
anythingllm  |     at /app/server/endpoints/system.js:973:41
anythingllm  |     at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5)
anythingllm  |     at next (/app/server/node_modules/express/lib/router/route.js:149:13)
anythingllm  |     at /app/server/utils/middleware/multiUserProtected.js:60:7
anythingllm  |     at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5)
anythingllm  |     at next (/app/server/node_modules/express/lib/router/route.js:149:13)
anythingllm  |     at validatedRequest (/app/server/utils/middleware/validatedRequest.js:20:5)
anythingllm  | [backend] info: EmbeddingEngine changed from undefined to native - resetting undefined namespaces
anythingllm  | [backend] info: [Event Logged] - workspace_vectors_reset
anythingllm  | [backend] info: Resetting anythingllm managed vector namespaces for 
anythingllm  | /usr/local/bin/docker-entrypoint.sh: line 24:   120 Illegal instruction     (core dumped) node /app/server/index.js
anythingllm exited with code 132
@nepomuc commented on GitHub (Sep 7, 2025): @timothycarambat Same problem. :/ Can you help? I simply used the run-command from you doc and want to only set up AnythingLLM with my ollama instance on my LAN. ```console anythingllm | [backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }). anythingllm | at new OpenAI (/app/server/node_modules/openai/index.js:72:19) anythingllm | at openAiModels (/app/server/utils/helpers/customModels.js:100:18) anythingllm | at getCustomModels (/app/server/utils/helpers/customModels.js:46:20) anythingllm | at /app/server/endpoints/system.js:973:41 anythingllm | at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5) anythingllm | at next (/app/server/node_modules/express/lib/router/route.js:149:13) anythingllm | at /app/server/utils/middleware/multiUserProtected.js:60:7 anythingllm | at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5) anythingllm | at next (/app/server/node_modules/express/lib/router/route.js:149:13) anythingllm | at validatedRequest (/app/server/utils/middleware/validatedRequest.js:20:5) anythingllm | [backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }). anythingllm | at new OpenAI (/app/server/node_modules/openai/index.js:72:19) anythingllm | at openAiModels (/app/server/utils/helpers/customModels.js:100:18) anythingllm | at getCustomModels (/app/server/utils/helpers/customModels.js:46:20) anythingllm | at /app/server/endpoints/system.js:973:41 anythingllm | at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5) anythingllm | at next (/app/server/node_modules/express/lib/router/route.js:149:13) anythingllm | at /app/server/utils/middleware/multiUserProtected.js:60:7 anythingllm | at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5) anythingllm | at next (/app/server/node_modules/express/lib/router/route.js:149:13) anythingllm | at validatedRequest (/app/server/utils/middleware/validatedRequest.js:20:5) anythingllm | [backend] error: TypeError: fetch failed anythingllm | at node:internal/deps/undici/undici:12637:11 anythingllm | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) anythingllm | at async ollamaAIModels (/app/server/utils/helpers/customModels.js:358:18) anythingllm | at async getCustomModels (/app/server/utils/helpers/customModels.js:52:14) anythingllm | at async /app/server/endpoints/system.js:973:35 anythingllm | [backend] error: TypeError: fetch failed anythingllm | at node:internal/deps/undici/undici:12637:11 anythingllm | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) anythingllm | at async ollamaAIModels (/app/server/utils/helpers/customModels.js:358:18) anythingllm | at async getCustomModels (/app/server/utils/helpers/customModels.js:52:14) anythingllm | at async /app/server/endpoints/system.js:973:35 anythingllm | [backend] error: TypeError: fetch failed anythingllm | at node:internal/deps/undici/undici:12637:11 anythingllm | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) anythingllm | at async ollamaAIModels (/app/server/utils/helpers/customModels.js:358:18) anythingllm | at async getCustomModels (/app/server/utils/helpers/customModels.js:52:14) anythingllm | at async /app/server/endpoints/system.js:973:35 anythingllm | [backend] info: EmbeddingEngine changed from undefined to native - resetting undefined namespaces anythingllm | [backend] info: [Event Logged] - workspace_vectors_reset anythingllm | [backend] info: Resetting anythingllm managed vector namespaces for anythingllm | /usr/local/bin/docker-entrypoint.sh: line 24: 117 Illegal instruction (core dumped) node /app/server/index.js anythingllm exited with code 132 ``` Setting it up with openai at the onboarding also results in an error: ```console anythingllm | [backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }). anythingllm | at new OpenAI (/app/server/node_modules/openai/index.js:72:19) anythingllm | at openAiModels (/app/server/utils/helpers/customModels.js:100:18) anythingllm | at getCustomModels (/app/server/utils/helpers/customModels.js:46:20) anythingllm | at /app/server/endpoints/system.js:973:41 anythingllm | at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5) anythingllm | at next (/app/server/node_modules/express/lib/router/route.js:149:13) anythingllm | at /app/server/utils/middleware/multiUserProtected.js:60:7 anythingllm | at Layer.handle [as handle_request] (/app/server/node_modules/express/lib/router/layer.js:95:5) anythingllm | at next (/app/server/node_modules/express/lib/router/route.js:149:13) anythingllm | at validatedRequest (/app/server/utils/middleware/validatedRequest.js:20:5) anythingllm | [backend] info: EmbeddingEngine changed from undefined to native - resetting undefined namespaces anythingllm | [backend] info: [Event Logged] - workspace_vectors_reset anythingllm | [backend] info: Resetting anythingllm managed vector namespaces for anythingllm | /usr/local/bin/docker-entrypoint.sh: line 24: 120 Illegal instruction (core dumped) node /app/server/index.js anythingllm exited with code 132 ```
yindo changed title from [backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }). to [GH-ISSUE #3419] [backend] error: Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }). 2026-06-05 14:45:10 -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#2205