TheDocumentation Index
Fetch the complete documentation index at: https://docs.babysea.ai/llms.txt
Use this file to discover all available pages before exploring further.
babysea package calls the /v1 API with typed responses, request timeouts, retry handling, and webhook signature verification.
npm
Install the official TypeScript SDK.
GitHub
View the package source and examples.
Install
Create a client
TypeScript
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | required | BabySea API key, for example bye_.... |
region | us, eu, or jp | us | Regional endpoint. Ignored when baseUrl is set. |
baseUrl | string | none | Full API origin override, without requiring a region. |
timeout | number | 30000 | Request timeout in milliseconds. |
maxRetries | number | 2 | Automatic retries for API errors where retryable is true. |
Generate an image
TypeScript
client.generate() chooses the route from the request body:
- no
generation_duration:POST /v1/generate/image/{model_identifier} generation_durationpresent:POST /v1/generate/video/{model_identifier}
Generate a video
TypeScript
Idempotent retries
Pass anIdempotency-Key to safely retry a generation request without creating duplicate work or duplicate charges. The SDK forwards it as the Idempotency-Key request header.
TypeScript
Poll a generation
TypeScript
Generate and wait
client.generateAndWait() creates a generation and polls until it reaches a terminal status. It returns the generation when generation_status is succeeded and throws BabySeaGenerationFailedError when the generation fails or is canceled. Use it for scripts and demos. For production throughput, prefer client.generate() with webhooks.
TypeScript
client.waitForGeneration() accepts the same timeout, interval, and signal options when you already have a generation_id.
Client methods
| Method | Endpoint |
|---|---|
client.status() | GET /v1/status |
client.usage(days?) | GET /v1/usage |
client.account() | GET /v1/user/account |
client.billing() | GET /v1/user/billing |
client.estimate(modelIdentifier, options?) | GET /v1/estimate/{model_identifier} |
client.generate(modelIdentifier, params, options?) | POST /v1/generate/image/... or POST /v1/generate/video/... |
client.generateAndWait(modelIdentifier, params, options?) | POST /v1/generate/..., then GET /v1/content/{generation_id} |
client.waitForGeneration(generationId, options?) | GET /v1/content/{generation_id} until terminal status |
client.getGeneration(generationId) | GET /v1/content/{generation_id} |
client.listGenerations({ limit, offset }) | GET /v1/content/list |
client.cancelGeneration(generationId) | POST /v1/content/generation/cancel/{generation_id} |
client.deleteGeneration(generationId) | DELETE /v1/content/{generation_id} |
client.library.providers() | GET /v1/library/providers |
client.library.models() | GET /v1/library/models |
client.health.providers() | GET /v1/health/inference/providers |
client.health.models() | GET /v1/health/inference/models |
client.health.storage() | GET /v1/health/storage |
client.health.cache() | GET /v1/health/cache |
Estimate cost
TypeScript
resolution and audio when relevant.
Errors and retries
TypeScript
retryable: true, up to maxRetries. It also retries transient network failures for idempotent methods. For POST generation requests, network retries require an Idempotency-Key.
Verify webhooks
TypeScript
verifyWebhook() checks the t=<unix_timestamp>,v1=<hmac> signature, validates the timestamp tolerance, and returns the parsed payload.
Runtime support
The SDK uses web-standardfetch and crypto.subtle APIs.
| Runtime | Supported |
|---|---|
| Node.js 18+ | Yes |
| Deno | Yes |
| Bun | Yes |
| Cloudflare Workers | Yes |
| Vercel Edge | Yes |
| Netlify Edge | Yes |
| Modern browsers | Yes |
