{"record":{"id":"882ffd2165ddd2ec","repo":"apache/seatunnel","slug":"bedrock-mantle-provider-requires-pip-install-open","errorCode":null,"errorMessage":"bedrock-mantle provider requires: pip install openai aws-bedrock-token-generator","messagePattern":"bedrock-mantle provider requires: pip install openai aws-bedrock-token-generator","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"seatunnel-cli/seatunnel_cli/llm_provider.py","lineNumber":977,"sourceCode":"\n    Some OpenAI models on Bedrock (e.g. openai.gpt-5.6-terra) are NOT in the\n    foundation-model catalog and reject Converse/InvokeModel/ChatCompletions.\n    They are served only via the OpenAI Responses API on the bedrock-mantle\n    endpoint: https://bedrock-mantle.{region}.api.aws/openai/v1\n\n    Auth uses a short-term bearer token derived from the caller's SigV4\n    credentials (aws-bedrock-token-generator); tokens are refreshed\n    automatically. These models do not accept `temperature` — it is omitted.\n    \"\"\"\n\n    TOKEN_TTL_SECONDS = 1800  # regenerate well within the 12h token validity\n\n    def __init__(self):\n        try:\n            import openai  # noqa: F401\n            from aws_bedrock_token_generator import provide_token  # noqa: F401\n        except ImportError as e:\n            raise ImportError(\n                \"bedrock-mantle provider requires: \"\n                \"pip install openai aws-bedrock-token-generator\"\n            ) from e\n\n        self._region = os.environ.get(\n            \"AWS_REGION\", os.environ.get(\"AWS_DEFAULT_REGION\", \"us-east-1\"))\n        self._model_id = os.environ.get(\"OPENAI_MODEL\", \"openai.gpt-5.6-terra\")\n        self._fast_model_id = os.environ.get(\"OPENAI_SMALL_FAST_MODEL\", self._model_id)\n        self._client = None\n        self._token_born = 0.0\n\n    def _get_client(self):\n        \"\"\"Return an OpenAI client for the bedrock-mantle endpoint.\n\n        Auth uses a short-term bearer token derived from the caller's AWS\n        credentials; the client (and token) is rebuilt after TOKEN_TTL_SECONDS.\n        The base URL must be the model-specific ``openai/v1`` path — the\n        generic ``v1`` path rejects these models (see the GPT-5.6 model card).","sourceCodeStart":959,"sourceCodeEnd":995,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-cli/seatunnel_cli/llm_provider.py#L959-L995","documentation":"The bedrock-mantle provider uses the OpenAI client together with aws_bedrock_token_generator for SigV4-based token auth against Bedrock's OpenAI-compatible endpoint. If either package is missing, it raises ImportError listing both required installs.","triggerScenarios":"AI_PROVIDER=bedrock-mantle and __init__ imports 'openai' or 'aws_bedrock_token_generator', either of which raises ImportError in the current environment.","commonSituations":"Installed only 'openai' but not 'aws-bedrock-token-generator'; fresh venv missing both; attempted Bedrock access without installing the SigV4 helper.","solutions":["Run: pip install openai aws-bedrock-token-generator","Verify both imports succeed with 'python -c \"import openai; from aws_bedrock_token_generator import provide_token\"'","Ensure boto3/AWS credentials setup is also present if required by the token generator"],"exampleFix":"// before\nexport AI_PROVIDER=bedrock-mantle\nseatunnel-cli ...   # ImportError\n// after\npip install openai aws-bedrock-token-generator\nexport AI_PROVIDER=bedrock-mantle","handlingStrategy":"try-catch","validationCode":"python -c \"import openai; from aws_bedrock_token_generator import provide_token\" || pip install openai aws-bedrock-token-generator","typeGuard":null,"tryCatchPattern":"try:\n    provider = BedrockMantleProvider()\nexcept ImportError as e:\n    print(f'Missing deps: {e}. Run: pip install openai aws-bedrock-token-generator')\n    sys.exit(2)","preventionTips":["Install both packages together for bedrock-mantle","Set AWS_REGION/AWS_DEFAULT_REGION and AWS credentials up front","Smoke-test provider construction in CI","Keep the token-generator package updated for SigV4 changes"],"tags":["python","llm","dependency","aws","bedrock"],"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"}