Edit or combine images
const url = 'https://api.aderra.ai/v1/images/edits';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"prompt":"Make it night, with the lamp lit"}'};
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/edits \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "prompt": "Make it night, with the lamp lit" }'Image-to-image. The request carries only a prompt: the images to edit are your most
recent images, up to 8 from roughly the last two hours, newest first. They are the
images you generated with /v1/images/generations and the images you sent as
image_url parts to /v1/chat/completions, across every key on your account.
There is no image upload field.
With no recent image, the call is refused with no_reference_image.
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": "Make it night, with the lamp lit"}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"}