Client Configuration

Configure the GLabs client for your needs

Client Configuration

The GLabsClient is the main entry point for interacting with Google Labs APIs.

Constructor Options

interface GLabsClientConfig {
  // Required
  bearerToken: string;
 
  // Optional
  sessionToken?: string;         // Session token for auto token refresh (ST→AT)
  accountTier?: 'pro' | 'ultra'; // Default: 'pro'
  projectId?: string;            // Auto-resolved if omitted
  recaptcha?: RecaptchaConfig;   // Required for image/video generation
  logger?: GLabsLogger;          // Default: console
  timeout?: number;              // Default: 120000 (2 minutes)
  maxRetries?: number;           // Default: 2
  retryDelay?: number;           // Default: 1500 (1.5 seconds)
}

Account Tiers

FeatureProUltra
Default Video Modefastquality
Video Modesquality, fastquality, fast
HD/4K UpscalingYesYes
Max Images Per Batch44
const proClient = new GLabsClient({
  bearerToken: 'token',
  accountTier: 'pro',
});
 
const ultraClient = new GLabsClient({
  bearerToken: 'token',
  accountTier: 'ultra',
});

reCAPTCHA Configuration

All generation requests require reCAPTCHA verification. The SDK supports 7 providers with fallback chains.

Real Chrome browser with persistent context — highest scores:

const client = new GLabsClient({
  bearerToken: 'token',
  recaptcha: {
    provider: 'chrome',
  },
});

Cloud-based — no local browser needed:

const client = new GLabsClient({
  bearerToken: 'token',
  recaptcha: {
    provider: 'yescaptcha',
    apiKey: 'your-yescaptcha-api-key',
  },
});

Fallback Chains

Configure a fallback provider in case the primary fails:

const client = new GLabsClient({
  bearerToken: 'token',
  recaptcha: {
    provider: 'chrome',
    fallback: {
      provider: 'yescaptcha',
      apiKey: 'key',
    },
  },
});

All Providers

ProviderTypeNote
chromeBrowserReal Chrome, highest scores
yescaptchaCloudReliable, no browser needed
playwrightBrowserPlaywright-managed browser
regotchaCloudOptimized for Google Labs
capsolverCloudProxy support
veo3solverTokenPre-solved tokens via JWT
customSelf-hostedYour own solver endpoint

Token Management

With sessionToken configured, the SDK automatically:

  • Refreshes bearer token 1 hour before expiry
  • Retries once on 401 after refreshing
  • Deduplicates concurrent refresh calls
const client = new GLabsClient({
  bearerToken: 'token',
  sessionToken: 'session-token',
});
 
// Manual refresh
await client.refreshToken();

Custom Logger

interface GLabsLogger {
  log: (message: string, ...args: unknown[]) => void;
  warn: (message: string, ...args: unknown[]) => void;
  error: (message: string, ...args: unknown[]) => void;
}
 
const client = new GLabsClient({
  bearerToken: 'token',
  logger: {
    log: (msg, ...args) => console.log(`[GLabs] ${msg}`, ...args),
    warn: (msg, ...args) => console.warn(`[GLabs] ${msg}`, ...args),
    error: (msg, ...args) => console.error(`[GLabs] ${msg}`, ...args),
  },
});

Silent Mode

const client = new GLabsClient({
  bearerToken: 'token',
  logger: { log: () => {}, warn: () => {}, error: () => {} },
});

Retry Configuration

const client = new GLabsClient({
  bearerToken: 'token',
  maxRetries: 3,
  retryDelay: 2000,
  timeout: 180000,
});

Client Properties

client.accountTier  // 'pro' | 'ultra'
client.projectId    // string | undefined

Static Methods

generateSessionId

const sessionId = GLabsClient.generateSessionId();
// '550e8400-e29b-41d4-a716-446655440000'

On this page