import { VlmRun } from "vlmrun";
// Define response schema
interface ImageCaption {
caption: string;
tags: string[];
}
const client = new VlmRun({
apiKey: "<VLMRUN_API_KEY>",
baseURL: "https://agent.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);