POST
/
v1
/
ai-photo-editor
Python
from magic_hour import Client
from os import getenv

client = Client(token=getenv("API_TOKEN"))
res = client.v1.ai_photo_editor.generate(
    assets={"image_file_path": "/path/to/1234.png"},
    resolution=768,
    style={
        "image_description": "A photo of a person",
        "likeness_strength": 5.2,
        "negative_prompt": "painting, cartoon, sketch",
        "prompt": "A photo portrait of a person wearing a hat",
        "prompt_strength": 3.75,
        "steps": 4,
        "upscale_factor": 2,
        "upscale_fidelity": 0.5,
    },
    name="Photo Editor image",
    wait_for_completion=True,
    download_outputs=True,
    download_directory="outputs"
)
{
  "id": "cuid-example",
  "frame_cost": 10,
  "credits_charged": 10
}

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

resolution
integer
required

The resolution of the final output image. The allowed value is based on your subscription. Please refer to our pricing page for more details

Required range: 512 <= x <= 1024
Example:

768

style
object
required
assets
object
required

Provide the assets for photo editor

name
string
default:Photo Editor - dateTime

The name of image. This value is mainly used for your own identification of the image.

Example:

"Photo Editor image"

steps
integer
deprecated

Deprecated: Please use .style.steps instead. Number of iterations used to generate the output. Higher values improve quality and increase the strength of the prompt but increase processing time.

Required range: 3 <= x <= 6

Response

Success

id
string
required

Unique ID of the image. This value can be used in the get image project API to fetch additional details such as status

Example:

"cuid-example"

frame_cost
integer
required
deprecated

Deprecated: Previously represented the number of frames (original name of our credit system) used for image generation. Use 'credits_charged' instead.

Example:

10

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:

10