diff --git a/docs/docs/documentation/getting-started/installation/backend-config.md b/docs/docs/documentation/getting-started/installation/backend-config.md index 682230ddda0f..f6f2fc6925de 100644 --- a/docs/docs/documentation/getting-started/installation/backend-config.md +++ b/docs/docs/documentation/getting-started/installation/backend-config.md @@ -106,13 +106,14 @@ For usage, see [Usage - OpenID Connect](../authentication/oidc.md) Mealie supports various integrations using OpenAI. To enable OpenAI, [you must provide your OpenAI API key](https://platform.openai.com/api-keys). You can tweak how OpenAI is used using these backend settings. Please note that while OpenAI usage is optimized to reduce API costs, you're unlikely to be able to use OpenAI features with the free tier limits. -| Variables | Default | Description | -| ------------------------- | :-----: | ---------------------------------------------------------------------------------------------------------------------- | -| OPENAI_BASE_URL | None | The base URL for the OpenAI API. If you're not sure, leave this empty to use the standard OpenAI platform | -| OPENAI_API_KEY | None | Your OpenAI API Key. Enables OpenAI-related features | -| OPENAI_MODEL | gpt-4o | Which OpenAI model to use. If you're not sure, leave this empty | -| OPENAI_WORKERS | 2 | Number of OpenAI workers per request. Higher values may increase processing speed, but will incur additional API costs | -| OPENAI_SEND_DATABASE_DATA | True | Whether to send Mealie data to OpenAI to improve request accuracy. This will incur additional API costs | +| Variables | Default | Description | +| ------------------------- | :-----: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| OPENAI_BASE_URL | None | The base URL for the OpenAI API. If you're not sure, leave this empty to use the standard OpenAI platform | +| OPENAI_API_KEY | None | Your OpenAI API Key. Enables OpenAI-related features | +| OPENAI_MODEL | gpt-4o | Which OpenAI model to use. If you're not sure, leave this empty | +| OPENAI_WORKERS | 2 | Number of OpenAI workers per request. Higher values may increase processing speed, but will incur additional API costs | +| OPENAI_SEND_DATABASE_DATA | True | Whether to send Mealie data to OpenAI to improve request accuracy. This will incur additional API costs | +| OPENAI_REQUEST_TIMEOUT | 10 | The number of seconds to wait for an OpenAI request to complete before cancelling the request. Leave this empty unless you're running into timeout issues on slower hardware | ### Themeing diff --git a/mealie/core/settings/settings.py b/mealie/core/settings/settings.py index 11805a64a0ac..eadd0c4014d7 100644 --- a/mealie/core/settings/settings.py +++ b/mealie/core/settings/settings.py @@ -233,6 +233,11 @@ class AppSettings(BaseSettings): but will incur additional API costs """ + OPENAI_REQUEST_TIMEOUT: int = 10 + """ + The number of seconds to wait for an OpenAI request to complete before cancelling the request + """ + # =============================================== # Web Concurrency diff --git a/mealie/services/openai/openai.py b/mealie/services/openai/openai.py index 961101ff8fce..4e31045def51 100644 --- a/mealie/services/openai/openai.py +++ b/mealie/services/openai/openai.py @@ -54,6 +54,7 @@ class OpenAIService(BaseService): self.get_client = lambda: AsyncOpenAI( base_url=settings.OPENAI_BASE_URL, api_key=settings.OPENAI_API_KEY, + timeout=settings.OPENAI_REQUEST_TIMEOUT, ) super().__init__()