Skip to content

AI Photo Editing API ​

Turn a difficult portrait into a cleaner ID-style photo in one request. The API evaluates the whole image, corrects only the problems it finds, and leaves already suitable regions unchanged.

This endpoint is for portrait normalization, not beautification. Its highest priority is keeping the person recognizable as the same real individual.

The problem it solves ​

Real users rarely submit a perfectly controlled studio photo. A single image may combine a turned head, a tilted posture, visible teeth, glasses, hard shadows, compression artifacts, or a shoulder that was cut off during an earlier background-removal step. Fixing these issues manually is slow, and chaining separate edits can introduce inconsistent results.

POST /v2/aiEdit applies the necessary corrections together while protecting details that should not change: identity, natural skin texture, age, hair, clothing, background, crop, and overall photographic character.

Use it before specification-based processing

This endpoint improves the portrait itself. It does not select a country-specific document size or guarantee acceptance by an issuing authority. For sizing, background processing, validation, and issue codes, pass the normalized result to the Passport Photo API.

What the API corrects ​

Input problemCorrectionWhat remains protected
Head turned or tilted; uneven postureMakes the face naturally front-facing, keeps the head upright, and levels the shoulders when neededRecognizable facial structure, natural anatomy, framing, and scale
Broad smile, open mouth, or visible teethProduces a calm, natural, closed-mouth expressionCharacteristic lip shape, eye shape, and the person's likeness
Eyeglasses, sunglasses, or unsuitable novelty headwearRemoves the obstruction and conservatively reconstructs only hidden facial regionsHairline, ears, head shape, ordinary jewelry, and religious or cultural head coverings that do not obscure the face
Harsh shadows, color casts, overexposure, or underexposureBalances facial light and color while preserving real skin tonePores, age, complexion, and natural texture—without whitening or makeup
Blur, noise, compression, or weak local contrastRestores only the clarity needed for a usable ID-style portraitReal detail—without invented features, aggressive sharpening, or plastic skin
A shoulder or garment ends at an unnatural internal edgeReconstructs only the missing continuation of the existing clothing and silhouetteBody proportions, clothing, lighting, background, and the existing crop

If a region already meets these requirements, the API is instructed to leave it unchanged.

Before and after ​

These synthetic examples illustrate the kinds of corrections the endpoint is designed to make. They are not real customers or identity documents, and individual results vary with the input image.

Before · turned head and visible teethSynthetic portrait before editing, with the subject's head turned and teeth visible in a broad smile
After · front-facing and neutralSynthetic portrait after editing, with the same subject facing forward with a neutral closed-mouth expression
Pose and expression. The face is brought toward the camera and the expression is neutralized while the subject's age, hair, skin texture, clothing, and background remain consistent.
Before · glasses and hard side lightSynthetic portrait before editing, with prescription glasses and strong uneven lighting across the face
After · clear face and even lightSynthetic portrait after editing, with the same subject's glasses removed and facial lighting balanced
Face visibility and lighting. The glasses are removed, only the covered facial areas are reconstructed, and the strong light imbalance is corrected without changing the background or adding glamour retouching.
Before · eyes hidden by dark glassesSynthetic portrait before editing, with the subject's eyes and eyebrows obscured by dark glasses
After · obstruction removedSynthetic portrait after editing, with the same subject's dark glasses removed and the obscured eye area reconstructed
Dark-glasses removal. The frames and lenses are removed and only the hidden eye and eyebrow region is reconstructed. The pose, expression, face shape, hair, clothing, and background remain consistent.
Before · blur, noise, and compressionSynthetic portrait before editing, with moderate focus softness, visible image noise, and compression artifacts
After · conservative quality recoverySynthetic portrait after editing, with the same subject rendered more clearly while retaining natural age and skin texture
Recoverable image quality. Noise, compression artifacts, softness, and weak local contrast are reduced without aggressive sharpening, invented facial detail, or artificial skin smoothing.
Before · shoulder cut off inside frameSynthetic portrait before editing, with one sweater shoulder ending at an unnatural straight edge inside the image
After · silhouette reconstructedSynthetic portrait after editing, with the same subject's missing shoulder and sweater area naturally reconstructed
Incomplete silhouette. Only the missing shoulder and sweater continuation are repaired. A shoulder that already ends naturally—or continues through the image boundary—is not changed.

Identity-preserving boundaries ​

The endpoint is designed to preserve facial proportions, face shape, eyes, eyebrows, nose, lips, jawline, cheeks, ears, skin tone and texture, hairstyle, hairline, age, and distinctive characteristics.

It does not intentionally:

  • slim, reshape, rejuvenate, beautify, or cosmetically retouch the person;
  • change ethnicity or gender presentation;
  • whiten skin, add makeup, or create glamour lighting;
  • replace the background or clothing;
  • add objects or alter regions that are already suitable;
  • invent fine facial detail when the source does not contain enough information.

API endpoint ​

Send the request to the region where your account and data processing are configured:

  • https://api-us.idphotoapp.com — US region
  • https://api-eu.idphotoapp.com — EU region
  • Other regional deployments are available on request
http
POST /v2/aiEdit

Request ​

FieldTypeRequiredDescription
apiKeystringYesYour API key. Send requests from your server; do not expose credentials in browser code.
apiSecretstringYesYour API secret.
imageBase64stringYesBase64-encoded JPEG or PNG, with or without a data URI prefix. Use a single-person portrait.
outputFormatstringNoJPEG or PNG. When omitted, the input image format is used.
outputTypestringNoCurrently only IMAGE_BASE64 is supported.
jsonc
{
  "apiKey": "your-api-key",
  "apiSecret": "your-api-secret",
  "imageBase64": "data:image/jpeg;base64,...",
  "outputFormat": "JPEG",
  "outputType": "IMAGE_BASE64"
}

Response ​

The edited image is returned as Base64 without a data URI prefix. width and height report the output pixel dimensions.

jsonc
{
  "output": "/9j/4AAQSkZJRgABAQ...",
  "width": 600,
  "height": 800
}

To display the result as a JPEG in an application, prepend data:image/jpeg;base64, to output. For storage or further API processing, decode the value as binary image data instead.

Integration guidance ​

  • Access to this endpoint may need to be enabled for your account.
  • Use a clear, single-person portrait and keep the complete image payload on your server.
  • Set an appropriate timeout for image processing and do not log credentials or full Base64 values.
  • Treat authentication failures, invalid image data, and processing failures separately from a successful edit.
  • Review the edited portrait before passing it to the Passport Photo API. A successful edit does not by itself select or validate a document specification.