Learn how to generate and return artifacts like images and structured data.
name
field. This allows agentic applications to implement specific semantics for handling these outputs, such as displaying structured metadata, enabling file downloads, or facilitating iterative workflows.
Refer to the Message Structure documentation for more details on the artifact definition.
This guide demonstrates how to generate common artifact types like images and JSON data within your ACP agent.
Artifact
message part.
BytesIO
buffer.Artifact
is yielded with name
, content
(base64 string), content_encoding="base64"
, and content_type="image/png"
.data
) holds the structured information.json.dumps()
converts the dictionary into a JSON string.Artifact
is yielded with name
, content
(the JSON string), and content_type="application/json"
.content_encoding
is "plain"
, which is suitable for JSON strings.