Client Configuration
Initialization
import { VlmRun } from "vlmrun";
const client = new VlmRun({
apiKey: "your-api-key",
// Optional configuration options
baseURL: "https://api.vlm.run/v1",
});
Configuration Options
| Option | Type | Description | Default |
|---|---|---|---|
apiKey | string | Your VLM Run API key | Required |
baseURL | string | Custom API base URL | https://api.vlm.run/v1 |
timeout | number | Request timeout in milliseconds | 120000 |
maxRetries | number | Number of retries for failed requests | 5 |
VLMRUN_GATEWAY_URL in the environment to override it.
Client Components
// 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({
/* ... */
});
// Agent execution and OpenAI-compatible chat completions
client.agent.execute({
/* ... */
});
client.agent.completions.create({
/* ... */
});
// OpenAI-compatible model gateway (OCR / VLM models)
client.gateway.completions.create({
/* ... */
});
// Skills, executions, and artifacts
client.skills.list();
client.executions.list();
client.artifacts.list({
/* ... */
});
Error Handling
import { VlmRun, APIError, VLMRunError } 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
class APIError extends VLMRunError {
message: string;
http_status?: number;
headers?: Record<string, string>;
request_id?: string;
error_type?: string;
suggestion?: string;
}
class VLMRunError extends Error {
message: string;
}