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

from pydantic import BaseModel, Field
import datetime

from vlmrun.client import VLMRun
from vlmrun.client.types import AgentCreationResponse, AgentCreationConfig, AgentExecutionResponse
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>")

# Create the agent using a prompt
response: AgentCreationResponse = client.agent.create(
  name="invoice-extractor",  # Optional name
  inputs=ExecutionInputs(file=MessageContent(type="file_url", file_url=FileUrl(url="https://example.com/invoice.pdf")))  # Optional test inputs
  config=AgentCreationConfig(prompt="Extract the invoice_id, date and amount from the invoice.", response_model=Invoice),
)
{
  "id": "<string>",
  "name": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z",
  "status": "pending"
}
!pip install vlmrun

from pydantic import BaseModel, Field
import datetime

from vlmrun.client import VLMRun
from vlmrun.client.types import AgentCreationResponse, AgentCreationConfig, AgentExecutionResponse
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>")

# Create the agent using a prompt
response: AgentCreationResponse = client.agent.create(
  name="invoice-extractor",  # Optional name
  inputs=ExecutionInputs(file=MessageContent(type="file_url", file_url=FileUrl(url="https://example.com/invoice.pdf")))  # Optional test inputs
  config=AgentCreationConfig(prompt="Extract the invoice_id, date and amount from the invoice.", response_model=Invoice),
)

Authorizations

Authorization
string
header
required

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

Body

application/json

Request to create an agent.

config
AgentCreationConfig · object

The configuration for the agent creation 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 agent creation

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, a pretty-name will be generated.

inputs
AgentExecutionInputs · object

The inputs to the agent.

Response

Successful Response

Response to the agent creation request.

id
string
required

ID of the agent

name
string
required

Name of the agent

created_at
string<date-time>
required

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

updated_at
string<date-time>
required

Date and time when the agent was updated (in UTC timezone)

status
enum<string>
default:pending

The status of the job.

Available options:
pending,
enqueued,
running,
completed,
failed,
paused