Installation
Quick start
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
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',
});
Your BabySea API key (bye_...).
Your deployment region (unless baseUrl).
Full base URL override, takes precedence over region.
Auto-retries on retryable errors (429, 5xx).
| Option | Type | Default | Description |
|---|
apiKey | string | — | Required, your BabySea API key (bye_...) |
region | us | eu | — | Required, deployment region (unless baseUrl) |
baseUrl | string | — | Full base URL override, takes precedence over region |
timeout | number | 30000 | Request timeout in ms |
maxRetries | number | 2 | Auto-retries on retryable errors (429, 5xx) |
Response envelope
All successful responses follow the same envelope:
{
"status": "success",
"request_id": "...",
"message": "OK",
"timestamp": "...",
"data": { ... }
}
Paginated responses include extra fields:
{
"status": "success",
"request_id": "...",
"message": "OK",
"timestamp": "...",
"total": 342,
"limit": 50,
"offset": 0,
"data": { ... }
}
Runtime compatibility
| Runtime | Supported | Notes |
|---|
| Node.js 18+ | ✅ | Uses native fetch and crypto.subtle |
| Deno | ✅ | Web standard APIs |
| Bun | ✅ | Web standard APIs |
| Cloudflare Workers | ✅ | Edge runtime compatible |
| Vercel Edge Functions | ✅ | Edge runtime compatible |
| Modern Browsers | ✅ | ESM bundle, crypto.subtle required |
| Node.js < 18 | ❌ | No native fetch, use a polyfill or upgrade |
Package exports
{
"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:
import { verifyWebhook } from 'babysea-sdk/webhooks';
TypeScript support
The SDK is written in TypeScript and ships .d.ts declarations. All response types are exported:
import type {
BabySeaOptions,
BabySeaRegion,
ApiResponse,
PaginatedResponse,
AccountData,
BillingData,
EstimateData,
HealthProvidersData,
ImageGenerationParams,
ImageGenerationData,
Generation,
LibraryModelsData,
GenerationListData,
StatusData,
UsageData,
WebhookPayload,
} from 'babysea-sdk';