[GH-ISSUE #1135] OpenAI API Key disappeared after updating #12355

Closed
opened 2026-04-19 19:15:21 -05:00 by GiteaMirror · 12 comments
Owner

Originally created by @taidbui on GitHub (Mar 11, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/1135

I am wondering if it only happens to me or not, but my OpenAI API Key is always lost when updating a new version of the app via docker update using the following command (as suggested in the documentation): docker run --rm --volume /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once open-webui

Is there a quick fix for this?

Originally created by @taidbui on GitHub (Mar 11, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/1135 I am wondering if it only happens to me or not, but my OpenAI API Key is always lost when updating a new version of the app via docker update using the following command (as suggested in the documentation): `docker run --rm --volume /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once open-webui` Is there a quick fix for this?
Author
Owner

@justinh-rahb commented on GitHub (Mar 11, 2024):

docker run --rm --volume /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once open-webui

Try this:

docker rm -f open-webui
docker run -d -p 3000:8080 -e OPENAI_API_KEY=your_openai_api_key_goes_here --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main

Modify the docker run accordingly to how you originally ran it, the important part is adding the -e OPENAI_API_KEY=your_openai_api_key_goes_here part to it.

<!-- gh-comment-id:1988627728 --> @justinh-rahb commented on GitHub (Mar 11, 2024): > docker run --rm --volume /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once open-webui Try this: ```bash docker rm -f open-webui docker run -d -p 3000:8080 -e OPENAI_API_KEY=your_openai_api_key_goes_here --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main ``` Modify the `docker run` accordingly to how you originally ran it, the important part is adding the `-e OPENAI_API_KEY=your_openai_api_key_goes_here` part to it.
Author
Owner

@taidbui commented on GitHub (Mar 11, 2024):

Thanks. Looks good. I will try next time.

<!-- gh-comment-id:1988798174 --> @taidbui commented on GitHub (Mar 11, 2024): Thanks. Looks good. I will try next time.
Author
Owner

@Mortezanavidi commented on GitHub (Mar 11, 2024):

the problem is that OPENAI_API_KEY works but OPENAI_BASE_URL doessn't work, unfortunately if we edit openai base url, it won't save it and gives error

<!-- gh-comment-id:1989245991 --> @Mortezanavidi commented on GitHub (Mar 11, 2024): the problem is that OPENAI_API_KEY works but OPENAI_BASE_URL doessn't work, unfortunately if we edit openai base url, it won't save it and gives error
Author
Owner

@tjbck commented on GitHub (Mar 11, 2024):

@Mortezanavidi The correct environment variable is OPENAI_API_BASE_URL :)

<!-- gh-comment-id:1989262868 --> @tjbck commented on GitHub (Mar 11, 2024): @Mortezanavidi The correct environment variable is `OPENAI_API_BASE_URL` :)
Author
Owner

@Mortezanavidi commented on GitHub (Mar 11, 2024):

@tjbck thank you for mentioning that, it worked but it didn't fixed the problem, the error i'mg getting is:
"GET /openai/api/models HTTP/1.1" 500 Internal Server Error
even tho the api proxy is working well and i can use it with other apps without a problem

<!-- gh-comment-id:1989407193 --> @Mortezanavidi commented on GitHub (Mar 11, 2024): @tjbck thank you for mentioning that, it worked but it didn't fixed the problem, the error i'mg getting is: ` "GET /openai/api/models HTTP/1.1" 500 Internal Server Error ` even tho the api proxy is working well and i can use it with other apps without a problem
Author
Owner

@justinh-rahb commented on GitHub (Mar 11, 2024):

What are you using as the endpoint URL?

<!-- gh-comment-id:1989431773 --> @justinh-rahb commented on GitHub (Mar 11, 2024): What are you using as the endpoint URL?
Author
Owner

@Mortezanavidi commented on GitHub (Mar 11, 2024):

a simple fastapi model that i created myself over my other apis, something close to litellm, it has the /v1/models endpoint with the correct json output result.
as of OPENAI_API_BASE_URL, my address is localhost:10000/v1

<!-- gh-comment-id:1989439725 --> @Mortezanavidi commented on GitHub (Mar 11, 2024): a simple fastapi model that i created myself over my other apis, something close to litellm, it has the /v1/models endpoint with the correct json output result. as of OPENAI_API_BASE_URL, my address is localhost:10000/v1
Author
Owner

@Mortezanavidi commented on GitHub (Mar 12, 2024):

any progress on this? my api is giving 200 ok response which means openwebui is accessing it successfully, but on openwebui i am getting 500 internal error

<!-- gh-comment-id:1990876202 --> @Mortezanavidi commented on GitHub (Mar 12, 2024): any progress on this? my api is giving 200 ok response which means openwebui is accessing it successfully, but on openwebui i am getting 500 internal error
Author
Owner

@Mortezanavidi commented on GitHub (Mar 12, 2024):

i just checked it with default https://api.openai.com/v1 and my own api and it gives the same 500 error on a fresh install (new volume as well)

<!-- gh-comment-id:1990911069 --> @Mortezanavidi commented on GitHub (Mar 12, 2024): i just checked it with default https://api.openai.com/v1 and my own api and it gives the same 500 error on a fresh install (new volume as well)
Author
Owner

@tjbck commented on GitHub (Mar 12, 2024):

@Mortezanavidi Could you share a screenshot of your settings with us.

<!-- gh-comment-id:1992431341 --> @tjbck commented on GitHub (Mar 12, 2024): @Mortezanavidi Could you share a screenshot of your settings with us.
Author
Owner

@gramakri commented on GitHub (May 3, 2024):

I am the author of the Cloudron package for openwebui and I am seeing the same issue.

11:21:01 - INFO:apps.openai.main:get_all_models()
11:21:01 - INFO:     89.247.165.150:0 - "GET /openai/api/models HTTP/1.1" 500 Internal Server Error

Restarting the app makes the error go away. But it didn't save the settings in any case.

<!-- gh-comment-id:2092631226 --> @gramakri commented on GitHub (May 3, 2024): I am the author of the Cloudron package for openwebui and I am seeing the same issue. ``` 11:21:01 - INFO:apps.openai.main:get_all_models() 11:21:01 - INFO: 89.247.165.150:0 - "GET /openai/api/models HTTP/1.1" 500 Internal Server Error ``` Restarting the app makes the error go away. But it didn't save the settings in any case.
Author
Owner

@gramakri commented on GitHub (May 3, 2024):

@tjbck Just debugging this a bit. I think the issue is simply that these settings are never stored in the database. https://github.com/open-webui/open-webui/blob/main/backend/apps/openai/main.py#L81 seems to just modify the app state and thus it is lost across restart.

Maybe the settings UI is not supposed to work and it is simply showing environment variables? I can confirm that after setting env vars OPENAI_API_BASE_URLS and OPENAI_API_KEYS, it works.

image

<!-- gh-comment-id:2092652900 --> @gramakri commented on GitHub (May 3, 2024): @tjbck Just debugging this a bit. I think the issue is simply that these settings are never stored in the database. https://github.com/open-webui/open-webui/blob/main/backend/apps/openai/main.py#L81 seems to just modify the app state and thus it is lost across restart. Maybe the settings UI is not supposed to work and it is simply showing environment variables? I can confirm that after setting env vars `OPENAI_API_BASE_URLS` and `OPENAI_API_KEYS`, it works. ![image](https://github.com/open-webui/open-webui/assets/82041/28cf184f-d535-48b7-b28d-12e262249008)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#12355