Generate an image
const url = 'https://api.aderra.ai/v1/images/generations';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"prompt":"A lighthouse in a storm, oil painting"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.aderra.ai/v1/images/generations \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "prompt": "A lighthouse in a storm, oil painting" }'Generate one image from a prompt. Synchronous: the image is returned in the response,
as b64_json or url depending on the model.
If the model’s content filter refuses the prompt, Aderra may retry once with the prompt
reworded (then the response says prompt_rewritten: true) or on an unfiltered model.
A refused or blank image is not charged.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
What to draw, or for an edit, what to change.
An image model id from GET /v1/usage/prices (all models at https://aderra.ai/docs/api/models/#image-models). Absent, or a name Aderra does not know, uses the default image model, flux-schnell (unless maxPriceMicro is set, when an unknown name is refused).
One of the sizes the model is sold at, for example 1024x1024. Absent: the model’s first size. Another size is refused with unsupported_size, which lists the allowed ones.
Optional price ceiling in micro-credits (1 credit = 1,000,000 micro-credits; 1,000 credits = $1), as a string of digits. A model that costs more is refused with price_limit_exceeded before anything is charged.
Example
{ "prompt": "A lighthouse in a storm, oil painting"}Responses
Section titled “Responses”The image.
object
One of b64_json (PNG data) or url, depending on the model.
object
Always false for an API key.
What this image cost, in micro-credits, as a string.
Present and true when the prompt was reworded after a content refusal.
Example
{ "billed_micro": "160000000"}invalid_json, missing_prompt, invalid_size, unsupported_size (with the allowed sizes), invalid_price_limit, unknown_model, and for edits no_reference_image.
The key is missing, unknown or revoked: {"error": "unauthorized"}.
Media and a few early refusals send error as a plain string, sometimes with a message for a person.
object
Example
{ "error": "unauthorized"}api_wallet_empty or key_spend_cap_reached in the OpenAI error shape, or a flat
price_limit_exceeded when the image costs more than your maxPriceMicro.
Media and a few early refusals send error as a plain string, sometimes with a message for a person.
object
Example
{ "error": { "type": "billing_error" }}account_suspended: the account behind the key is suspended.
object
Example
{ "error": { "type": "billing_error" }}request_too_large: the body is over the size limit.
object
Example
{ "error": { "type": "billing_error" }}refused_blank or image_content_refused: the image model refused the prompt. Not charged; reword it.
Media and a few early refusals send error as a plain string, sometimes with a message for a person.
object
Example
{ "error": "missing_prompt"}rate_limited: the key passed its requests per minute.
too_many_concurrent_requests: the account already has 8 requests in progress.
Wait for Retry-After seconds.
object
Example
{ "error": { "type": "rate_limit_error", "code": "rate_limited", "message": "This API key is limited to 60 requests a minute. Try again in 12 seconds, or raise the key's limit at https://aderra.ai/developers." }}Headers
Section titled “Headers”Example
12Whole seconds to wait before trying again.
image_failed: the image model failed. Not charged.
Media and a few early refusals send error as a plain string, sometimes with a message for a person.
object
Example
{ "error": "missing_prompt"}