API documentation
Baalvion AI API
Base URL: https://ai.baalvion.com/api/v1. Requests and responses are JSON. Every response has the shape { "success": true, "data": … } or { "success": false, "error": { "code", "message", "details" } }.
Authentication
Create a key in your dashboard and send it as a bearer token. Keys begin with bv_live_. Generations made with a key are charged to the key owner's credit balance.
Authorization: Bearer bv_live_…Models and providers
GET /models returns every model currently available to the API, with its parameters, provider and estimated price in credits. GET /models/:id returns one. GET /providers lists the providers that currently have an available model.
curl https://ai.baalvion.com/api/v1/models -H "Authorization: Bearer $BAALVION_API_KEY"Models offered by more than one provider share a family, for example flux-dev.
Create a generation
POST /generations. The same shape works for every provider. The response is 202 with the job in queued state and the credits reserved for it. Send an Idempotency-Key header to make retries safe: repeating a request with the same key returns the original job.
POST /generations
{
"model": "flux-dev",
"prompt": "an isometric solar-powered village",
"parameters": { "aspect_ratio": "4:3", "num_images": 2 }
}Unknown or unsupported settings are rejected with 400; nothing is silently ignored. Inputs that take a file (for example image) expect { "type": "output", "id": "<output id>" } from an earlier generation, or { "type": "upload", "id": "<file id>" } from an upload.
{
"success": true,
"data": {
"id": "6f1c…",
"status": "queued",
"model": { "id": "flux-dev", "name": "FLUX.1 dev" },
"provider": { "id": "fal", "name": "fal.ai" },
"routing": { "strategy": "priority", "reason": "configured provider priority", "failedOver": false },
"estimatedCredits": 10,
"chargedCredits": null,
"outputs": []
}
}Choose a model for me
Send "model": "auto" with a task and, optionally, a mode (auto, best_quality or lowest_cost) and max_credits. POST /models/select takes the same fields and returns the ranking and the reasons without charging anything. Quality is ranked by catalogue tier until benchmark results are recorded, and the response says so.
{ "model": "auto", "task": "text_to_image", "mode": "lowest_cost",
"max_credits": 20, "prompt": "A lighthouse at dawn" }Files
POST /uploads takes the file itself as the request body. Images up to 25 MB, audio 50 MB, video 200 MB. Files are private, expire after seven days unless you send X-Expires-In (300 to 2592000 seconds), and can be removed with DELETE /uploads/:id. Camera metadata is removed from images, not from video or audio.
curl -X POST https://ai.baalvion.com/api/v1/uploads \
-H "Authorization: Bearer $BAALVION_API_KEY" \
-H "Content-Type: application/octet-stream" \
-H "X-Filename: product.jpg" \
--data-binary @product.jpgProviders and routing
You do not need to choose a provider. When you do, add "provider": "replicate" and the request is never moved elsewhere. Otherwise routing may be priority (default), lowest_cost, fastest or balanced. Only providers that support all your settings are considered. Speed-based choices fall back to priority until there is enough recent data, and the response's routing.reason always says how the choice was made.
If the chosen provider certainly refused the work (for example it is out of capacity), the job may move to another provider that costs no more than your quote. A job that may already be running is never resubmitted.
Get a generation
GET /generations/:id. Status moves from queued through submitted and running to succeeded, failed or canceled. On success, outputs holds signed URLs that stay valid for 15 minutes; fetch the job again for fresh links.
{
"status": "succeeded",
"chargedCredits": 10,
"outputs": [
{ "id": "…", "kind": "image", "width": 1152, "height": 864, "url": "https://…", "downloadUrl": "https://…" }
]
}GET /generations lists your recent generations, newest first (limit, before).
Cancel
POST /generations/:id/cancel cancels a job that has not started yet and returns its credits. Once a model has begun work, or where a provider has no cancel operation, it can no longer be cancelled.
Key permissions and limits
Each key has its own permissions, set in your dashboard: generate (models, generations, uploads, writing), content (teams, library, brands, drafts, figures), publish (scheduling posts) and workflows. A new key can only generate. You can also set the most a key may spend in a calendar month; work still running counts, and a request over the limit is refused with 402 KEY_LIMIT_REACHED.
Teams, posts and workflows
GET /workspaces lists the workspaces the key's owner belongs to. The same roles apply as on screen. Inviting and removing people is done on screen only.
GET /workspaces/:ws /members /dashboard /activity
GET /workspaces/:ws/files POST sends a file as the body
GET /workspaces/:ws/brands /social-accounts /analytics
GET /workspaces/:ws/posts POST creates a draft
PATCH /workspaces/:ws/posts/:id DELETE removes it
POST /workspaces/:ws/posts/:id/schedule { "at": "2027-01-15T09:30:00Z" }
POST /workspaces/:ws/copy { "action": "caption", "brief": "…" }
GET /workspaces/:ws/copy/:id
GET /workspaces/:ws/workflows
POST /workspaces/:ws/workflows/:id/runs { "inputs": {…}, "maxCredits": 50 }
GET /workspaces/:ws/runs/:id POST …/approve …/cancelA workflow that schedules posts needs the publish permission as well as workflows.
Client libraries
Single files with no dependencies, to copy into your project: baalvion.mjs (Node 18+) and baalvion.py (Python 3.8+). Both add an idempotency key to generations, retry only what is safe to repeat, and check webhook signatures. Use them on a server, never in a web page.
import { Baalvion } from './baalvion.mjs';
const ai = new Baalvion(process.env.BAALVION_API_KEY);
const job = await ai.generations.create({ model: 'auto', task: 'text_to_image', prompt: 'A red bicycle' });
const done = await ai.generations.wait(job.id);
console.log(done.outputs[0].url);import os
from baalvion import Baalvion
ai = Baalvion(os.environ["BAALVION_API_KEY"])
job = ai.generate(model="auto", task="text_to_image", prompt="A red bicycle")
done = ai.wait_generation(job["id"])
print(done["outputs"][0]["url"])Credits and usage
GET /credits returns available, held (reserved by running jobs) and a breakdown by source. GET /usage returns your daily request counts, recent requests and credits used. You are never charged more than estimatedCredits; failed jobs are refunded in full.
Webhooks
Register an HTTPS endpoint in your dashboard to receive generation.succeeded and generation.failed for jobs created through the API. Each delivery carries Baalvion-Signature: t=<unix>,v1=<hex>, an HMAC-SHA256 of `${t}.${rawBody}` with your endpoint secret. Reject deliveries older than five minutes. Failed deliveries are retried with backoff up to eight times.
import crypto from 'node:crypto';
function verify(rawBody, header, secret) {
const { t, v1 } = Object.fromEntries(header.split(',').map((p) => p.split('=')));
if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
const expected = crypto.createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(v1));
}Errors
400 BAD_REQUEST: the input does not match the model;detailsnames each field.401 INVALID_API_KEY: missing, malformed or revoked key.402 INSUFFICIENT_CREDITS:details.neededanddetails.availablesay by how much.402 KEY_LIMIT_REACHED: this key's monthly limit.403 KEY_SCOPE: the key lacks the permission for this request.404 NOT_FOUND: unknown model, or a generation that is not yours.429 RATE_LIMITEDorTOO_MANY_ACTIVE_JOBS: slow down; honourRetry-After.503 MODEL_*: the model is not available to you yet or right now.- A failed job carries
error.codesuch asCONTENT_BLOCKED,PROVIDER_REJECTED_INPUT,PROVIDER_FAILEDorTIMEOUT. Provider error text is not passed through.
Rate limits
Each key allows 60 requests a minute by default, and each account can have five generations running at once. Contact us if you need more.