Skip to main content

Download an artifact

Download the raw binary content of an immutable artifact version.

Endpoint

GET /agents/sessions/{session_id}/artifacts/{artifact_id}/content Downloads the raw content of the specified artifact. A successful call returns 200 and a binary stream.

Path parameters

session_id string (required)Session that owns the artifactartifact_id string (required)Artifact version ID from the list responseNo 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

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:
HeaderDescription
Content-Typeapplication/octet-stream
Content-LengthFile size in bytes
Content-Dispositionattachment and the filename
Cache-Controlprivate, 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 statusError type / codeSolution
404not_found_error / not_found_errorUse 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.