> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magichour.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Image Editor Tool - Magic Hour Docs

> Edit and modify images with AI-powered tools for comprehensive image manipulation.

export const ToolSection = ({type = "image", outputs = [], title = "", productSlug = "", apiSlug = ""}) => <>
    {outputs && outputs.length > 0 && <Tabs>
        {outputs.map((output, idx) => <Tab key={idx} title={`Example Output ${idx + 1}`}>
            <Frame>
              {type === "video" ? <video controls preload="metadata" playsInline className="rounded-lg h-80" src={`${output.src}#t=0.001`} type={`${output.src?.endsWith("mp4") ? 'video/mp4' : "video/webm"}`}>
                </video> : type === "audio" ? <audio controls preload="metadata" className="w-full" src={output.src}>
                  Your browser does not support the audio element.
                </audio> : <img height="320" className="rounded-lg h-80" src={output.src} />}
            </Frame>
          </Tab>)}
      </Tabs>}

    <CardGroup cols={2}>
      <Card title="API Spec" icon="webhook" horizontal href={`/api-reference/${type}-projects/${apiSlug}`}>
        See API details
      </Card>
      <Card title="Product Page" icon="video" horizontal href={`https://magichour.ai/products/${productSlug}`}>
        Learn more about {title}
      </Card>
    </CardGroup>

  </>;

## Overview

AI Image Editor provides comprehensive image editing capabilities using AI. Modify, enhance, and transform images with text-based instructions for natural-looking results without manual editing tools.

<ToolSection
  title="AI Image Editor"
  productSlug="ai-image-editor"
  apiSlug="ai-image-editor"
  type="image"
  outputs={[
{
  src: "/get-started/images/aiimageeditorexample1.jpg",
},
{
  src: "/get-started/images/aiimageeditorexample2.png",
},
]}
/>

## How It Works

1. **Upload image** - Provide the image you want to edit
2. **Describe changes** - Use text to specify desired modifications
3. **AI processes** - AI applies edits intelligently
4. **Download result** - Retrieve your edited image

## Use Cases

* **Photo editing** - Quick modifications without manual tools
* **Object removal** - Remove unwanted elements from images
* **Color adjustments** - Change colors and tones
* **Style changes** - Modify image aesthetics
* **Content addition** - Add new elements to images

## Best Practices

### Editing Instructions

<Tip>**Be specific and clear** - Detailed instructions produce more accurate edits.</Tip>

* **Describe precisely** - Specify exact changes wanted
* **One edit at a time** - Better results with focused changes
* **Use descriptive language** - Clear descriptions work best
* **Reference locations** - Specify where changes should occur

### Image Requirements

| Requirement | Details                             |
| :---------- | :---------------------------------- |
| Resolution  | Minimum 512x512 pixels              |
| Format      | PNG, JPG, JPEG, WEBP                |
| Quality     | Higher quality enables better edits |
| Clarity     | Clear images edit more accurately   |

## Code Examples

### Basic Image Edit

<CodeGroup>
  ```python Python theme={null}
  from magic_hour import Client
  from os import getenv

  client = Client(token=getenv("API_TOKEN"))

  result = client.v1.ai_image_editor.generate(
      assets={
          "image_file_paths": ["https://raw.githubusercontent.com/runshouse/Sample_Assets/main/tomcruise.png"]
      },
      style={
          "prompt": "Turn this image into studio ghibli style"
      },
      name="Image Editor image",
      wait_for_completion=True,
      download_outputs=True,
      download_directory="."
  )

  if result.status == "complete":
      print(f"✅ Image edit complete!")
      print(f"Downloaded to: {result.downloaded_paths}")
      print(f"Credits charged: {result.credits_charged}")
  else:
      print(f"❌ Job failed with status: {result.status}")
      if hasattr(result, 'error_message'):
          print(f"Error: {result.error_message}")
  ```

  ```javascript Node.js theme={null}
  import { Client } from "magic-hour";

  const client = new Client({ token: process.env.API_TOKEN });

  const result = await client.v1.aiImageEditor.generate({
    assets: {
      imageFilePaths: [
        "https://raw.githubusercontent.com/runshouse/Sample_Assets/main/tomcruise.png",
      ],
    },
    style: {
      prompt: "Change the background to a sunset beach scene",
    },
    name: "Image Editor image",
    waitForCompletion: true,
    downloadOutputs: true,
    downloadDirectory: ".",
  });

  console.log(`✅ Image edit complete!`);
  console.log(`Status: ${result.status}`);
  console.log(`Downloaded to: ${result.downloadedPaths}`);
  ```
</CodeGroup>

## Pricing

| Output         | Credits    |
| :------------- | :--------- |
| 1 edited image | 10 credits |

<Tip>
  **Try this in our Google Colab Cookbook:** [Run this API with sample
  code](https://colab.research.google.com/drive/1NTHL_lr_s-qBJ-mSecSXPzRLi9_V5JiU?usp=sharing). Just
  add your API key.
</Tip>

## API Reference

<Card title="AI Image Editor API Reference" icon="webhook" href="/api-reference/image-projects/ai-image-editor">
  View full API specification
</Card>

## Related Tools

<CardGroup cols={2}>
  <Card title="AI Face Editor" icon="face-smile" href="/tools/image/face-editor">
    Edit facial features specifically
  </Card>

  <Card title="Image Background Remover" icon="eraser" href="/tools/image/background-remover">
    Remove image backgrounds
  </Card>
</CardGroup>
