Skip to main content
POST
/
v1
/
agent
/
execute
!pip install vlmrun

from vlmrun.client import VLMRun
from vlmrun.client.types import AgentExecutionResponse, AgentExecutionConfig
from vlmrun.types import MessageContent, FileUrl

# Define a Pydantic model for the execution inputs
class ExecutionInputs(BaseModel):
  file: MessageContent = Field(..., description="The file to extract data from")

# Define a Pydantic model for the response
class Invoice(BaseModel):
  invoice_id: str = Field(..., description="The ID of the invoice")
  invoice_date: datetime.date = Field(..., description="The date of the invoice")
  total_amount: float = Field(..., description="The total amount of the invoice")

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

# Upload the file to the object store
file = client.files.upload(file=Path("test.pdf"))

# Execute the agent (by name and version)
response: AgentExecutionResponse = client.agent.execute(
  name="<agent-name>:<agent-version>",
  inputs=ExecutionInputs(file=MessageContent(type="file_url", file_url=FileUrl(url=file.public_url))),
  batch=True  # Required for agent execution
)

# Execute the agent (by prompt)
response: AgentExecutionResponse = client.agent.execute(
  inputs=ExecutionInputs(file=MessageContent(type="file_url", file_url=FileUrl(url=file.public_url))),
  config=AgentExecutionConfig(prompt="Extract the invoice_id, date and amount from the invoice.", response_model=Invoice),
  batch=True  # Required for agent execution
)
{
  "name": "<string>",
  "usage": {
    "elements_processed": 123,
    "element_type": "image",
    "credits_used": 123,
    "steps": 123,
    "message": "<string>",
    "duration_seconds": 0
  },
  "id": "<string>",
  "response": "<unknown>",
  "status": "pending",
  "created_at": "2023-11-07T05:31:56Z",
  "completed_at": "2023-11-07T05:31:56Z"
}
!pip install vlmrun

from vlmrun.client import VLMRun
from vlmrun.client.types import AgentExecutionResponse, AgentExecutionConfig
from vlmrun.types import MessageContent, FileUrl

# Define a Pydantic model for the execution inputs
class ExecutionInputs(BaseModel):
  file: MessageContent = Field(..., description="The file to extract data from")

# Define a Pydantic model for the response
class Invoice(BaseModel):
  invoice_id: str = Field(..., description="The ID of the invoice")
  invoice_date: datetime.date = Field(..., description="The date of the invoice")
  total_amount: float = Field(..., description="The total amount of the invoice")

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

# Upload the file to the object store
file = client.files.upload(file=Path("test.pdf"))

# Execute the agent (by name and version)
response: AgentExecutionResponse = client.agent.execute(
  name="<agent-name>:<agent-version>",
  inputs=ExecutionInputs(file=MessageContent(type="file_url", file_url=FileUrl(url=file.public_url))),
  batch=True  # Required for agent execution
)

# Execute the agent (by prompt)
response: AgentExecutionResponse = client.agent.execute(
  inputs=ExecutionInputs(file=MessageContent(type="file_url", file_url=FileUrl(url=file.public_url))),
  config=AgentExecutionConfig(prompt="Extract the invoice_id, date and amount from the invoice.", response_model=Invoice),
  batch=True  # Required for agent execution
)

Authorizations

Authorization
string
header
required

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

Body

application/json

Request to execute an agent.

metadata
RequestMetadata · object

Optional metadata to pass to the model.

config
AgentExecutionConfig · object

The configuration for the agent execution request.

id
string

Unique identifier of the request.

created_at
string<date-time>

Date and time when the request was created (in UTC timezone)

callback_url
string<uri> | null

The URL to call when the request is completed.

Minimum string length: 1
model
enum<string>
default:vlmrun-orion-1:auto

VLM Run Agent model to use for execution

Available options:
vlmrun-orion-1,
vlmrun-orion-1:auto,
vlmrun-orion-1:fast,
vlmrun-orion-1:pro
name
string | null

Name of the agent. If not provided, we use the prompt to identify the unique agent.

batch
boolean
default:true

Whether to process the document in batch mode (async).

inputs
AgentExecutionInputs · object

The inputs to the agent.

Response

Successful Response

Response to the agent execution request.

name
string
required

Name of the agent

usage
CreditUsageResponse · object

The usage metrics for the request.

id
string

Unique identifier of the agent execution response.

response
any | null

The response from the model.

status
enum<string>
default:pending

The status of the job.

Available options:
pending,
enqueued,
running,
completed,
failed,
paused
created_at
string<date-time>

Date and time when the execution was created (in UTC timezone)

completed_at
string<date-time> | null

Date and time when the execution was completed (in UTC timezone)