Use this file to discover all available pages before exploring further.
Artifacts are binary objects generated during agent interactions, such as images, videos, audio files, and documents. When agents perform operations like image generation, face blurring, video trimming, or document processing, the results are stored as artifacts that can be retrieved using 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
Import reference types from the SDK:
from vlmrun.types import ImageRef, VideoRef, AudioRef, DocumentRef, ReconRef, UrlRef
To retrieve an artifact for a specific agent execution, use the execution_id from the agent execution response and the object_id (returned as a Ref type) from the JSON result.
Python
from pydantic import BaseModel, Fieldfrom PIL import Imagefrom vlmrun.client import VLMRunfrom vlmrun.client.types import AgentExecutionResponse, AgentExecutionConfig, ImageUrlfrom vlmrun.types import ImageRef, MessageContentclient = VLMRun(api_key="<VLMRUN_API_KEY>")# Define typed inputs using MessageContentclass ExecutionInputs(BaseModel): image: MessageContent = Field(..., description="The input image")class ImageResponse(BaseModel): image: ImageRef = Field(..., description="The processed image")# Execute an agent with typed inputsexecution: AgentExecutionResponse = client.agent.execute( name="image/blur-image", inputs=ExecutionInputs( image=MessageContent(type="image_url", image_url=ImageUrl(url="https://example.com/photo.jpg")) ), config=AgentExecutionConfig( prompt="Blur the entire image", response_model=ImageResponse ))# Wait for completionexecution = client.executions.wait(execution.id, timeout=180)# Parse the response and retrieve the artifactresult = ImageResponse.model_validate(execution.response)image: Image.Image = client.artifacts.get( execution_id=execution.id, object_id=result.image.id)
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
# First call downloads the artifactvideo_path = client.artifacts.get(session_id=session_id, object_id="vid_a1b2c3")# Subsequent calls return the cached file pathvideo_path = client.artifacts.get(session_id=session_id, object_id="vid_a1b2c3") # No download
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 Ref types (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