Overview of BabySea Generative Media API
generation_prompt, generation_ratio), provider routing via generation_provider_order to handle failovers, and a standardized credit system where 1 credit equals $1 USD.website·Indexed 32 days ago
https://docs.babysea.aiAn execution control plane for generative AI that provides a regional /v1 API and TypeScript SDK for running image and video generation through a single response schema. Features include asynchronous workload management, webhook notifications, a browser-based playground for testing model schemas, and a comprehensive dashboard for managing API keys, billing, and usage metrics.
generation_prompt, generation_ratio), provider routing via generation_provider_order to handle failovers, and a standardized credit system where 1 credit equals $1 USD./v1 API routes as production code, allowing developers to verify model schemas, regional endpoints, and content actions before implementation. Access the playground at https://us.babysea.ai/playground.The Metrics dashboard provides account-level visibility into request volume, generation outcomes, credit spend, webhook delivery, and latency trends for a selected team account. It is a read-only page accessible to all team roles.
Key data sections include:
Credit packs are one-time add-ons that increase the account credit balance. To purchase a credit pack, the following requirements must be met:
primary-owner.Note: If a subscription becomes inactive before the payment webhook is processed, credits will not be allocated automatically and will require manual review.
| Pack | Credits added |
|---|---|
| $10 | 10.000 |
| $25 | 25.000 |
| $50 | 50.000 |
| $100 | 100.000 |
| $500 | 500.000 |
| $1,000 | 1,000.000 |
BabySea signs the raw JSON body using HMAC-SHA256. The signed payload consists of the unix timestamp and the raw body: <unix_timestamp>.<raw_json_body>.
It is recommended to use the verifyWebhook() function from the TypeScript SDK, which validates the signature and ensures the timestamp is within the default tolerance window of 300 seconds.
import {
isCreditLowBalance,
isGenerationCompleted,
verifyWebhook,
} from 'babysea/webhooks';
export async function POST(request: Request) {
const rawBody = await request.text();
const signature = request.headers.get('X-BabySea-Signature') ?? '';
const event = await verifyWebhook(
rawBody,
signature,
process.env.BABYSEA_WEBHOOK_SECRET!,
);
if (isGenerationCompleted(event)) {
await saveOutput(
event.webhook_data.generation_id,
event.webhook_data.generation_output_file ?? [],
);
}
if (isCreditLowBalance(event)) {
await notifyBillingOwner(event.webhook_data.current_balance);
}
return new Response('ok');
}primary-owner can perform this action. Before deleting, it is recommended to review billing, API keys, webhooks, custom domains, logs, and stored generations.generateAndWait() method creates a generation and polls automatically until it succeeds or fails. It is ideal for scripts and demos. It throws BabySeaGenerationFailedError if the process fails or is canceled.const generation = await client.generateAndWait(
'bfl/flux-schnell',
{
generation_prompt: 'A baby seal playing on Arctic ice',
generation_ratio: '1:1',
},
{
timeout: 120_000, // Total timeout for polling
interval: 2_000, // Polling interval
},
);
console.log(generation.data.generation_output_file);When moving to production, follow these best practices:
Generate Only keys for workers to limit scope.Idempotency-Key for all queue or user-triggered retries.verifyWebhook to validate the X-BabySea-Signature header (which contains a timestamp and HMAC) against your BABYSEA_WEBHOOK_SECRET. Use isGenerationCompleted to check if the event indicates a finished generation.import { isGenerationCompleted, verifyWebhook } from 'babysea/webhooks';
export async function POST(request: Request) {
const rawBody = await request.text();
const signature = request.headers.get('X-BabySea-Signature') ?? '';
const event = await verifyWebhook(
rawBody,
signature,
process.env.BABYSEA_WEBHOOK_SECRET!,
);
if (isGenerationCompleted(event)) {
console.log(event.webhook_data.generation_output_file);
}
return new Response('ok');
}When handling errors, prioritize the retryable field in the error envelope over the HTTP status code, as some 5xx provider failures are not retryable.
Retry Guidelines:
retryable: true (use exponential backoff), HTTP 429 (respect Retry-After), or HTTP 5xx where retryable: true.4xx (except 429), or when the error type is provider_credits_exhausted (choose another model/provider instead).