Using the API
Media generation
One endpoint creates images, video, speech and music. Requests are asynchronous: you get a job back at once, then read it or wait for a webhook.
Create a generation
Send the model and a prompt. Any other field the model accepts, such as aspect_ratio or duration, goes at the top level or inside params. The response is 202 with the job.
curl https://api.openbase.ai/v1/generations \
-H "Authorization: Bearer $OPENBASE_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"model": "fal-ai/flux/dev",
"prompt": "A lighthouse at dusk, 35mm film",
"aspect_ratio": "16:9"
}'Always send an Idempotency-Key
If a request is retried with the same key and body, you get the original job back and are charged once. The same key with a different body returns 409 idempotency_conflict.
Price it first
POST /v1/pricing/quote takes the same body and returns the price and a signed quote_token. Pass the token when you create the generation to lock the price. If the price has moved since, you receive 409 price_changed and can decide again.
Read the result
GET /v1/generations/{id}
{
"id": "0b7c...",
"object": "generation",
"status": "succeeded",
"model": "fal-ai/flux/dev",
"price": { "micros": 30000, "credits": 3, "usd": 0.03 },
"outputs": [
{
"asset_id": "5d1e...",
"type": "image",
"url": "https://cdn.openbase.ai/...",
"thumbnail_url": "https://cdn.openbase.ai/...",
"content_type": "image/webp"
}
]
}Output URLs are signed and short lived. Request the job again for a fresh one. Statuses are queued, running, succeeded, failed and cancelled. Prefer webhooks to polling.
Billing
- Credit is held when the job is created.
- It is charged only after the output is stored in your library.
- Failures, cancellations and blocked content release the hold and cost nothing.
Inputs from your library
Anywhere a model takes a file URL you can pass asset:<id> instead. The reference is swapped for a signed URL when the job is sent. Upload files with POST /v1/assets/uploads, send the bytes to the returned URL, then call POST /v1/assets/<id>/complete.
Limits and errors
429 concurrency_limit: too many jobs at once for your plan. Retry after the header value.402 insufficient_credits: add credits or upgrade.400 invalid_request: a field did not match the model schema.
The full machine-readable contract is at GET /v1/openapi.json.