from PIL import Imagefrom pydantic import BaseModel, Fieldfrom vlmrun.client import VLMRunfrom vlmrun.types import ImageRefclient = VLMRun(api_key="<VLMRUN_API_KEY>")# Define a response model with an ImageRef fieldclass BlurredImageResponse(BaseModel): image: ImageRef = Field(..., description="The blurred image")# Make a chat completion request that generates an image artifactresponse = client.agent.completions.create( model="vlmrun-orion-2:auto", messages=[ { "role": "user", "content": [ {"type": "text", "text": "Blur all the faces in this image"}, {"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}} ] } ], response_format={"type": "json_schema", "schema": BlurredImageResponse.model_json_schema()},)# Parse the response to get the artifact referenceresult = BlurredImageResponse.model_validate_json(response.choices[0].message.content)# Retrieve the artifact using session_id and object_idimage: Image.Image = client.artifacts.get( session_id=response.session_id, object_id=result.image.id,)
import { VlmRun } from "vlmrun";const client = new VlmRun({ baseURL: "https://api.vlm.run/v1", apiKey: "<VLMRUN_API_KEY>"});// Retrieve the artifact using session_id and object_idconst artifact = await client.artifacts.get({ sessionId: "<SESSION_ID>", objectId: "img_a1b2c3"});console.log(artifact);
Retrieve an artifact by session ID or execution ID.
GET
/
v1
/
artifacts
from PIL import Imagefrom pydantic import BaseModel, Fieldfrom vlmrun.client import VLMRunfrom vlmrun.types import ImageRefclient = VLMRun(api_key="<VLMRUN_API_KEY>")# Define a response model with an ImageRef fieldclass BlurredImageResponse(BaseModel): image: ImageRef = Field(..., description="The blurred image")# Make a chat completion request that generates an image artifactresponse = client.agent.completions.create( model="vlmrun-orion-2:auto", messages=[ { "role": "user", "content": [ {"type": "text", "text": "Blur all the faces in this image"}, {"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}} ] } ], response_format={"type": "json_schema", "schema": BlurredImageResponse.model_json_schema()},)# Parse the response to get the artifact referenceresult = BlurredImageResponse.model_validate_json(response.choices[0].message.content)# Retrieve the artifact using session_id and object_idimage: Image.Image = client.artifacts.get( session_id=response.session_id, object_id=result.image.id,)
import { VlmRun } from "vlmrun";const client = new VlmRun({ baseURL: "https://api.vlm.run/v1", apiKey: "<VLMRUN_API_KEY>"});// Retrieve the artifact using session_id and object_idconst artifact = await client.artifacts.get({ sessionId: "<SESSION_ID>", objectId: "img_a1b2c3"});console.log(artifact);
Retrieve the raw content of an artifact using either a session_id (for chat completions) or an execution_id (for agent executions), along with the object_id from the response. Artifacts are binary objects generated during agent interactions, such as images, videos, audio files, and documents.
For a comprehensive guide on working with artifacts, including usage patterns and examples, see the Artifacts Guide.
Object ID for the artifact (format: <type>_<6-hex-chars>, e.g., img_a1b2c3)
session_id
string
No
Session ID from chat completions (mutually exclusive with execution_id)
execution_id
string
No
Execution ID from agent executions (mutually exclusive with session_id)
Either session_id or execution_id must be provided, but not both. Use session_id for artifacts from chat completions and execution_id for artifacts from agent executions.
Use session_id to retrieve artifacts from chat completion responses.
from PIL import Imagefrom pydantic import BaseModel, Fieldfrom vlmrun.client import VLMRunfrom vlmrun.types import ImageRefclient = VLMRun(api_key="<VLMRUN_API_KEY>")# Define a response model with an ImageRef fieldclass BlurredImageResponse(BaseModel): image: ImageRef = Field(..., description="The blurred image")# Make a chat completion request that generates an image artifactresponse = client.agent.completions.create( model="vlmrun-orion-2:auto", messages=[ { "role": "user", "content": [ {"type": "text", "text": "Blur all the faces in this image"}, {"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}} ] } ], response_format={"type": "json_schema", "schema": BlurredImageResponse.model_json_schema()},)# Parse the response to get the artifact referenceresult = BlurredImageResponse.model_validate_json(response.choices[0].message.content)# Retrieve the artifact using session_id and object_idimage: Image.Image = client.artifacts.get( session_id=response.session_id, object_id=result.image.id,)
import { VlmRun } from "vlmrun";const client = new VlmRun({ baseURL: "https://api.vlm.run/v1", apiKey: "<VLMRUN_API_KEY>"});// Retrieve the artifact using session_id and object_idconst artifact = await client.artifacts.get({ sessionId: "<SESSION_ID>", objectId: "img_a1b2c3"});console.log(artifact);