Learn how to generate and return artifacts like images and structured data.
name
field that allows consuming applications to implement specific handling semantics—such as offering downloads, displaying rich content, or enabling iterative workflows.
Common use cases for artifacts include:
Artifact
message part.
content_encoding="base64"
for binary dataBytesIO
bufferArtifact
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.