{"record":{"id":"9aa4065af84f06a6","repo":"apache/seatunnel","slug":"anthropic-package-required-for-ai-provider-anthrop","errorCode":null,"errorMessage":"anthropic package required for AI_PROVIDER=anthropic. Install it: pip install anthropic","messagePattern":"anthropic package required for AI_PROVIDER=anthropic\\. Install it: pip install anthropic","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"seatunnel-cli/seatunnel_cli/llm_provider.py","lineNumber":478,"sourceCode":"                    yield {\"type\": \"tool_input_delta\", \"tool_use_id\": current_tool_id or \"\", \"delta\": delta[\"toolUse\"].get(\"input\", \"\")}\n            elif \"contentBlockStop\" in event:\n                if current_tool_id:\n                    yield {\"type\": \"tool_stop\", \"tool_use_id\": current_tool_id}\n                    current_tool_id = None\n            elif \"messageStop\" in event:\n                yield {\"type\": \"message_stop\", \"stop_reason\": event[\"messageStop\"].get(\"stopReason\", \"end_turn\")}\n\n\n# ─── Anthropic Provider ───\n\nclass AnthropicProvider(LLMProvider):\n    \"\"\"Anthropic Messages API provider (direct, not via Bedrock).\"\"\"\n\n    def __init__(self):\n        try:\n            import anthropic\n        except ImportError:\n            raise ImportError(\n                \"anthropic package required for AI_PROVIDER=anthropic. \"\n                \"Install it: pip install anthropic\"\n            )\n\n        api_key = os.environ.get(\"ANTHROPIC_API_KEY\")\n        if not api_key:\n            raise ValueError(\"ANTHROPIC_API_KEY environment variable is required for AI_PROVIDER=anthropic\")\n\n        self._client = anthropic.Anthropic(api_key=api_key)\n        self._model_id = os.environ.get(\"ANTHROPIC_MODEL\", \"claude-sonnet-4-20250514\")\n        self._fast_model_id = os.environ.get(\"ANTHROPIC_SMALL_FAST_MODEL\", \"claude-haiku-4-5-20251001\")\n\n    @property\n    def provider_name(self) -> str:\n        return \"anthropic\"\n\n    @property\n    def model_id(self) -> str:","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-cli/seatunnel_cli/llm_provider.py#L460-L496","documentation":"AnthropicProvider initializes the Anthropic Messages API client and imports the third-party 'anthropic' package lazily. If the package is not installed, it raises ImportError with an install hint before any API call is made.","triggerScenarios":"AI_PROVIDER=anthropic selects AnthropicProvider and its __init__ runs 'import anthropic', which fails because the package is absent from the current Python environment.","commonSituations":"Installed seatunnel-cli without the anthropic extra; running inside a fresh venv/container lacking the dependency; forgot 'pip install anthropic' after switching AI_PROVIDER.","solutions":["Run: pip install anthropic in the active environment","Install with the CLI's LLM extra if provided (e.g. pip install 'seatunnel-cli[anthropic]')","Verify with 'python -c \"import anthropic\"' that the same interpreter running the CLI has the package"],"exampleFix":"// before\nexport AI_PROVIDER=anthropic\nseatunnel-cli ...   # ImportError\n// after\npip install anthropic\nexport AI_PROVIDER=anthropic","handlingStrategy":"try-catch","validationCode":"python -c \"import anthropic\" || pip install anthropic","typeGuard":null,"tryCatchPattern":"try:\n    provider = get_provider()\nexcept ImportError as e:\n    print(f'Missing LLM dependency: {e}. Run: pip install anthropic')\n    sys.exit(2)","preventionTips":["Install CLI LLM extras in the same venv used to run the CLI","Pin anthropic in your requirements/setup","Verify imports in CI before invoking LLM features","Avoid switching AI_PROVIDER without installing its package"],"tags":["python","llm","dependency","anthropic"],"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"}