palbaseDocs

Palbase ai · API

POST/ai/images

Make pictures

Starts a picture job and answers at once: making a picture takes the provider minutes. With reference images it edits them; a mask marks the part of the first to change. Read the job by its id; its pictures are kept for a day — save what you keep in your storage.

Called by your server, with the project's secret key.

Headers

Idempotency-Keystring · requiredMakes the request safe to send again (at most 255 characters): the same key with the same request is the same response or job, so a retry never asks — or pays — twice.

Request body

backgroundstring · optionalauto, transparent or opaque; transparent needs png or webp.
countinteger · optionalHow many pictures (1–4, default 1).
formatstring · optionalpng (default), jpeg or webp.
maskobject · optionalA picture the caller sends.
modelstring · optionalAn image model's name (GET /ai/models), or left out for the default.
promptstring · requiredWhat to make.
qualitystring · optionalauto, low, medium, high, xhigh or max.
referencesobject[] · optionalPictures to work from (4 at most, each 8 MiB at most and — with the mask — 24 MiB together, as PNG, JPEG or WebP): with them the job is an edit.
sizestring · optionalauto, 1024x1024, 1536x1024, 1024x1536, or WIDTHxHEIGHT: sides multiples of 16, an aspect between 1:3 and 3:1, 655,360 to 8,294,400 pixels.
curl
curl -X POST "https://<your-ref>.palbase.studio/ai/images" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"prompt":"string"}'

Responses

202The job, started (or the job this Idempotency-Key started)

400The request is malformed, or names what this module does not offer (the error names which)

401No valid credential

402Palbase's models do not serve the project now and it has not connected its own key for this model's provider (PUT /ai/providers/{provider}): its monthly AI budget is spent (ai_budget_reached), its month's free dollar is spent and it has no paid rights to pay past it (ai_payment_required), or they do not serve it (provider_key_required). GET /ai/spend says which.

403A publishable key or a user's session: everything here is the project's server's, called with the secret key

413The body is larger than the route takes

429The project's request rate, or the provider's for its connection, is used up — or the project holds as much as it may at once: 32 open streams at one of the module's servers (too_many_streams), 2 pictures being made (too_many_images), 512 MiB of pictures kept here for their day (image_storage_full), or the service — or the project's share of it — holds as much of its requests at once as it takes: their bodies, an embedding request's vectors, the pictures being made (busy). Retry-After says when to try again

503The model service or the database did not answer; retry shortly

defaultAn error: the envelope names it (`error`) and explains it (`error_description`).

Operation CreateImage of ai's contract.