Skip to main content
The client.hub object provides access to domains and schemas for structured data extraction.

Get Hub Info

import { VlmRun } from "vlmrun";

const client = new VlmRun({
  apiKey: "your-api-key",
});

// Get hub version information
const info = await client.hub.info();
console.log(`Hub version: ${info.version}`);

List Domains

import { VlmRun } from "vlmrun";
import type { DomainInfo } from "vlmrun";

const client = new VlmRun({
  apiKey: "your-api-key",
});

// List all available domains
const domains: DomainInfo[] = await client.hub.listDomains();

// Print domain information
for (const domain of domains) {
  console.log(`Domain: ${domain.domain}`);
  console.log(`Name: ${domain.name}`);
  console.log(`Description: ${domain.description}`);
}

Get Schema

import { VlmRun } from "vlmrun";
import type { HubSchemaResponse } from "vlmrun";

const client = new VlmRun({
  apiKey: "your-api-key",
});

// Get schema for a specific domain
const schema: HubSchemaResponse = await client.hub.getSchema({
  domain: "document.invoice",
});

console.log(`Schema version: ${schema.schema_version}`);
console.log(`Schema hash: ${schema.schema_hash}`);
console.log(`JSON Schema: ${JSON.stringify(schema.json_schema, null, 2)}`);

// Get schema with GraphQL statement
const schemaWithGql: HubSchemaResponse = await client.hub.getSchema({
  domain: "document.invoice",
  gql_stmt: "{ invoice_number total_amount }",
});

TypeScript Interfaces

interface HubInfoResponse {
  version: string;
}

interface DomainInfo {
  domain: string;
  name: string;
  description: string;
}

interface HubSchemaResponse {
  json_schema: Record<string, any>;
  schema_version: string;
  schema_hash: string;
  domain: string;
  gql_stmt: string;
  description: string;
}

interface HubSchemaParams {
  domain: string;
  gql_stmt?: string;
}

Error Handling

import { VlmRun, ApiError } from "vlmrun";

try {
  const schema = await client.hub.getSchema({
    domain: "invalid.domain",
  });
} catch (error) {
  if (error instanceof ApiError) {
    console.error("API Error:", error.message);
    console.error("Status:", error.http_status);
  } else {
    console.error("Unknown Error:", error);
  }
}