Skip to main content
GET
/
v1
/
artifacts
/
{session_id}
/
{object_id}
from pydantic import BaseModel, Field
from vlmrun.client import VLMRun
from vlmrun.types.refs import ImageRef

client = VLMRun(base_url="https://agent.vlm.run/v1", api_key="<VLMRUN_API_KEY>")

# Define a Pydantic model to get the image artifact ID for the response.
class GeneratedImageResponse(BaseModel):
    id: ImageRef = Field(..., description="The ID of the generated image")

# Generate an image, which returns an `ImageRef`
response = client.agent.completions.create(
    model="vlmrun-orion-1:auto",
    messages=[
        {"role": "user", "content": "Generate an image of a cat"},
    ],
    response_format={"type": "json_schema", "schema": GeneratedImageResponse.model_json_schema()},
)

# Validate the response and get the image artifact ID
img_response: GeneratedImageResponse = GeneratedImageResponse.model_validate_json(response.choices[0].message.content)

# Get the generated image by session_id and object_id
# Here we convert the `ImageRef` to a `PIL.Image.Image` as a convenience for the user.
image: PIL.Image.Image = client.artifacts.get(
    session_id=response.session_id,
    object_id=img_response.id,
)
"<any>"
Retrieve the raw content of an artifact associated with a specific session and object ID. Artifacts are object references generated during agent executions and can include images, documents, or other binary content. They typically take the form of an 3-5 letter string (img_, vid_, doc_, aud_, recon_, url_, arr_) followed by a 6-digit hex string (<6-digit-hex-string>). The following is the mapping between the artifact type and the object reference:
Artifact TypedtypeReference NameReference Type
ImagePIL.Image.Imageimg_<6-digit-hex-string>ImageRef
VideoPath (mp4, mov, etc.)vid_<6-digit-hex-string>VideoRef
DocumentPath (pdf, docx, txt, etc.)doc_<6-digit-hex-string>DocumentRef
AudioPath (wav or mp3)aud_<6-digit-hex-string>AudioRef
ReconPath (ply or spz)recon_<6-digit-hex-string>ReconRef
URLAnyHttpUrl (URL of the file)url_<6-digit-hex-string>UrlRef
Arraynp.ndarray (numpy array)arr_<6-digit-hex-string>ArrayRef
The Python and Node SDKs provide convenience methods to get an artifact and return it popular dtypes such as PIL Images, or Paths to local files. For example:

Response

Returns the raw binary content of the artifact with the appropriate content type.
from pydantic import BaseModel, Field
from vlmrun.client import VLMRun
from vlmrun.types.refs import ImageRef

client = VLMRun(base_url="https://agent.vlm.run/v1", api_key="<VLMRUN_API_KEY>")

# Define a Pydantic model to get the image artifact ID for the response.
class GeneratedImageResponse(BaseModel):
    id: ImageRef = Field(..., description="The ID of the generated image")

# Generate an image, which returns an `ImageRef`
response = client.agent.completions.create(
    model="vlmrun-orion-1:auto",
    messages=[
        {"role": "user", "content": "Generate an image of a cat"},
    ],
    response_format={"type": "json_schema", "schema": GeneratedImageResponse.model_json_schema()},
)

# Validate the response and get the image artifact ID
img_response: GeneratedImageResponse = GeneratedImageResponse.model_validate_json(response.choices[0].message.content)

# Get the generated image by session_id and object_id
# Here we convert the `ImageRef` to a `PIL.Image.Image` as a convenience for the user.
image: PIL.Image.Image = client.artifacts.get(
    session_id=response.session_id,
    object_id=img_response.id,
)

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

session_id
string
required
object_id
string
required

Response

Successful Response

The response is of type any.