Theom
10/24/2025, 6:39 AMMarvin
10/24/2025, 6:39 AMMarvin
10/24/2025, 6:42 AMfrom prefect.artifacts import create_markdown_artifact, Artifact
# Flow A: create or update an artifact
create_markdown_artifact(
markdown="# Daily summary\nAll systems go.",
key="reports/daily-summary",
description="Daily ops report"
)
# Flow B (or any other run): read the latest artifact by key
artifact = Artifact.get(key="reports/daily-summary")
if artifact:
print("Artifact type:", artifact.type)
print("Updated:", artifact.updated)
print("Data:", artifact.data) # for markdown, this is the markdown string
else:
print("No artifact found for that key")
CLI to inspect versions
prefect artifact inspect "reports/daily-summary"
If you need a specific run’s artifact (not just the latest):
- Easiest pattern: encode the run identifier (or a timestamp) into the key when writing, then read that exact key later.
- Alternatively, you can query artifacts by flow_run_id via the REST API or the Python client filters.
Docs and references:
- Concepts: Artifacts concepts
- How-to: Artifacts how-to
- Python API: prefect.artifacts API
- CLI reference: prefect artifact CLI