{"record":{"id":"69fc971dd3268107","repo":"apache/seatunnel","slug":"openai-package-required-for-ai-provider-orcarouter","errorCode":null,"errorMessage":"openai package required for AI_PROVIDER=orcarouter. Install it: pip install openai","messagePattern":"openai package required for AI_PROVIDER=orcarouter\\. Install it: pip install openai","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"seatunnel-cli/seatunnel_cli/llm_provider.py","lineNumber":1279,"sourceCode":"    addressed as ``provider/model``, e.g. ``orcarouter/auto`` routes and\n    grades automatically. Defaults to the ``orcarouter/auto`` model, which\n    automatically selects the best model for each request.\n\n    Since OrcaRouter speaks the OpenAI Chat Completions protocol, this\n    provider mirrors :class:`OpenAIProvider` and only customizes the base\n    URL, the API key environment variable, and the default model.\n    \"\"\"\n\n    #: OrcaRouter's OpenAI-compatible base URL.\n    DEFAULT_BASE_URL = \"https://api.orcarouter.ai/v1\"\n    #: Default model: auto-routes to the best model for the request.\n    DEFAULT_MODEL = \"orcarouter/auto\"\n\n    def __init__(self):\n        try:\n            import openai\n        except ImportError:\n            raise ImportError(\n                \"openai package required for AI_PROVIDER=orcarouter. \"\n                \"Install it: pip install openai\"\n            )\n\n        api_key = os.environ.get(\"ORCAROUTER_API_KEY\")\n        if not api_key:\n            raise ValueError(\n                \"ORCAROUTER_API_KEY environment variable is required for \"\n                \"AI_PROVIDER=orcarouter\"\n            )\n\n        self._model_id = os.environ.get(\n            \"ORCAROUTER_MODEL\",\n            os.environ.get(\"OPENAI_MODEL\", self.DEFAULT_MODEL))\n        self._fast_model_id = os.environ.get(\n            \"ORCAROUTER_SMALL_FAST_MODEL\",\n            os.environ.get(\"OPENAI_SMALL_FAST_MODEL\", self._model_id))\n        self._client = openai.OpenAI(api_key=api_key, base_url=self.DEFAULT_BASE_URL)","sourceCodeStart":1261,"sourceCodeEnd":1297,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-cli/seatunnel_cli/llm_provider.py#L1261-L1297","documentation":"The OrcaRouter provider class requires the third-party openai Python package (used as its client SDK). If importing openai fails at construction time, an ImportError with install instructions is raised so the user knows exactly which optional dependency is missing.","triggerScenarios":"Instantiating the orcarouter provider (via create_provider(\"orcarouter\") or AI_PROVIDER=orcarouter) in an environment where the openai package is not installed; the `import openai` inside __init__ raises ImportError.","commonSituations":"Fresh virtualenvs or minimal installs where only seatunnel-cli's core dependencies are present; CI containers built without extras; users switching AI_PROVIDER to orcarouter without installing the extra.","solutions":["Run `pip install openai` in the active environment","Install the CLI with its LLM extras (e.g. pip install seatunnel-cli[llm] if provided)","Verify with `python -c \"import openai\"` that the package resolves in the same interpreter running seatunnel"],"exampleFix":"// before\n$ seatunnel --provider orcarouter\nImportError: openai package required...\n// after\n$ pip install openai\n$ seatunnel --provider orcarouter","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec(\"openai\") is None:\n    raise SystemExit(\"Install the openai package: pip install openai\")","typeGuard":null,"tryCatchPattern":"try:\n    provider = create_provider(\"orcarouter\")\nexcept ImportError as e:\n    print(f\"Missing dependency: {e}; run pip install openai\")\n    sys.exit(1)","preventionTips":["Pin the openai package in requirements.txt or the CLI's llm extra","Run a startup dependency check before invoking LLM commands","Use one dedicated virtualenv for the CLI so installed extras are not lost"],"tags":["python","dependency","openai","installation"],"backgroundTag":"missing-optional-dependency","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}