Execute previously created agents on files to extract structured data with consistent, reproducible results. Monitor execution status and retrieve results asynchronously for long-running processing tasks.
The following fields can be used when executing an agent. Only inputs is required.
Field
Required
Description
name
No
Agent name and version in format agent-name:version. Required if not using inline config
inputs
Yes
A Pydantic BaseModel with typed fields for each input. Files use MessageContent with type: "input_file" and a file_id. Supports multiple files via separate fields
config
No
Inline agent configuration for one-time execution without creating a persistent agent
priority
No
Execution priority: low, normal, or high. Higher priority executions are processed first. Defaults to normal
toolsets
No
List of tool categories to enable for this execution. Available categories: core, image, image-gen, world_gen, viz, document, video, web
Pass multiple files to an agent by defining a typed input model with separate fields for each file. Each field is a MessageContent with type: "input_file" and the corresponding file_id.
Copy
from pathlib import Pathfrom pydantic import BaseModel, Fieldfrom vlmrun.client import VLMRunfrom vlmrun.client.types import AgentExecutionConfigfrom vlmrun.types import MessageContentclient = VLMRun(base_url="https://agent.vlm.run/v1", api_key="<VLMRUN_API_KEY>")# Define typed inputs for multiple filesclass CompareDocsInputs(BaseModel): file_1: MessageContent = Field(..., description="First document to compare") file_2: MessageContent = Field(..., description="Second document to compare")# Upload multiple filesfile_a = client.files.upload(file=Path("document_page_1.pdf"))file_b = client.files.upload(file=Path("document_page_2.pdf"))# Execute with multiple file inputsresponse = client.agent.execute( inputs=CompareDocsInputs( file_1=MessageContent(type="input_file", file_id=file_a.id), file_2=MessageContent(type="input_file", file_id=file_b.id), ), config=AgentExecutionConfig( prompt="Compare the two documents and summarize the key differences." ),)print(f"Execution ID: {response.execution_id}")
The input field names (e.g. file_1, file_2) are flexible — use descriptive names like invoice, receipt, or contract to make your code self-documenting.
Agent executions can generate artifacts such as processed images, videos, or documents. These artifacts are returned as object references (e.g., ImageRef, VideoRef) in the response and can be retrieved using the execution ID.
Copy
from pydantic import BaseModel, Fieldfrom PIL import Imagefrom vlmrun.client import VLMRunfrom vlmrun.client.types import AgentExecutionConfig, ImageUrlfrom vlmrun.types import ImageRef, MessageContentclient = VLMRun(base_url="https://agent.vlm.run/v1", 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 that generates an image artifactexecution = client.agent.execute( name="image/blur-faces", inputs=ExecutionInputs( image=MessageContent(type="image_url", image_url=ImageUrl(url="https://example.com/photo.jpg")) # Images still use image_url ), config=AgentExecutionConfig(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)