/v1 requests via the Authorization: Bearer <token> header. Manage them in the API keys section of the console.
Access control
In a personal workspace, the sole owner manages all keys. In team workspaces, RBAC applies:| Role | Access |
|---|---|
primary-owner / owner | Provision, rotate, revoke, and delete keys |
member | Read-only — view metadata and audit logs only |
Key format and storage
Keys use thebye_ prefix followed by a Base64-encoded random value:
Authentication flow
For every/v1 request, BabySea runs these checks in order:
All checks pass → request reaches the route handler.
Key status
| Status | Authenticates | Meaning |
|---|---|---|
Active | Yes | Key is live and valid |
Rotated | Yes (until grace period ends) | Old key within its overlap window |
Expired | No | Expiration timestamp reached |
Revoked | No | Manually disabled |
Permission presets
Scopes are bound to a key at creation and cannot be changed. Choose the most restrictive preset your workload requires.| Preset | Scopes granted | Best for |
|---|---|---|
Full Access | All — read, write, delete | Production API servers |
Generate Only | generation:write, generation:read, library:read | Background workers that only start generations |
Read Only | generation:read, account:read, health:read, library:read | Dashboards, usage readers |
Monitor Only | health:read, library:read | Uptime monitors, catalog browsers |
Scope → endpoint mapping
| Scope | Endpoints |
|---|---|
generation:write | POST /v1/generate/image/{model}, POST /v1/generate/video/{model} |
generation:read | GET /v1/content/{id}, GET /v1/content/list |
generation:delete | DELETE /v1/content/{id}, POST /v1/content/generation/cancel/{id} |
account:read | GET /v1/user/account, GET /v1/user/billing, GET /v1/usage, GET /v1/status |
health:read | GET /v1/health/inference/providers, GET /v1/health/inference/models, GET /v1/health/storage, GET /v1/health/cache |
library:read | GET /v1/library/providers, GET /v1/library/models, GET /v1/estimate/{model} |
Create a key
Requires:primary-owner or owner role.
Enter a name
Up to 100 characters. Use descriptive names tied to the workload:
| Example | Use case |
|---|---|
prod-api-worker | Production image generation backend |
dev-frontend | Local development |
staging-monitor | Staging health checks |
analytics-reader | Usage dashboard |
Choose a permission preset
Select a preset. Defaults to
Full Access. Scopes are immutable after creation.Optional — add an IP allowlist
Enter comma-separated IPs (max 50 entries, 45 chars each). Leave empty to allow all IPs.
Using your key
- SDK
- cURL
- Python
TypeScript
Verify the key
Terminal
account:read — available on Full Access and Read Only. For Generate Only keys, send a generation request instead.
Store it securely
.env
IP allowlist
Restrict a key to specific egress IPs. Requests from unlisted IPs are rejected withBSE1007 before reaching any route handler. Allowlists are immutable after creation — to update, provision a new key with the revised list, migrate, then revoke the old one.
| Rule | Detail |
|---|---|
| Match type | Exact string match |
| Max entries | 50 IPs per key |
| Max length per IP | 45 characters |
| Empty | All IPs allowed |
| Inherited on rotation | Yes |
| Raw IP logged | Never — SHA-256 hash only |
Common setups
Single server
Multiple servers / load balancer
Rotation, revocation, and deletion
Rotate
Rotation replaces a key while keeping the old one active during a configurable grace period (1–168 hours, default 24h), so you can update applications without downtime.
The replacement key inherits the original’s name, scopes, and IP allowlist. Scopes are still immutable.
Example quarterly rotation (default 24h grace):
- Mon 10:00 — Rotate
prod-api-worker, copy new key - Mon 10:05 — Update secrets manager
- Mon 10:10 — Deploy; services pick up new key
- Mon 10:30 — Verify with
GET /v1/status - Tue 10:00 — Grace period expires; old key stops working
Rotate vs. revoke
| Action | Old key | New key | Use when |
|---|---|---|---|
| Rotate | Active during grace period | Yes | Planned refresh |
| Revoke | Disabled immediately | No | Key is compromised or leaked |
Revoke
Revocation immediately disables the key. All requests returnBSE1002 from that moment. The key and its logs remain visible in the table but the key cannot be reactivated.
Delete
Deleting permanently removes the key and all associated request logs. The key is also immediately revoked if still active. Aggregate daily statistics are preserved in account analytics before deletion.If you still need the audit logs, revoke instead of deleting. Deletion removes individual log entries permanently.
Action availability
| Action | Active | Rotated | Expired | Revoked |
|---|---|---|---|---|
| Rotate | ✓ | — | — | — |
| Revoke | ✓ | ✓ | — | — |
| Delete | ✓ | ✓ | ✓ | ✓ |
Usage tracking
BabySea records a Last used timestamp on every authenticated request. Keys that have never been used displayNo activity. Request metadata (endpoint, method, status code, SHA-256 hash of client IP) is logged for auditing. Raw IPs are never stored.
Error reference
| Code | Type | Message | HTTP |
|---|---|---|---|
BSE1001 | missing_api_key | Missing API key. Provide a valid key via the Authorization header. | 401 |
BSE1002 | invalid_api_key | Invalid or expired API key. | 401 |
BSE1003 | insufficient_permissions | API key does not have permission for this resource. | 403 |
BSE1007 | ip_not_allowed | This IP address is not in the allowlist for this API key. | 403 |
"retryable": false. To resolve BSE1003, provision a new key with a preset that includes the required scope.