ApiLux

Image editing

Edit an existing image from a text instruction: keep the subject and composition, adjust colours, retouch, change details.

ImplementedAvailability depends on the selected model being enabled and priced in ApiLux.

Request

POST/images/edits

Requires the Authorization: Bearer apl_... header

FieldTypeDescription
modelrequiredstringPublic model ID whose kind is IMAGE.
promptrequiredstringThe edit instruction. Being specific keeps the original intact.
image.b64_jsonstringSource image as raw base64. Requires mime_type.
image.data_urlstringOr a data:image/png;base64,... data URL — then mime_type is not needed.
image.mime_type"image/png" | "image/jpeg" | "image/webp"Required with b64_json. Max 8 MB decoded.

Response

FieldTypeDescription
data[].b64_jsonrequiredstringThe edited image, as base64.
usage.imagesrequiredintegerNumber of images charged.

Billing

By the number of images returned, same as generation.

Examples

cURL
IMG=$(base64 -w 0 source.png)

curl https://apilux.net/api/v1/images/edits \
  -H "Authorization: Bearer apl_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  --max-time 360 \
  -d "{
    \"model\": \"IMAGE_MODEL_ID\",
    \"prompt\": \"Giữ nguyên nhân vật, chỉ làm sáng nền\",
    \"image\": { \"b64_json\": \"$IMG\", \"mime_type\": \"image/png\" }
  }"
Node.js
import { readFileSync, writeFileSync } from "node:fs";

const res = await fetch("https://apilux.net/api/v1/images/edits", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.APILUX_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "IMAGE_MODEL_ID",
    prompt: "Giữ nguyên nhân vật, chỉ làm sáng nền",
    image: {
      b64_json: readFileSync("source.png").toString("base64"),
      mime_type: "image/png",
    },
  }),
});
const data = await res.json();
writeFileSync("edited.png", Buffer.from(data.data[0].b64_json, "base64"));

Errors

HTTPCodeMeaning
400invalid_requestInvalid body (missing field, wrong type, value out of range).
401auth_missing_or_malformedMissing Authorization header, or it is not in the Bearer apl_... form.
401auth_invalidThe API key does not exist.
401auth_revokedThe API key has been revoked.
401auth_expiredThe API key has expired.
400unknown_modelThe model does not exist on ApiLux.
400capability_not_supportedThe model exists but cannot be used on this endpoint (e.g. a text model on an image endpoint).
503pricing_not_configuredThe model is implemented but has no price configured on ApiLux yet. This is our state, not a client error.
503model_disabledThe model is currently disabled.
503model_temporarily_unavailableThe model is enabled and priced, but the upstream provider is not currently serving it. This is temporary and can clear on its own — the model reappears in GET /v1/models once the provider serves it again. You are not charged and no provider call is made.
402insufficient_balanceWallet balance is not enough for this request.
429api_key_limit_exceededThis API key hit a limit you configured yourself. The wallet still has funds — only this key is capped until the window resets. The response carries limit_type (spending | requests | tokens) and period (daily | monthly | lifetime). Token limits on text endpoints are measured from actual usage, so the total can exceed the limit by at most one request.
503api_key_quota_reconciliation_requiredAn earlier text request on this same key has not been reconciled yet. The usual cause: the provider returned a successful result without token usage, so the token limit for that window can no longer be trusted and ApiLux stops rather than let the limit be exceeded silently. Retrying will not help until that is done — contact support. You are not charged for the blocked request, no provider call is made, and image/video endpoints are unaffected.
502upstream_errorThe model provider failed. You are not charged.
504upstream_timeoutThe provider did not respond in time. You are not charged.
429upstream_rate_limitedRate limited. Retry after a few seconds.

Notes

Images are sent as JSON + base64, not multipart. Limit is 8 MB per image; PNG, JPEG and WEBP only.