zylon-ai/private-gpt · error · ImportError

OpenAI Responses LLM dependencies are not installed. Install

Error message

OpenAI Responses LLM dependencies are not installed. Install with `uv sync --inexact --extra llm-openai`.

What it means

ImportError raised by OpenAIResponsesLLMLoader._load_patched_openai_responses: the lazy import of PatchedOpenAIResponsesLLM from the custom openairesponses module failed, meaning the optional 'llm-openai' extra (OpenAI packages including Responses API support) is missing. The generic Responses factory uses this loader for api.openai.com traffic.

Source

Thrown at private_gpt/components/llm/factories/responses/generic.py:24

from private_gpt.components.llm.tokenizers.tokenizer_base import TokenizerBase
from private_gpt.components.model_discovery.url_utils import is_openai_api_base
from private_gpt.settings.settings import LLMModelConfig, Settings
from private_gpt.utils.dependencies import format_missing_dependency_message


class OpenAIResponsesLLMLoader:
    """Mixin providing lazy-loaded access to PatchedOpenAIResponsesLLM."""

    @staticmethod
    def _load_patched_openai_responses() -> type[Any]:
        try:
            from private_gpt.components.llm.custom.openairesponses import (
                PatchedOpenAIResponsesLLM,
            )

            return PatchedOpenAIResponsesLLM
        except ImportError as e:
            raise ImportError(
                format_missing_dependency_message(
                    "OpenAI Responses LLM",
                    extras="llm-openai",
                )
            ) from e


class OpenAIGenericResponsesFactory(LLMFactory):
    """Responses API router.

    Routes to OpenAIResponsesFactory for api.openai.com,
    otherwise delegates to OpenAILikeResponsesFactory.
    """

    def __init__(self, settings: Settings):
        super().__init__(settings)
        self.openai_settings = settings.openai

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Run `uv sync --inexact --extra llm-openai`.
  2. If already installed, upgrade the openai package to a version supporting the Responses API and reinstall the extra.
  3. Rebuild Docker/CI images with the extra included.

Example fix

# before
uv sync

# after
uv sync --inexact --extra llm-openai
Defensive patterns

Strategy: validation

Validate before calling

def responses_api_available() -> bool:
    try:
        from openai.types import responses  # noqa: F401
        return True
    except ImportError:
        return False

Try / catch

try:
    factory = OpenAIGenericResponsesFactory(settings)
except ImportError as e:
    if 'llm-openai' in str(e):
        raise SystemExit('Run: uv sync --inexact --extra llm-openai') from e
    raise

Prevention

When it happens

Trigger: Configuring the Responses API route for api.openai.com without the llm-openai extra installed, or with an openai package version too old to provide the Responses API surface the custom module imports.

Common situations: Minimal installs (`uv sync` with no extras); pinned old openai SDK versions that predate the Responses API; CI images built without the extra.

Related errors


AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15). Data as JSON: /api/errors/90478e3d8760a9b8. Report an issue: GitHub.