apache/seatunnel · error · ImportError

bedrock-mantle provider requires: pip install openai…

Error message

bedrock-mantle provider requires: pip install openai aws-bedrock-token-generator

What it means

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.

Solutions

  1. Run: pip install openai aws-bedrock-token-generator
  2. Verify both imports succeed with 'python -c "import openai; from aws_bedrock_token_generator import provide_token"'
  3. Ensure boto3/AWS credentials setup is also present if required by the token generator

Example fix

// before
export AI_PROVIDER=bedrock-mantle
seatunnel-cli ...   # ImportError
// after
pip install openai aws-bedrock-token-generator
export AI_PROVIDER=bedrock-mantle
Defensive patterns

Strategy: try-catch

Validate before calling

python -c "import openai; from aws_bedrock_token_generator import provide_token" || pip install openai aws-bedrock-token-generator

Try / catch

try:
    provider = BedrockMantleProvider()
except ImportError as e:
    print(f'Missing deps: {e}. Run: pip install openai aws-bedrock-token-generator')
    sys.exit(2)

Prevention

When it happens

Trigger: AI_PROVIDER=bedrock-mantle and __init__ imports 'openai' or 'aws_bedrock_token_generator', either of which raises ImportError in the current environment.

Common situations: Installed only 'openai' but not 'aws-bedrock-token-generator'; fresh venv missing both; attempted Bedrock access without installing the SigV4 helper.

Understand the failure class

Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/882ffd2165ddd2ec. Report an issue: GitHub.

Appendix: source

Thrown at seatunnel-cli/seatunnel_cli/llm_provider.py:977

    Some OpenAI models on Bedrock (e.g. openai.gpt-5.6-terra) are NOT in the
    foundation-model catalog and reject Converse/InvokeModel/ChatCompletions.
    They are served only via the OpenAI Responses API on the bedrock-mantle
    endpoint: https://bedrock-mantle.{region}.api.aws/openai/v1

    Auth uses a short-term bearer token derived from the caller's SigV4
    credentials (aws-bedrock-token-generator); tokens are refreshed
    automatically. These models do not accept `temperature` — it is omitted.
    """

    TOKEN_TTL_SECONDS = 1800  # regenerate well within the 12h token validity

    def __init__(self):
        try:
            import openai  # noqa: F401
            from aws_bedrock_token_generator import provide_token  # noqa: F401
        except ImportError as e:
            raise ImportError(
                "bedrock-mantle provider requires: "
                "pip install openai aws-bedrock-token-generator"
            ) from e

        self._region = os.environ.get(
            "AWS_REGION", os.environ.get("AWS_DEFAULT_REGION", "us-east-1"))
        self._model_id = os.environ.get("OPENAI_MODEL", "openai.gpt-5.6-terra")
        self._fast_model_id = os.environ.get("OPENAI_SMALL_FAST_MODEL", self._model_id)
        self._client = None
        self._token_born = 0.0

    def _get_client(self):
        """Return an OpenAI client for the bedrock-mantle endpoint.

        Auth uses a short-term bearer token derived from the caller's AWS
        credentials; the client (and token) is rebuilt after TOKEN_TTL_SECONDS.
        The base URL must be the model-specific ``openai/v1`` path — the
        generic ``v1`` path rejects these models (see the GPT-5.6 model card).

View on GitHub (pinned to cf67b549a7)