Overview
The Artifacts API provides endpoints to retrieve files generated by AI agents or uploaded by users. It supports various file types including text, HTML, binary files, and files within .skill archives.Get Artifact File
GET /api/threads/{thread_id}/artifacts/{path}
Retrieve an artifact file generated by the AI agent or uploaded by the user
Path Parameters
The thread ID
The artifact path with virtual prefix (e.g.,
mnt/user-data/outputs/file.txt)Query Parameters
If true, returns file as attachment for download. Otherwise, files are displayed inline.
Response
The response content type depends on the file type:- HTML files (
.html): Rendered as HTML (text/html) - Text files: Returned as plain text with appropriate MIME type
- Binary files: Returned with appropriate MIME type
Example Requests
View HTML File
View Text File
text/x-python MIME type
Download File
Content-Disposition: attachment header
View Uploaded File
Error Responses
Path is not a file
Access denied (path traversal attempt)
Artifact not found
.skill Archive Files
GET /api/threads/{thread_id}/artifacts/{skill_path}.skill/{internal_path}
Retrieve a file from within a .skill archive without extracting
Path Format
To access files inside .skill archives, use the format:Example Requests
View SKILL.md from Archive
View Script from Archive
scripts/install.sh inside the archive
How It Works
- The API detects
.skill/in the path - Splits the path into archive path and internal path
- Opens the .skill file (ZIP archive)
- Extracts the requested file without extracting the entire archive
- Returns the file content with appropriate MIME type
- Caches for 5 minutes to avoid repeated ZIP extraction
Error Responses
Archive or file not found
Virtual Paths
DeerFlow uses virtual paths to organize files:Outputs Directory
Files generated by AI agents:mnt/user-data/outputs/index.html- Generated web pagemnt/user-data/outputs/script.py- Generated Python scriptmnt/user-data/outputs/my-skill.skill- Packaged skill file
Uploads Directory
Files uploaded by users:mnt/user-data/uploads/document.pdf- Uploaded PDFmnt/user-data/uploads/document.md- Auto-converted markdownmnt/user-data/uploads/image.png- Uploaded image
Path Resolution
The API resolves virtual paths to actual filesystem paths:Content Types
The API automatically detects and sets appropriate MIME types:Text Files
.txt→text/plain.md→text/markdown.py→text/x-python.js→text/javascript.json→application/json.yaml,.yml→application/x-yaml
Web Files
.html→text/html(rendered in browser).css→text/css.js→text/javascript
Documents
.pdf→application/pdf.doc,.docx→application/vnd.openxmlformats-officedocument.wordprocessingml.document.xls,.xlsx→application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Images
.png→image/png.jpg,.jpeg→image/jpeg.gif→image/gif.svg→image/svg+xml
Archives
.zip→application/zip.tar.gz→application/gzip
Content Disposition
The API uses differentContent-Disposition headers:
Inline Display (Default)
Force Download
With?download=true:
Security
Path Traversal Protection
The API validates all paths to prevent directory traversal attacks:- Paths must be within the thread’s sandbox directory
- Attempts to access parent directories (
../) are blocked - Returns 403 Forbidden for unauthorized access attempts
Filename Encoding
Filenames with special characters are properly encoded using RFC 5987:- Unicode characters
- Spaces
- Special characters
Use Cases
Display Generated HTML
Download Generated File
View Artifact as Text
List Artifact URLs from Upload Response
Preview File from .skill Archive
Related
Uploads API
Upload files to threads
Gateway Overview
Learn about the Gateway API