ai.content.Media

A media payload the turn produced: a generated image, a file a provider-side tool wrote. The value is a real BAML media value, so `-> image` returns something callers can save or pass straight back into another prompt.

Reference version

Signature

class ai.content.Media

A media payload the turn produced: a generated image, a file a provider-side tool wrote. The value is a real BAML media value, so -> image returns something callers can save or pass straight back into another prompt.

Source:<builtin>/ai/ns_content/content.bamlbytes 764–2708

Fields

provider_id

string | null

revised_prompt

string | null

Static methods

function

new

(
value: image | audio | video | pdf,
provider_id: string | null = …,
revised_prompt: string | null = …
) -> ai.content.Media throws baml.errors.InvalidArgument

Wrap a media value a client just built from a provider payload. baml.media.Image.from_base64 and its siblings return the image / audio / video / pdf primitives, which are distinct static types from the baml.media.* wrapper classes MediaPart is a union of, so the value bridges through its BEP-038 {kind, source, value, mime} envelope. The decode discriminates on the envelope's kind, so the union lands on the wrapper for the value's own media kind.

Instance methods

function

kind

(self) -> string throws never

The payload's media kind: "image", "audio", "video", or "pdf".