Skip to content
lumalabs.ai

Image editing

Edit existing images with text prompts using the Luma Agents API — background replacement, style transfer, object modification, and more.

Modify existing images with natural language instructions. Describe the edit you want and the uni-1 family applies it while preserving the parts of the image you did not mention. For generating new images from text, see Image generation.

Use type: "image_edit" when you have an existing image and want to modify it. Use type: "image" with image_ref when you want to create something new inspired by a reference.

ScenarioUseWhy
Change a photo’s backgroundimage_edit + sourceKeeps the subject, only changes the background
Convert a photo to manga styleimage_edit + source + style: "manga"Transforms the existing image
Create a new image in a similar styleimage + image_refGenerates something new using the reference for style guidance
Combine elements from multiple imagesimage + image_ref (multiple)Compositing, not editing a single source

An image edit requires three things: type set to "image_edit", a source image, and a prompt describing the edit.

from luma_agents import Luma
client = Luma()
generation = client.generations.create(
type="image_edit",
prompt="Change the sky to a dramatic sunset with orange and purple clouds",
source={"url": "https://example.com/landscape.jpg"},
)

The source field accepts a single image — either as a URL or inline base64 data.

From a URL:

{
"source": {
"url": "https://example.com/photo.jpg"
}
}

From base64 data:

{
"source": {
"data": "iVBORw0KGgoAAAANSUhEUgAAAAUA...",
"media_type": "image/jpeg"
}
}

Combine source with the style parameter to apply a style preset to an existing image:

generation = client.generations.create(
type="image_edit",
prompt="Convert to a bold manga illustration with clean ink outlines and vivid flat colors",
source={"url": "https://example.com/photograph.jpg"},
style="manga",
)

Combine source (the image to edit) with image_ref (style/content references) to guide the edit. Up to 8 reference images are supported.

Single reference — apply a color grading from a reference:

generation = client.generations.create(
type="image_edit",
prompt="Apply the color grading from the reference to the source image",
source={"url": "https://example.com/my-photo.jpg"},
image_ref=[
{"url": "https://example.com/color-reference.jpg"},
],
)

Multiple references — combine lighting from one and texture from another:

generation = client.generations.create(
type="image_edit",
prompt="Apply the lighting from the first reference and the texture from the second to the source image",
source={"url": "https://example.com/my-photo.jpg"},
image_ref=[
{"url": "https://example.com/lighting-reference.jpg"},
{"url": "https://example.com/texture-reference.jpg"},
],
)

Change colors, materials, or properties of objects in the image:

generation = client.generations.create(
type="image_edit",
prompt="Change the car's color to midnight blue with a metallic finish",
source={"url": "https://example.com/car-photo.jpg"},
)

Replace the background while preserving the subject:

generation = client.generations.create(
type="image_edit",
prompt="Replace the background with a tropical beach at sunset, "
"warm golden light matching the direction of light on the subject",
source={"url": "https://example.com/portrait.jpg"},
)

Change the lighting or time of day:

generation = client.generations.create(
type="image_edit",
prompt="Change the lighting to dramatic golden hour with long shadows from the left",
source={"url": "https://example.com/scene.jpg"},
)

These constraints are specific to image_edit requests. General constraints from Image generation also apply.

RuleConstraint
typeMust be "image_edit"
sourceRequired. Must provide url or data — not both
source.urlMust be publicly accessible. Max 50 MB
source.dataMust be valid base64. Requires media_type
image_refOptional. Up to 8 additional reference images
promptRequired. 1–6,000 characters describing the desired edit

Common validation errors:

MistakeHTTP codeError
Missing source400"source is required for type 'image_edit'"
Providing source with type: "image"400"source is only valid for type 'image_edit'"
source with both url and data400"source: provide either 'url' or 'data', not both"
source.data without media_type400"source: 'media_type' is required with 'data'"
source image over 50 MB413"source: image exceeds 50 MB limit"
Unreachable source.url422"source: failed to fetch URL"
Invalid source.data422"source: invalid base64 data"

The response format is identical to image generation — poll GET /v1/generations/{id} until the state reaches completed or failed.

{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "image_edit",
"state": "completed",
"model": "uni-1",
"created_at": "2026-04-08T12:00:00Z",
"output": [
{
"type": "image",
"url": "https://storage.example.com/generations/a1b2c3d4/output.png?X-Amz-Expires=3600&..."
}
],
"failure_reason": null,
"failure_code": null
}

The submit-poll-download workflow for image editing is identical to image generation — set type: "image_edit" and include a source image. See the Quickstart for the complete polling pattern.

  • Image generation — Generate new images from text
  • Models — Model capabilities and limitations
  • Pricing — Pay-as-you-go and Provisioned Throughput plans
  • Error handling — Every error code with troubleshooting steps
  • FAQ — Quick answers to common questions
  • API Reference — Complete endpoint specifications