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

# AI Image Editing API

> Edit images with text prompts using FLUX Kontext, Wan2.6, and Qwen. Change colors, remove backgrounds, apply style transfer via a single API.

export const RuncrateStyles = () => {
  if (typeof document !== 'undefined' && !document.getElementById('runcrate-overrides')) {
    const s = document.createElement('style');
    s.id = 'runcrate-overrides';
    s.textContent = `
      /* Match Runcrate's rounding scale (--radius: 0.75rem) */
      .rounded-sm { border-radius: 0.5rem !important; }   /* 8px */
      .rounded-md { border-radius: 0.625rem !important; } /* 10px */
      .rounded-lg { border-radius: 0.75rem !important; }  /* 12px */
      .rounded-l-sm { border-top-left-radius: 0.5rem !important; border-bottom-left-radius: 0.5rem !important; }
      .rounded-r-sm { border-top-right-radius: 0.5rem !important; border-bottom-right-radius: 0.5rem !important; }
      .rounded-l-md { border-top-left-radius: 0.625rem !important; border-bottom-left-radius: 0.625rem !important; }
      .rounded-r-md { border-top-right-radius: 0.625rem !important; border-bottom-right-radius: 0.625rem !important; }
      .rounded-l-lg { border-top-left-radius: 0.75rem !important; border-bottom-left-radius: 0.75rem !important; }
      .rounded-r-lg { border-top-right-radius: 0.75rem !important; border-bottom-right-radius: 0.75rem !important; }

      /* Cards: never pure white in light mode */
      .card { background-color: #fcfcfc !important; border-radius: 0.75rem !important; }
      html.dark .card { background-color: #141414 !important; }

      /* Docs hero box */
      .rc-hero { background-color: #fcfcfc; border: 1px solid #e0e0e0; }
      html.dark .rc-hero { background-color: #141414; border-color: #242424; }
      html.dark .rc-hero h1 { color: #f5f5f5; }

      /* Runcrate scrollbar — thin, transparent track, hide-until-hover thumb */
      ::-webkit-scrollbar { width: 6px; height: 6px; background-color: transparent; }
      ::-webkit-scrollbar-track { background-color: transparent; }
      ::-webkit-scrollbar-thumb { background-color: rgba(155, 155, 155, 0.5); border-radius: 10px; transition: opacity 0.3s ease; opacity: 0; }
      ::-webkit-scrollbar-thumb:hover { background-color: rgba(155, 155, 155, 0.7); }
      *:hover::-webkit-scrollbar-thumb,
      *:focus::-webkit-scrollbar-thumb,
      *:active::-webkit-scrollbar-thumb { opacity: 1; }
      * { scrollbar-width: thin; scrollbar-color: rgba(155, 155, 155, 0.5) transparent; }
    `;
    document.head.appendChild(s);
  }
  return null;
};

<RuncrateStyles />

Edit existing images using natural language. Change colors, swap backgrounds, remove objects, apply style transfer — one endpoint, no masking.

## Available models

| Model                  | Strengths                                  |
| ---------------------- | ------------------------------------------ |
| **FLUX.1 Kontext Pro** | Fast edits, good instruction following     |
| **FLUX.1 Kontext Max** | Highest quality, production assets         |
| **Wan2.6 Image Edit**  | Object removal, background replacement     |
| **Qwen Image Edit**    | Color/material changes, CJK text rendering |

***

## Basic image edit

<CodeGroup>
  ```python Python theme={"theme":"github-dark"}
  from runcrate import Runcrate

  client = Runcrate(api_key="rc_live_YOUR_API_KEY")

  edited = client.models.generate_image(
      model="black-forest-labs/FLUX.1-kontext-pro",
      prompt="Change the car color to matte black",
      image="./red-car.png",
  )
  edited.data[0].save("black-car.png")
  ```

  ```typescript TypeScript theme={"theme":"github-dark"}
  import Runcrate from '@runcrate/sdk';

  const rc = new Runcrate({ apiKey: 'rc_live_YOUR_API_KEY' });
  const edited = await rc.models.generateImage({
    model: 'black-forest-labs/FLUX.1-kontext-pro',
    prompt: 'Change the car color to matte black',
    image: './red-car.png',
  });
  await edited.save('black-car.png');
  ```

  ```bash curl theme={"theme":"github-dark"}
  curl https://api.runcrate.ai/v1/images/generations \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer rc_live_YOUR_API_KEY" \
    -d '{"model": "black-forest-labs/FLUX.1-kontext-pro", "prompt": "Change the car color to matte black", "image": "https://example.com/red-car.png"}'
  ```
</CodeGroup>

<Tip>
  `image` accepts a **file path** (auto base64-encoded), a **URL**, or raw **base64** data.
</Tip>

***

## Background removal

```python theme={"theme":"github-dark"}
from runcrate import Runcrate
client = Runcrate(api_key="rc_live_YOUR_API_KEY")

result = client.models.generate_image(
    model="Wan-AI/Wan2.6-Image-Edit",
    prompt="Remove the background, replace with clean white studio backdrop",
    image="./product-on-table.png",
)
result.data[0].save("product-isolated.png")
```

***

## Style transfer

```python theme={"theme":"github-dark"}
result = client.models.generate_image(
    model="black-forest-labs/FLUX.1-kontext-max",
    prompt="Convert to a watercolor painting style with soft pastel colors",
    image="./city-photo.jpg",
)
result.data[0].save("city-watercolor.png")
```

***

## Batch editing

```python theme={"theme":"github-dark"}
from runcrate import Runcrate
from pathlib import Path
from concurrent.futures import ThreadPoolExecutor

client = Runcrate(api_key="rc_live_YOUR_API_KEY")
output = Path("./clean"); output.mkdir(exist_ok=True)

def clean(p: Path):
    r = client.models.generate_image(model="Qwen/Qwen-Image-Edit", prompt="Remove background, white backdrop", image=str(p))
    r.data[0].save(str(output / p.name))

with ThreadPoolExecutor(max_workers=4) as pool:
    pool.map(clean, list(Path("./raw").glob("*.png")))
```

***

## Tips

* **Kontext Pro vs Max.** Pro for fast iteration, Max for final production assets.
* **Be specific.** "Change the sky to vivid cerulean blue with wispy cirrus clouds" beats "make the sky bluer."
* **Only describe the change.** The models preserve the subject — describe only what should change.
