Object References
Agent responses return object references (refs) instead of raw binary data. Each reference is a string identifier that follows a specific format: a 3-5 letter type prefix followed by an underscore and a 6-digit hexadecimal string (e.g.,img_a1b2c3).
| Artifact Type | Prefix | Reference Type | Python Return Type |
|---|---|---|---|
| Image | img_ | ImageRef | PIL.Image.Image |
| Video | vid_ | VideoRef | Path (mp4) |
| Audio | aud_ | AudioRef | Path (mp3) |
| Document | doc_ | DocumentRef | Path (pdf) |
| Reconstruction | recon_ | ReconRef | Path (spz) |
| URL | url_ | UrlRef | Path (any of the above) |
| Array | arr_ | ArrayRef | np.ndarray |
Retrieving an Artifact
In a Chat Completion
To retrieve a chat completion artifact, use thesession_id from the chat response and the object_id (returned as a Ref type) from the JSON result.
In an Agent Execution
To retrieve an artifact for a specific agent execution, use theexecution_id from the agent execution response and the object_id (returned as a Ref type) from the JSON result.
Python
Retrieving Multiple Artifacts
Agents can return multiple artifacts in a single response:Python
Artifact Caching
The Python and Node SDKs automatically caches downloaded artifacts to avoid re-downloading the same files. Artifacts are stored in~/.vlmrun/artifacts/{session_id}/ with filenames based on the object ID and appropriate file extension.
Python
Common Use Cases
Multi-modal Artifacts
Generate multi-modal artifacts such as images and videos.
Multiple Artifacts
Generate multiple images of a scene (e.g. virtual try-on, video thumbnails, etc.).
Document Processing
Redact sensitive information from documents, and return the processed document as a PDF.
3D Reconstruction
Generate 3D models from images or videos, and return ply/spz files.
Best Practices
When working with artifacts, keep these guidelines in mind:- For large artifacts like videos, the Python and Node SDKs download files to disk rather than loading them into memory. This prevents memory issues when working with large files. Always check the file size before loading video content into memory.
-
Use structured response models with appropriate
Reftypes (ImageRef,VideoRef, etc.) to ensure type safety and enable IDE autocompletion. The Python and Node SDKs will automatically handle the conversion to the appropriate Python type when retrieving artifacts.
API Reference
View the complete API reference for artifact retrieval