From 582277bf74b25ef01060f86dfad13e5e6a62b080 Mon Sep 17 00:00:00 2001 From: Justin Hayes Date: Wed, 13 Mar 2024 09:59:41 -0400 Subject: [PATCH 1/2] Create openai.md Add multiple OpenAI endpoints config tutorial --- docs/tutorial/openai.md | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/tutorial/openai.md diff --git a/docs/tutorial/openai.md b/docs/tutorial/openai.md new file mode 100644 index 0000000..05178fd --- /dev/null +++ b/docs/tutorial/openai.md @@ -0,0 +1,43 @@ +--- +sidebar_position: 1 +title: "OpenAI API" +--- + +# OpenAI Connections + +In this tutorial, we will demonstrate how to configure multiple OpenAI (or compatible) API endpoints using environment variables. This setup allows you to easily switch between different API providers or use multiple providers simultaneously, while keeping your configuration between container updates, rebuilds or redeployments. + +## Docker Run + +Here's an example `docker run` command similar to what you might use for Open-WebUI: +```bash +docker run -d -p 3000:8080 \ + -v open-webui:/app/backend/data \ + -e OPENAI_API_BASE_URLS="https://api.openai.com/v1;https://api.mistral.ai/v1" \ + -e OPENAI_API_KEYS=";" \ + --name open-webui \ + --restart always \ + ghcr.io/open-webui/open-webui:main +``` +This command sets the following environment variables: + +* `OPENAI_API_BASE_URLS`: A list of API base URLs separated by semicolons (;). In this example, we use OpenAI and Mistral. +* `OPENAI_API_KEYS`: A list of API keys corresponding to the base URLs specified in `OPENAI_API_BASE_URLS`. Make sure to replace `` and `` with your actual API keys. + +You can adapt this command to your own needs, and add even more endpoint/key pairs, but make sure to include the environment variables as shown above. + +## Docker Compose + +Alternatively, you can use a `docker-compose.yaml` file to define and run the Open-WebUI container. Here's an abridged version of what that might look like: +```yaml +services: + open-webui: + environment: + - 'OPENAI_API_BASE_URLS=${OPENAI_API_BASE_URLS}' + - 'OPENAI_API_KEYS=${OPENAI_API_KEYS}' +``` +You can edit the ${VARIABLES} directly, or optionally define the values of these variables in an `.env` file, which should be placed in the same directory as the `docker-compose.yaml` file: +```ini +OPENAI_API_BASE_URLS="https://api.openai.com/v1;https://api.mistral.ai/v1" +OPENAI_API_KEYS=";" +``` From aafa202399137441f2c7b2ca9e8f69b66cb7b8be Mon Sep 17 00:00:00 2001 From: Justin Hayes Date: Wed, 13 Mar 2024 10:02:41 -0400 Subject: [PATCH 2/2] Update openai.md --- docs/tutorial/openai.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/openai.md b/docs/tutorial/openai.md index 05178fd..4511bc4 100644 --- a/docs/tutorial/openai.md +++ b/docs/tutorial/openai.md @@ -36,7 +36,7 @@ services: - 'OPENAI_API_BASE_URLS=${OPENAI_API_BASE_URLS}' - 'OPENAI_API_KEYS=${OPENAI_API_KEYS}' ``` -You can edit the ${VARIABLES} directly, or optionally define the values of these variables in an `.env` file, which should be placed in the same directory as the `docker-compose.yaml` file: +You can edit the `${VARIABLES}` directly, or optionally define the values of these variables in an `.env` file, which should be placed in the same directory as the `docker-compose.yaml` file: ```ini OPENAI_API_BASE_URLS="https://api.openai.com/v1;https://api.mistral.ai/v1" OPENAI_API_KEYS=";"