Download an artifact
Download the raw binary content of an immutable artifact version.
Endpoint
Downloads the raw content of the specified artifact. A successful call returns 200 and a binary stream.
/agents/sessions/{session_id}/artifacts/{artifact_id}/contentPath parameters
session_idstringRequiredSession that owns the artifact
artifact_idstringRequiredArtifact version ID from the list response
No request body. Accept: application/octet-stream can be sent.
Request example
curl --fail-with-body -sS -D headers.txt -o artifact.part \
"$BASE_URL/agents/sessions/sess_xxx/artifacts/artifact_xxx/content" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "OpenAI-Beta: agents=v1" \
-H "Accept: application/octet-stream"
if [ $? -eq 0 ]; then
mv artifact.part artifact.bin
wc -c artifact.bin
else
echo "download failed"
rm -f artifact.part
exit 1
fi
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["DASHSCOPE_API_KEY"],
base_url=os.environ["BASE_URL"],
)
content = client.beta.agents.sessions.artifacts.content(
"artifact_xxx",
session_id="sess_xxx",
)
with open("artifact.bin", "wb") as output:
output.write(content.content)
print(len(content.content))
Response example
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Length: 19
Content-Disposition: attachment; filename="report.txt"
A successful response has Content-Type set to application/octet-stream and includes an attachment filename. Common response headers:
| Header | Description |
|---|---|
Content-Type | application/octet-stream |
Content-Length | File size in bytes |
Content-Disposition | attachment and the filename |
Cache-Control | private, no-store |
Errors are still JSON. Do not treat an error body as artifact content. Download to a temporary file first, confirm the HTTP status, and then rename it.
Error codes
| HTTP status | Error type / code | Solution |
|---|---|---|
404 | not_found_error / not_found_error | Use an artifact ID that exists and has not been deleted in the current workspace |
The error body has the shape {"error":{"type","code","message","param"}}. Gateway or routing errors can use a different structure. Keep the HTTP status, response headers, x-request-id, and artifact ID for troubleshooting.