Skip to main content
POST
/
v1
/
ai-image-editor
Python
from magic_hour import Client
from os import getenv

client = Client(token=getenv("API_TOKEN"))
res = client.v1.ai_image_editor.generate(
    assets={"image_file_path": "/path/to/1234.png"},
    style={"prompt": "Give me sunglasses"},
    name="Ai Image Editor image",
    wait_for_completion=True,
    download_outputs=True,
    download_directory="."
)
{
  "id": "cuid-example",
  "credits_charged": 50
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <api_key>, where <api_key> is your API key. To get your API key, go to Developer Hub and click "Create new API Key".

Body

application/json

Body

style
object
required
assets
object
required

Provide the assets for image edit

name
string
default:Ai Image Editor - dateTime

Give your image a custom name for easy identification.

Example:

"My Ai Image Editor image"

image_count
enum<number>
default:1

Number of images to generate. Maximum varies by model. Defaults to 1 if not specified.

Available options:
1,
4,
9,
16
Example:

1

model
enum<string>

The AI model to use for image editing. Each model has different capabilities and costs.

Models:

  • default - Use the model we recommend, which will change over time. This is recommended unless you need a specific model. This is the default behavior.
  • qwen-edit - 10 credits/image
    • Available for tiers: free, creator, pro, business
    • Image count allowed: 1
    • Max additional input images: 2
  • nano-banana - 50 credits/image
    • Available for tiers: free, creator, pro, business
    • Image count allowed: 1
    • Max additional input images: 9
  • nano-banana-2 - 100 credits/image
    • Available for tiers: free, creator, pro, business
    • Image count allowed: 1
    • Max additional input images: 9
  • seedream-v4 - 50 credits/image
    • Available for tiers: free, creator, pro, business
    • Image count allowed: 1
    • Max additional input images: 9
  • nano-banana-pro - 150 credits/image
    • Available for tiers: creator, pro, business
    • Image count allowed: 1, 4, 9, 16
    • Max additional input images: 9
  • seedream-v4.5 - 100 credits/image
    • Available for tiers: creator, pro, business
    • Image count allowed: 1
    • Max additional input images: 9
Available options:
default,
qwen-edit,
nano-banana,
nano-banana-2,
seedream-v4,
nano-banana-pro,
seedream-v4.5
Example:

"default"

aspect_ratio
enum<string>

The aspect ratio of the output image(s). If not specified, defaults to auto.

Available options:
auto,
16:9,
9:16,
4:3,
3:2,
1:1,
4:5,
2:3
Example:

"1:1"

Response

Success

Success

id
string
required

Unique ID of the image. Use it with the Get image Project API to fetch status and downloads.

Example:

"cuid-example"

credits_charged
integer
required

The amount of credits deducted from your account to generate the image. We charge credits right when the request is made.

If an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund.

Example:

50