Skip to main content

Installation

npm install babysea-sdk

Quick start

TypeScript
import { BabySea } from 'babysea-sdk';

const client = new BabySea({ apiKey: 'bye_...', region: 'us' });

const result = await client.generate('google/nano-banana', {
  generation_prompt: 'A cute baby seal on the beach',
});

console.log(result.data.generation_id);

Configuration

TypeScript
const client = new BabySea({
  // Required - your API key (starts with bye_)
  apiKey: 'bye_...',

  // Required - deployment region ('us' or 'eu')
  region: 'us',

  // Optional - request timeout in milliseconds (default: 30000)
  timeout: 30_000,

  // Optional - max automatic retries for `429` and `5xx` errors (default: 2)
  maxRetries: 2,
});

// Or with a custom base URL (overrides region)
const dev = new BabySea({
  apiKey: 'bye_...',
  baseUrl: 'https://custom.babysea.ai',
});
apiKey
string
Your BabySea API key (bye_...).
region
string
Your deployment region (unless baseUrl).
baseUrl
string
Full base URL override, takes precedence over region.
timeout
number
Request timeout in ms.
maxRetries
number
Auto-retries on retryable errors (429, 5xx).
OptionTypeDefaultDescription
apiKeystringRequired, your BabySea API key (bye_...)
regionus | euRequired, deployment region (unless baseUrl)
baseUrlstringFull base URL override, takes precedence over region
timeoutnumber30000Request timeout in ms
maxRetriesnumber2Auto-retries on retryable errors (429, 5xx)

Response envelope

All successful responses follow the same envelope:
JSON
{
  "status": "success",
  "request_id": "...",
  "message": "OK",
  "timestamp": "...",
  "data": { ... }
}
Paginated responses include extra fields:
JSON
{
  "status": "success",
  "request_id": "...",
  "message": "OK",
  "timestamp": "...",
  "total": 342,
  "limit": 50,
  "offset": 0,
  "data": { ... }
}

Runtime compatibility

RuntimeSupportedNotes
Node.js 18+Uses native fetch and crypto.subtle
DenoWeb standard APIs
BunWeb standard APIs
Cloudflare WorkersEdge runtime compatible
Vercel Edge FunctionsEdge runtime compatible
Modern BrowsersESM bundle, crypto.subtle required
Node.js < 18No native fetch, use a polyfill or upgrade

Package exports

JSON
{
  "exports": {
    ".": {
      "import": "./dist/index.mjs",
      "require": "./dist/index.cjs",
      "types": "./dist/index.d.ts"
    },
    "./webhooks": {
      "import": "./dist/webhooks.mjs",
      "require": "./dist/webhooks.cjs",
      "types": "./dist/webhooks.d.ts"
    }
  }
}
The webhook helper is a separate export for tree-shaking:
TypeScript
import { verifyWebhook } from 'babysea-sdk/webhooks';

TypeScript support

The SDK is written in TypeScript and ships .d.ts declarations. All response types are exported:
TypeScript
import type {
  BabySeaOptions,
  BabySeaRegion,
  ApiResponse,
  PaginatedResponse,
  AccountData,
  BillingData,
  EstimateData,
  HealthProvidersData,
  ImageGenerationParams,
  ImageGenerationData,
  Generation,
  LibraryModelsData,
  GenerationListData,
  StatusData,
  UsageData,
  WebhookPayload,
} from 'babysea-sdk';