Back to Baml

Image / Audio / Pdf / Video

fern/03-reference/baml_client/media.mdx

0.222.01.4 KB
Original Source

BAML functions can accept image, audio, Pdf, and video inputs for multimedia processing capabilities. Choose the appropriate type based on your needs:

<Cards> <Card title="Image" icon="image" href="./image" > Create Image objects from URLs, base64 data, or browser-specific sources like File and Blob objects. </Card>

<Card title="Audio" icon="volume-high" href="./audio"

Create Audio objects from URLs, base64 data, or browser-specific sources like File and Blob objects. </Card>

<Card title="Pdf" icon="file-pdf" href="./pdf"

Create Pdf objects from URLs, base64 data, or browser-specific sources like File and Blob objects. </Card>

<Card title="Video" icon="video" href="./video"

Create Video objects from URLs, base64 data, or browser-specific sources like File and Blob objects. </Card> </Cards>

URL Resolution

BAML automatically handles URL-to-base64 conversion based on provider requirements. You can control this behavior using the media_url_handler configuration option in your client definition.

By default:

  • URLs are converted to base64 for providers that don't support external URLs
  • Google Cloud Storage URLs (gs://) are preserved when using Google providers
  • MIME types are added when required by the provider

See the client configuration documentation for provider-specific defaults and configuration options.