> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vlm.run/llms.txt
> Use this file to discover all available pages before exploring further.

# client

> VLM Run Node.js SDK Client Configuration and Usage

## 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

```typescript theme={"theme":{"light":"github-light","dark":"dark-plus"}}
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:

```typescript theme={"theme":{"light":"github-light","dark":"dark-plus"}}
// 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:

```typescript theme={"theme":{"light":"github-light","dark":"dark-plus"}}
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

```typescript theme={"theme":{"light":"github-light","dark":"dark-plus"}}
interface ApiError extends Error {
  message: string;
  http_status: number;
  headers?: Record<string, string>;
}

interface VlmRunError extends Error {
  message: string;
  code?: string;
  cause?: Error;
}
```
