ai.PromptMessage
A single chat message in a rendered prompt.
Reference version
Signature
class ai.PromptMessageA single chat message in a rendered prompt.
Source:<builtin>/ai/spec.bamlbytes 1670–2372
Fields
role
stringThe chat role, e.g. "system", "user", or "assistant". Empty for role-less content.
content
stringThe message's rendered text. Media parts use a readable placeholder.
parts
ai.PromptPart[]Ordered structural content. Provider clients use this instead of the
readable content projection so media survives prompt rendering.
metadata
map<string, baml.json.json>Per-message provider directives, carried verbatim from the
ai.Role.metadata of the ${role(...)} marker that opened
this message — Anthropic cache_control, for example. Empty when the
message carried none.