ai.PromptMessage

A single chat message in a rendered prompt.

Reference version

Signature

class ai.PromptMessage

A single chat message in a rendered prompt.

Source:<builtin>/ai/spec.bamlbytes 16702372

Fields

role

string

The chat role, e.g. "system", "user", or "assistant". Empty for role-less content.

content

string

The 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.