Skip to content

UserImagePrompt

🛈 DocStrings

A user prompt containing a single base64-encoded image.

Source code in src/clawd_code_sdk/models/prompts.py
@dataclass
class UserImagePrompt:
    """A user prompt containing a single base64-encoded image."""

    image_data: str
    """Base64-encoded image data."""
    media_type: ImageMediaType
    """MIME type of the image."""

    def to_content_block(self) -> BetaImageBlockParam:
        """Return the Anthropic API content block dict."""
        return BetaImageBlockParam(
            type="image",
            source=BetaBase64ImageSourceParam(
                type="base64",
                media_type=self.media_type,
                data=self.image_data,
            ),
        )

image_data instance-attribute

image_data: str

Base64-encoded image data.

media_type instance-attribute

media_type: ImageMediaType

MIME type of the image.

to_content_block

to_content_block() -> BetaImageBlockParam

Return the Anthropic API content block dict.

Source code in src/clawd_code_sdk/models/prompts.py
def to_content_block(self) -> BetaImageBlockParam:
    """Return the Anthropic API content block dict."""
    return BetaImageBlockParam(
        type="image",
        source=BetaBase64ImageSourceParam(
            type="base64",
            media_type=self.media_type,
            data=self.image_data,
        ),
    )

:fa-brands-github: Show source on GitHub