Chat Completions
import { VlmRun } from "vlmrun";
// Initialize the client
const client = new VlmRun({
apiKey: "<VLMRUN_API_KEY>",
baseURL: "https://api.vlm.run/v1"
});
// Basic text completion
const response = await client.agent.completions.create({
model: "vlmrun-orion-1:auto",
messages: [
{ role: "user", content: "What is the capital of France?" }
]
});
console.log(response.choices[0].message.content);
Image Analysis
import { VlmRun } from "vlmrun";
const client = new VlmRun({
apiKey: "<VLMRUN_API_KEY>",
baseURL: "https://api.vlm.run/v1"
});
// Analyze an image
const response = await client.agent.completions.create({
model: "vlmrun-orion-1:auto",
messages: [
{
role: "user",
content: [
{ type: "text", text: "Describe this image in detail" },
{ type: "image_url", image_url: { url: "https://example.com/image.jpg", detail: "auto" } }
]
}
]
});
console.log(response.choices[0].message.content);
Video Analysis
import { VlmRun } from "vlmrun";
const client = new VlmRun({
apiKey: "<VLMRUN_API_KEY>",
baseURL: "https://api.vlm.run/v1"
});
// Analyze a video
const response = await client.agent.completions.create({
model: "vlmrun-orion-1:auto",
messages: [
{
role: "user",
content: [
{ type: "text", text: "Summarize this video" },
{ type: "video_url", video_url: { url: "https://example.com/video.mp4" } }
]
}
]
});
console.log(response.choices[0].message.content);
Structured Outputs
import { VlmRun } from "vlmrun";
// Define response schema
interface ImageCaption {
caption: string;
tags: string[];
}
const client = new VlmRun({
apiKey: "<VLMRUN_API_KEY>",
baseURL: "https://api.vlm.run/v1"
});
// Get structured response
const response = await client.agent.completions.create({
model: "vlmrun-orion-1:auto",
messages: [
{
role: "user",
content: [
{ type: "text", text: "Generate a caption and tags for this image" },
{ type: "image_url", image_url: { url: "https://example.com/image.jpg" } }
]
}
],
response_format: {
type: "json_schema",
schema: {
type: "object",
properties: {
caption: { type: "string", description: "Detailed caption of the image" },
tags: { type: "array", items: { type: "string" }, description: "Tags describing the image" }
},
required: ["caption", "tags"]
}
}
});
// Parse the response
const result: ImageCaption = JSON.parse(response.choices[0].message.content);
console.log(result);
Document Analysis
import { VlmRun } from "vlmrun";
const client = new VlmRun({
apiKey: "<VLMRUN_API_KEY>",
baseURL: "https://api.vlm.run/v1"
});
// Analyze a PDF document
const response = await client.agent.completions.create({
model: "vlmrun-orion-1:auto",
messages: [
{
role: "user",
content: [
{ type: "text", text: "Extract key information from this document" },
{ type: "file_url", file_url: { url: "https://example.com/document.pdf" } }
]
}
]
});
console.log(response.choices[0].message.content);
Agent Execution
Pass optional skills inconfig.
import { VlmRun } from "vlmrun";
const client = new VlmRun({ apiKey: "<VLMRUN_API_KEY>" });
const execution = await client.agent.execute({
name: "my-agent:v1",
inputs: { file: { type: "file_url", file_url: { url: "https://example.com/document.pdf" } } },
model: "vlmrun-orion-2:pro",
});
// Poll until the execution completes (defaults to a 600s timeout)
const result = await client.executions.wait(execution.id);
console.log(result.response);
Execution Mode
execution_mode reports whether the server replayed a skill’s cached pipeline.py or ran the full LLM agent loop. See program execution.
const execution = await client.agent.execute({
name: "my-agent:v1",
inputs: { file: { type: "file_url", file_url: { url: "https://example.com/document.pdf" } } },
model: "vlmrun-orion-2:pro",
config: { skills: [{ skillId: "my-skill-id" }] },
});
console.log(execution.execution_mode); // "program" | "agent"
The Node.js SDK cannot select the mode yet.
AgentExecutionConfig serializes only:promptjsonSchemaskillsserviceTierorchestrationMode
mode key is dropped before the request is sent. Use the Python SDK or a raw cURL request to force a mode.SDK Reference
client.agent.execute()
Parameters:
| Parameter | Type | Description |
|---|---|---|
name | string | Agent name and version, as agent-name:version |
inputs | Record<string, any> | Inputs to the agent (files, URLs, values) |
model | string | Model to use (default: vlmrun-orion-1:auto) |
batch | boolean | Must be true; false throws InputError (default: true) |
config | AgentExecutionConfig | prompt, jsonSchema, skills, serviceTier, orchestrationMode |
metadata | RequestMetadata | Request metadata |
callbackUrl | string | Webhook URL notified on completion |
toolsets | AgentToolset[] | Tool categories to enable for this execution |
Promise<AgentExecutionResponse> with execution_mode set to the path taken.
client.agent.completions.create()
Parameters:
| Parameter | Type | Description |
|---|---|---|
model | string | Model to use (e.g., vlmrun-orion-1:auto) |
messages | Message[] | List of messages in the conversation |
response_format | ResponseFormat | Optional JSON schema for structured output |
stream | boolean | Enable streaming responses (default: false) |
Promise<ChatCompletionResponse>
Message Content Types
| Type | Description |
|---|---|
text | Plain text content |
image_url | Image URL for image analysis |
video_url | Video URL for video analysis |
file_url | File URL for document analysis |