My App
GLabs SDK

Getting Started

Install and configure the GLabs SDK

Getting Started

This guide will help you install and configure the GLabs SDK in your project.

Installation

Install the package using your preferred package manager:

# Using bun
bun add @vrex/glabs-sdk

# Using npm
npm install @vrex/glabs-sdk

# Using pnpm
pnpm add @vrex/glabs-sdk

# Using yarn
yarn add @vrex/glabs-sdk

Prerequisites

Before using the SDK, you'll need:

  1. Bearer Token - A valid authentication token from Google Labs
  2. reCAPTCHA Provider (Required) - An API key from either YesCaptcha or CapSolver for solving reCAPTCHA challenges. Both image and video generation require reCAPTCHA verification.
  3. Project ID - Your Google Labs project identifier (optional, can be provided per-request)

Basic Setup

import { GLabsClient } from '@vrex/glabs-sdk';

const client = new GLabsClient({
  // Required: Your authentication token
  bearerToken: process.env.GLABS_BEARER_TOKEN!,

  // Required: reCAPTCHA solver configuration (for both image and video generation)
  recaptcha: {
    provider: 'yescaptcha', // or 'capsolver'
    apiKey: process.env.RECAPTCHA_API_KEY!,
  },

  // Optional: Account tier (defaults to 'pro')
  accountTier: 'pro',

  // Optional: Default project ID
  projectId: process.env.GLABS_PROJECT_ID,

  // Optional: Request timeout in milliseconds (default: 120000)
  timeout: 120000,

  // Optional: Custom logger
  logger: console,
});

Environment Variables

We recommend using environment variables for sensitive configuration:

# .env
GLABS_BEARER_TOKEN=your-bearer-token
GLABS_PROJECT_ID=your-project-id
RECAPTCHA_API_KEY=your-recaptcha-api-key
RECAPTCHA_PROVIDER=yescaptcha
import { GLabsClient } from '@vrex/glabs-sdk';

const client = new GLabsClient({
  bearerToken: process.env.GLABS_BEARER_TOKEN!,
  projectId: process.env.GLABS_PROJECT_ID,
  recaptcha: {
    provider: process.env.RECAPTCHA_PROVIDER as 'yescaptcha' | 'capsolver',
    apiKey: process.env.RECAPTCHA_API_KEY!,
  },
});

Session Management

Each API request requires a session ID. You can generate one using the static method:

const sessionId = GLabsClient.generateSessionId();

Or you can use your own UUID generation:

import { randomUUID } from 'crypto';
const sessionId = randomUUID();

Error Handling

The SDK throws GLabsError for API errors:

import { GLabsClient, GLabsError } from '@vrex/glabs-sdk';

try {
  const result = await client.images.generate({
    prompt: 'test image',
    sessionId: GLabsClient.generateSessionId(),
    aspectRatio: '16:9',
  });
} catch (error) {
  if (error instanceof GLabsError) {
    console.error('API Error:', error.message);
    console.error('Error Code:', error.code);
    console.error('Status Code:', error.statusCode);
  } else {
    throw error;
  }
}

Next Steps

On this page