Client Configuration
The VlmRun
client is the main entry point for interacting with the VLM Run API. It provides access to all SDK functionality including file operations, model operations, and predictions.
Initialization
import { VlmRun } from "vlmrun";
const client = new VlmRun({
apiKey: "your-api-key",
// Optional configuration options
baseUrl?: string;
});
Configuration Options
Option | Type | Description | Default |
---|
apiKey | string | Your VLM Run API key | Required |
baseUrl | string | Custom API base URL | https://api.vlm.run |
Client Components
The client provides access to different components for specific operations:
// File operations
client.files.upload({
/* ... */
});
client.files.get();
client.files.list();
// Model operations
client.models.list();
// Image predictions
client.image.generate({
/* ... */
});
// Document predictions
client.document.generate({
/* ... */
});
Error Handling
The client throws typed errors for different scenarios:
import { VlmRun, ApiError } from "vlmrun";
try {
const client = new VlmRun({
apiKey: "invalid-key",
});
await client.models.list();
} catch (error) {
if (error instanceof ApiError) {
console.error("API Error:", error.message);
console.error("Status:", error.http_status);
} else if (error instanceof VlmRunError) {
console.error("SDK Error:", error.message);
} else {
console.error("Unknown Error:", error);
}
}
TypeScript Interfaces
interface ApiError extends Error {
message: string;
http_status: number;
headers?: Record<string, string>;
}
interface VlmRunError extends Error {
message: string;
code?: string;
cause?: Error;
}