Skip to content

Conversation

@github-actions
Copy link

Motivation

Users need the ability to reference media files stored in Amazon S3 buckets instead of passing raw bytes for image, document, and video content types. This enables scenarios where large media files are already stored in S3 and eliminates the need to transfer bytes directly in API calls.

AWS Bedrock API supports S3 locations for these content types:

Resolves #10

Public API Changes

ImageSource, DocumentSource, and VideoSource TypedDicts now support an optional s3Location field as an alternative to bytes:

# Before: only bytes supported
content = {
    "image": {
        "format": "png",
        "source": {"bytes": image_bytes}
    }
}

# After: S3 location also supported (Bedrock only)
content = {
    "image": {
        "format": "png",
        "source": {
            "s3Location": {
                "uri": "s3://my-bucket/images/photo.png",
                "bucketOwner": "123456789012"  # optional
            }
        }
    }
}

New S3Location TypedDict added:

class S3Location(TypedDict, total=False):
    uri: str          # Required - pattern: s3://[bucket]/[key]
    bucketOwner: str  # Optional - 12-digit AWS account ID

Use Cases

  • Large media files: Reference videos or high-resolution images stored in S3 without transferring bytes
  • Cross-account access: Use bucketOwner to reference media in other AWS accounts
  • Existing S3 workflows: Integrate with pipelines that already store assets in S3

Provider Behavior

Bedrock: Full support - S3 locations are formatted and passed to the API.

Other providers (Anthropic, OpenAI, Gemini, etc.): S3 sources are not supported. When detected, a warning is logged and the content block is skipped:

WARNING - S3 sources are not supported by {provider}, skipping content block

…ntent types

- Add S3Location TypedDict with uri and bucketOwner fields to media.py
- Update ImageSource, DocumentSource, VideoSource to support s3Location
- Update Bedrock provider to format s3Location in content blocks
- Add S3 source detection and filtering to non-Bedrock providers:
  Anthropic, OpenAI, Gemini, LiteLLM, Ollama, Mistral, LlamaAPI,
  LlamaCpp, SageMaker, Writer
- Non-Bedrock providers log warning and skip S3 content blocks
- Add comprehensive unit tests for new functionality

Resolves #10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add support of s3Location to image and document content types

2 participants