BerriAI/litellm · error · ValueError

file_id must be a managed LiteLLM S3 file id

Error message

file_id must be a managed LiteLLM S3 file id

What it means

Identity guard in Bedrock file-id resolution: the value is neither a base64 LiteLLM managed file id (with the llm_output_file_id prefix) nor a direct s3:// URI, so it cannot be resolved to an S3 location and is rejected as unmanaged.

Solutions

  1. Use a file id returned by the LiteLLM managed S3 files API.
  2. Upload the file via LiteLLM first, then reference its managed id.
  3. Do not pass raw S3 URIs or foreign file ids to this endpoint.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/llms/bedrock/files/transformation.py:181 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/e6491c27d10e8129. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/bedrock/files/transformation.py:181

    Resolve a Bedrock file id to its S3 URI.

    Accepts either a base64-encoded LiteLLM unified file id (whose decoded
    form carries `llm_output_file_id,s3://...`) or a direct `s3://` URI.
    """
    try:
        padded: Final = file_id + "=" * (-len(file_id) % 4)
        decoded: Final = base64.urlsafe_b64decode(padded).decode()

        if decoded.startswith(SpecialEnums.LITELM_MANAGED_FILE_ID_PREFIX.value):
            if "llm_output_file_id," in decoded:
                return decoded.split("llm_output_file_id,")[1].split(";")[0]
    except Exception:
        pass

    if file_id.startswith("s3://"):
        return file_id

    raise ValueError("file_id must be a managed LiteLLM S3 file id")


_S3_BUCKET_REQUIRED_ERROR: Final = "S3 bucket_name is required. Set 's3_bucket_name' in proxy config or AWS_S3_BUCKET_NAME for Bedrock file content retrieval."


def _trusted_s3_model_credentials(litellm_params: Mapping[str, object]) -> _TrustedS3ModelCredentials:
    trusted_model_credentials: Final = litellm_params.get("_litellm_internal_model_credentials")
    if not isinstance(trusted_model_credentials, MappingProxyType):
        return _TrustedS3ModelCredentials()
    snapshot: Final[dict[str, object]] = {}
    snapshot.update(trusted_model_credentials)  # any-ok: untyped snapshot
    return _TrustedS3ModelCredentials.model_validate(snapshot)


def get_configured_s3_bucket_name(litellm_params: Mapping[str, object]) -> str:
    """
    Resolve the server-configured S3 bucket for Bedrock file operations.

View on GitHub (pinned to 77b7c6c40c)