# FLUX.2 Klein Image Generator (Text-to-Image & Image-to-Image) (`danitn11/flux2-klein-image-generator`) Actor

Fast, cheap AI image generator & editor powered by FLUX.2 Klein. Text-to-image and image-to-image in seconds, just $4/1000 images. No GPU or subscription — a pay-as-you-go Midjourney, DALL-E & Flux alternative.

- **URL**: https://apify.com/danitn11/flux2-klein-image-generator.md
- **Developed by:** [daniel tr](https://apify.com/danitn11) (community)
- **Categories:** AI, Social media, Developer tools
- **Stats:** 2 total users, 0 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 image generateds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## FLUX.2 Klein AI Image Generator — Text-to-Image & Image-to-Image ⚡

**AI image generator and editor** powered by **FLUX.2 Klein** — create stunning images from a text prompt, or transform an existing photo, in **just a few seconds**. No GPU, no subscription, no monthly fees: you pay a tiny fixed price per image. A fast, affordable **alternative to Midjourney, DALL·E 3, and Adobe Firefly**.

Two modes in one Actor:

- 🖋️ **Text to Image** — describe anything and get a high-quality image.
- 🖼️ **Image to Image** — edit, restyle, or transform a photo you already have (just add an image URL).

Perfect for **social media content**, product shots, blog and ad creatives, thumbnails, app assets, faceless content pipelines, and **n8n / Make / Zapier** workflows and AI agents.

### Examples

Every image below was generated by this Actor with the default **4 steps** — each took only a couple of seconds.

#### Text to Image

| Prompt | Size | Result |
| --- | --- | --- |
| *"A beautiful sunset over a calm ocean, cinematic, highly detailed, golden hour"* | `landscape_16_9` | <img src="https://cdn.doggi-dev.net/media-gen-gateway/req-96f33dd7065c46aabceae632801e5007_0.jpeg" width="320" alt="AI generated sunset over the ocean — FLUX.2 Klein text to image" /> |
| *"A red fox sitting in a snowy pine forest at golden hour, shallow depth of field, photorealistic"* | `square_hd` | <img src="https://cdn.doggi-dev.net/media-gen-gateway/req-a8f23140958149bf8eac5fb4b7be002b_0.jpeg" width="260" alt="AI generated red fox in a snowy forest — FLUX.2 Klein" /> |
| *"Neon cyberpunk city street at night, rain reflections, cinematic, ultra detailed"* | `portrait_16_9` | <img src="https://cdn.doggi-dev.net/media-gen-gateway/req-a67f3f555f2e419c85424ee841241e72_0.jpeg" width="200" alt="AI generated cyberpunk city street at night — FLUX.2 Klein" /> |
| *"A cozy coffee shop logo with the text \"FLUX BREW\" in elegant lettering, minimal, vector style"* | `square` | <img src="https://cdn.doggi-dev.net/media-gen-gateway/req-6e1f2310887644aa945d0dcfff03014e_0.jpeg" width="260" alt="AI generated coffee shop logo with text — FLUX.2 Klein" /> |

#### Image to Image

Start from one photo and restyle it with a prompt — the input below is the demo image from the `imageUrl` field:

| Source image | Prompt | Result |
| --- | --- | --- |
| <img src="https://cdn.doggi-dev.net/media-gen-gateway/req-b6f24df387a7461788b4bfafffe9c7e7_0.jpeg" width="220" alt="Source photo for image-to-image" /> | *"turn it into a vibrant watercolor painting"* | <img src="https://cdn.doggi-dev.net/media-gen-gateway/req-0705e7590b2d424cb44fa69b91b6e2e3_0.jpeg" width="220" alt="Watercolor painting from photo — FLUX.2 Klein image to image" /> |
| <img src="https://cdn.doggi-dev.net/media-gen-gateway/req-b6f24df387a7461788b4bfafffe9c7e7_0.jpeg" width="220" alt="Source photo for image-to-image" /> | *"convert to a detailed black-and-white pencil sketch"* | <img src="https://cdn.doggi-dev.net/media-gen-gateway/req-f81dc7ab990842608b886350123ec1b9_0.jpeg" width="220" alt="Pencil sketch from photo — FLUX.2 Klein image to image" /> |

### Gallery — one model, every style

A few of the styles and domains FLUX.2 Klein handles out of the box — photography, illustration, 3D, concept art, design, and more. Every image below was generated by this Actor at the default **4 steps**, `square_hd` (1024×1024), in about a second each:

<table>
    <tr>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-b67b721dd6ae4883aa6056771001d45b_0.jpeg" width="200" alt="Photo · Portrait — FLUX.2 Klein AI image" /><br /><sub><b>Photo · Portrait</b><br />Cinematic close-up portrait of an elderly fisherman…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-76490d4ae4d34f7e8a229dc4bd774e16_0.jpeg" width="200" alt="Photo · Landscape — FLUX.2 Klein AI image" /><br /><sub><b>Photo · Landscape</b><br />Golden-hour landscape of misty rolling hills with…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-a4da8c6d96cf40958d5d0aff310e749c_0.jpeg" width="200" alt="Photo · Macro — FLUX.2 Klein AI image" /><br /><sub><b>Photo · Macro</b><br />Macro shot of a dew-covered spider web…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-d0a77906ce1b48cfbb8b7c63ff71350d_0.jpeg" width="200" alt="Photo · Street — FLUX.2 Klein AI image" /><br /><sub><b>Photo · Street</b><br />Street photography, rainy Tokyo alley at night…</sub></td>
    </tr>
    <tr>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-4848d05cb72b40e4b334a27cdb0297a2_0.jpeg" width="200" alt="Photo · Product — FLUX.2 Klein AI image" /><br /><sub><b>Photo · Product</b><br />Studio product photo of a luxury wristwatch…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-1685374a067d42938655bbc1840d3a2a_0.jpeg" width="200" alt="Photo · Food — FLUX.2 Klein AI image" /><br /><sub><b>Photo · Food</b><br />Overhead food photography of a rustic Margherita…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-6b7516c6a2014b50ac2e75ed9f77440f_0.jpeg" width="200" alt="Art · Watercolor — FLUX.2 Klein AI image" /><br /><sub><b>Art · Watercolor</b><br />Watercolor painting of a Parisian cafe terrace…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-c9208df321b440f38f1baba201b3dcb7_0.jpeg" width="200" alt="Art · Oil — FLUX.2 Klein AI image" /><br /><sub><b>Art · Oil</b><br />Classical oil painting of a stormy sea…</sub></td>
    </tr>
    <tr>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-d970d0d52a9f4f4aa55789a78ebad116_0.jpeg" width="200" alt="Art · Anime — FLUX.2 Klein AI image" /><br /><sub><b>Art · Anime</b><br />Anime key visual of a girl standing…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-b3a830cdc7ed4458802daa016879069e_0.jpeg" width="200" alt="Art · Storybook — FLUX.2 Klein AI image" /><br /><sub><b>Art · Storybook</b><br />Children's book illustration of a friendly dragon…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-0d58a35d37754ea99ed11e8b2e77eba0_0.jpeg" width="200" alt="Art · Minimalist — FLUX.2 Klein AI image" /><br /><sub><b>Art · Minimalist</b><br />Minimalist flat-design illustration of a mountain sunrise…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-aca6b5ab3dae4d5aab2f050f349fc37e_0.jpeg" width="200" alt="3D · Character — FLUX.2 Klein AI image" /><br /><sub><b>3D · Character</b><br />Pixar-style 3D render of a curious baby…</sub></td>
    </tr>
    <tr>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-48716e2d5bb34c1db5a82ad5afe7fd4c_0.jpeg" width="200" alt="Fantasy · Matte — FLUX.2 Klein AI image" /><br /><sub><b>Fantasy · Matte</b><br />Epic fantasy concept art of a floating…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-1aea2cd398cf49a386196a789e6d0422_0.jpeg" width="200" alt="Sci-fi · Cyberpunk — FLUX.2 Klein AI image" /><br /><sub><b>Sci-fi · Cyberpunk</b><br />Cyberpunk megacity skyline at night, towering holographic…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-062097a8e4544cbfb4d78bc7164c8c4d_0.jpeg" width="200" alt="Sci-fi · Alien — FLUX.2 Klein AI image" /><br /><sub><b>Sci-fi · Alien</b><br />Bioluminescent alien jungle at night, glowing flora…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-0c090d1b58a2410bb10c24992080b874_0.jpeg" width="200" alt="Design · Logo — FLUX.2 Klein AI image" /><br /><sub><b>Design · Logo</b><br />Minimalist logo with the text "AURORA" in…</sub></td>
    </tr>
    <tr>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-8101ff59c0d349219df36e8890a3d5d5_0.jpeg" width="200" alt="Design · Architecture — FLUX.2 Klein AI image" /><br /><sub><b>Design · Architecture</b><br />Architectural visualization of a modern glass-and-wood cabin…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-7416cc9588ab4126803cbcbcf8c0a3eb_0.jpeg" width="200" alt="Design · Poster — FLUX.2 Klein AI image" /><br /><sub><b>Design · Poster</b><br />Vintage travel poster of the Amalfi Coast…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-65d1af35468541a48e2cb3f683eaf803_0.jpeg" width="200" alt="Nature · Wildlife — FLUX.2 Klein AI image" /><br /><sub><b>Nature · Wildlife</b><br />Wildlife photo of a Bengal tiger emerging…</sub></td>
      <td align="center" width="25%"><img src="https://cdn.doggi-dev.net/media-gen-gateway/req-d5cf96f7e4fb4fb0b6f8973f0291bf85_0.jpeg" width="200" alt="Fashion · Editorial — FLUX.2 Klein AI image" /><br /><sub><b>Fashion · Editorial</b><br />High-fashion editorial portrait, model in an avant-garde…</sub></td>
    </tr>
</table>

### Why this Actor?

- ⚡ **Fast** — FLUX.2 Klein is distilled for speed and runs in as few as **4 steps**, generating an image in **a few seconds** (most hosted endpoints take much longer).
- 💸 **Cheap** — from **$0.003 per image** (as low as $3 per 1,000) for both text-to-image and image-to-image. Pay only for successful images; failed runs are never charged.
- 🎨 **Quality** — FLUX.2 Klein delivers sharp detail, strong prompt following, and excellent text rendering.
- 🔌 **Automation-ready** — call it from the Apify API, n8n, Make, Zapier, LangChain, or any AI agent via MCP.
- 📐 **Flexible formats** — square, portrait, and landscape sizes for text-to-image; 15 aspect ratios for image-to-image.
- 🖼️ **Batch** — generate up to **4 images** per run.

### How it compares

| | This Actor (FLUX.2 Klein) | Midjourney / DALL·E / Firefly |
| --- | --- | --- |
| Pricing model | Pay per image (from $0.003) | Monthly subscription / credits |
| Commitment | None — pay only for what you run | Recurring plan, credits expire |
| Failed runs | Never charged | Often consume credits |
| Speed | A few seconds | Seconds to minutes |
| API & automation | Native Apify API, n8n, Make, Zapier, MCP | Varies / limited |
| Text-to-image & image-to-image | Both, one Actor | Varies |
| Watermark | None | Often on lower tiers |

Great when you want **image generation on demand** without a subscription — ideal for occasional use, automated pipelines, and pay-as-you-go scaling.

### How it works

1. Pick a **Mode** — *Text to Image* or *Image to Image* — and write a **prompt**.
2. For *Image to Image*, add a public **image URL** to edit (Mode switches automatically when an image is provided).
3. The Actor generates your image(s) and stores them in the run's dataset and key-value store.
4. Download the file(s) from the output, or pipe the URL into the next step of your workflow.

### Input example — Text to Image

```json
{
    "mode": "text-to-image",
    "prompt": "A beautiful sunset over a calm ocean, cinematic, highly detailed",
    "imageSize": "landscape_16_9",
    "numImages": 1,
    "numInferenceSteps": 4,
    "outputFormat": "jpeg"
}
````

### Input example — Image to Image

```json
{
    "mode": "image-to-image",
    "prompt": "make it a watercolor painting at sunset",
    "imageUrl": "https://cdn.doggi-dev.net/media-gen-gateway/req-b6f24df387a7461788b4bfafffe9c7e7_0.jpeg",
    "aspectRatio": "auto",
    "numImages": 1,
    "outputFormat": "jpeg"
}
```

### Output sizes

FLUX.2 Klein renders at roughly **1 megapixel**. For **Text to Image**, pick `imageSize`:

| `imageSize` | Output (px) | Best for |
| --- | --- | --- |
| `square_hd` | 1024 × 1024 | avatars, icons, square posts |
| `square` | 1024 × 1024 | square posts |
| `landscape_4_3` | 1152 × 896 | classic landscape |
| `landscape_16_9` | 1344 × 768 | YouTube thumbnails, banners, wallpapers |
| `portrait_4_3` | 896 × 1152 | classic portrait |
| `portrait_16_9` | 768 × 1344 | phone wallpapers, Reels/Shorts covers |
| `auto` | model decides (~1 MP) | let the model choose |

For **Image to Image**, the output stays ~1 MP and follows `aspectRatio` (`auto` preserves the input image's ratio).

### Output example

```json
{
    "imageUrl": "https://api.apify.com/v2/key-value-stores/.../records/image_1.jpg?signature=...",
    "prompt": "A beautiful sunset over a calm ocean, cinematic, highly detailed",
    "mode": "text-to-image",
    "width": 1024,
    "height": 576,
    "seed": 42,
    "requestId": "req-...",
    "model": "flux-2-klein-t2i"
}
```

### Pricing

You are charged **per generated image** — for both text-to-image and image-to-image — at a price that drops with your Apify plan. The price is the same whether you generate 1 or 4 images per run.

| Apify plan | Price per image | Per 1,000 images |
| --- | --- | --- |
| Free | $0.0040 | $4.00 |
| Bronze | $0.0038 | $3.80 |
| Silver | $0.0035 | $3.50 |
| Gold / Platinum / Diamond | $0.0030 | $3.00 |

Generate up to 4 images per run. **Failed generations are never charged** — you only pay for images you actually receive. (Apify also applies its standard tiny platform fees for the Actor start and each dataset record.)

### Tips for great results

- **Be specific** — describe subject, style, lighting, and mood: "a red fox in a snowy forest at golden hour, cinematic, shallow depth of field".
- For **Image to Image**, describe the *change* you want ("turn it into a watercolor", "make it night time"), not the whole scene.
- Use the **negative prompt** (text-to-image) to suppress artifacts: "blurry, low quality, distorted, extra fingers".
- Keep **steps at 4** for the fastest, cheapest results; raise them only if you want extra detail.
- Set a **seed** to reproduce or iterate on a result you like.

### 🎬 Bring your images to life — Wan 2.2 Image to Video

Generated an image you love? **Animate it.** Our companion Actor, **[Wan 2.2 Image to Video Generator (Lightning)](https://apify.com/danitn11/wan22-lightning-image-to-video)**, turns any still image into a smooth MP4 video in 15–60 seconds — perfect for **TikTok, Reels, and YouTube Shorts**.

- ⚡ **Fast** — Lightning-distilled Wan 2.2 on dedicated GPUs.
- 💸 **Cheap** — pay per second of video, from $0.02/s. No subscription.
- 🎞️ **Built for social** — 16:9, 9:16, 1:1, 4:3, 3:4 formats.
- 🔗 **Chains perfectly** — generate here, then pipe the `imageUrl` straight into Wan 2.2 to get a finished video.

**The complete pipeline:**

```
FLUX.2 Klein (this Actor) → image
  → Wan 2.2 Image to Video → MP4
  → post to TikTok / Reels / Shorts
```

👉 **[Try Wan 2.2 Image to Video →](https://apify.com/danitn11/wan22-lightning-image-to-video)**

### Use it from the API

```bash
curl -X POST "https://api.apify.com/v2/acts/danitn11~flux2-klein-image-generator/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "prompt": "A beautiful sunset over a calm ocean, cinematic", "imageSize": "landscape_16_9" }'
```

Works the same from the [Apify n8n node](https://apify.com/integrations), Make, Zapier, LangChain, or the Apify MCP server for AI agents.

For the full request/response shape (run-sync, async, polling, downloading the image), see the OpenAPI spec at [`openapi.yaml`](./openapi.yaml) — import it into Postman, Insomnia, or any OpenAPI client.

### Templates & integrations

Drop this Actor into a no-code workflow to automate image creation end to end. In each tool, search for the **Apify** connector, authenticate with your [Apify API token](https://console.apify.com/account/integrations), and select **`danitn11/flux2-klein-image-generator`** with the action **Run Actor** (or **Run Actor and get dataset items** to receive the image URL back).

- **n8n** — add the **Apify** node → *Run Actor*, map `prompt` (and `imageUrl` for editing) from a previous step (e.g. a new row in a Sheet or a form submission), then push the resulting `imageUrl` to your publishing node.
- **Make.com** — use the **Apify › Run an Actor** module, then a *Watch / Get dataset items* module to read back `imageUrl`. Chain into Buffer, Google Drive, or a social uploader.
- **Zapier** — trigger (new row, form submission, etc.) → **Apify: Run Actor** → action (post to social, save to Drive, send a Slack message).

**Common pattern — automated image pipeline:**

```
New prompt (Sheet / form / webhook)
  → Run this Actor (prompt [+ imageUrl])
  → Get imageUrl
  → Post to social / save to storage / attach to a listing
```

### Use with AI agents (MCP server)

This Actor works as a tool for any MCP-compatible AI agent (Claude, Cursor, VS Code Copilot, custom agents) through [Apify's hosted MCP server](https://mcp.apify.com). Your agent can generate or edit images as part of a larger task — "design a thumbnail and post it" — with billing through your Apify account.

**Server URL** (with this Actor preselected as a tool):

```
https://mcp.apify.com?tools=danitn11/flux2-klein-image-generator
```

Authenticate with OAuth (you'll be redirected on first connect) or an `Authorization: Bearer <APIFY_TOKEN>` header.

**Claude Code**

```bash
claude mcp add --transport http apify "https://mcp.apify.com?tools=danitn11/flux2-klein-image-generator" -H "Authorization: Bearer <APIFY_TOKEN>"
```

**Claude Desktop / claude.ai** — add a custom connector with the server URL above (OAuth flow handles auth).

**Cursor / VS Code** — add to `.cursor/mcp.json` (or "MCP: Open User Configuration" in VS Code):

```json
{
    "mcpServers": {
        "apify": {
            "url": "https://mcp.apify.com?tools=danitn11/flux2-klein-image-generator",
            "headers": { "Authorization": "Bearer <APIFY_TOKEN>" }
        }
    }
}
```

**Local stdio (npx)**

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": ["-y", "@apify/actors-mcp-server", "--tools", "danitn11/flux2-klein-image-generator"],
            "env": { "APIFY_TOKEN": "<APIFY_TOKEN>" }
        }
    }
}
```

Then just ask your agent: *"Generate a 16:9 image of a sunset over the ocean, cinematic."* The agent calls the Actor, waits for the result, and gets back the image URL from the output schema.

### FAQ

**How long does it take to generate an image?**
Typically just a few seconds — FLUX.2 Klein is distilled to run in as few as 4 steps on dedicated GPUs.

**What's the difference between Text to Image and Image to Image?**
Text to Image creates a brand-new image from your prompt. Image to Image takes a photo you supply (via URL) and transforms or restyles it according to your prompt.

**What image formats are supported?**
Input (for editing): JPG, PNG, and WebP via a publicly accessible URL. Output: JPEG, PNG, or WebP — your choice.

**Can I generate more than one image at a time?**
Yes — up to 4 images per run. You're charged per image, from $0.003 depending on your Apify plan.

**Is there a watermark?**
No. The output images are clean and ready to publish.

**What model is used?**
FLUX.2 Klein — a fast, distilled image generation model for both text-to-image and image-to-image.

# Actor input Schema

## `mode` (type: `string`):

Choose Text to Image to generate from a prompt, or Image to Image to edit/transform an existing image. If you provide an Image URL, Image to Image is used automatically.

## `prompt` (type: `string`):

Describe the image you want. For Image to Image, describe the change or new look you want applied to the input image, e.g. "make it a watercolor painting at sunset".

## `imageUrl` (type: `string`):

Publicly accessible URL of the source image to edit (JPG, PNG, or WebP). Required for Image to Image. Must be directly downloadable — no Google Drive share links, localhost, or auth-gated URLs. Example: https://cdn.doggi-dev.net/media-gen-gateway/req-b6f24df387a7461788b4bfafffe9c7e7\_0.jpeg

## `imageUrls` (type: `array`):

Optional extra reference images for multi-image editing/compositing. Used with Image to Image. The main Image URL is included automatically.

## `aspectRatio` (type: `string`):

Output aspect ratio for Image to Image. "auto" keeps the input image's ratio.

## `strength` (type: `number`):

How much to change the input image, 0–1. Lower keeps more of the original; higher follows the prompt more freely. Leave empty for the model default.

## `imageSize` (type: `string`):

Output size/orientation for Text to Image.

## `negativePrompt` (type: `string`):

What to avoid in the image, e.g. "blurry, low quality, distorted, extra fingers".

## `numImages` (type: `integer`):

How many images to generate per run, 1–4. You are charged per output image.

## `guidanceScale` (type: `number`):

How strictly the model follows your prompt. FLUX.2 Klein is guidance-distilled — 1.0 is the recommended default for the best speed and quality. Higher values follow the prompt more literally but can reduce realism.

## `outputFormat` (type: `string`):

Image file format. JPEG is smallest/fastest; PNG is lossless; WebP balances both.

## `seed` (type: `integer`):

Set a seed for reproducible results. Leave empty for a random image each run.

## Actor input object example

```json
{
  "mode": "text-to-image",
  "prompt": "A beautiful sunset over a calm ocean, cinematic, highly detailed",
  "aspectRatio": "auto",
  "imageSize": "landscape_4_3",
  "numImages": 1,
  "guidanceScale": 1,
  "outputFormat": "jpeg"
}
```

# Actor output Schema

## `image` (type: `string`):

The first generated image stored in the run's key-value store, ready to download or embed.

## `results` (type: `string`):

Dataset records with every image URL, prompt, mode, dimensions, and seed.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "prompt": "A beautiful sunset over a calm ocean, cinematic, highly detailed"
};

// Run the Actor and wait for it to finish
const run = await client.actor("danitn11/flux2-klein-image-generator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "prompt": "A beautiful sunset over a calm ocean, cinematic, highly detailed" }

# Run the Actor and wait for it to finish
run = client.actor("danitn11/flux2-klein-image-generator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "prompt": "A beautiful sunset over a calm ocean, cinematic, highly detailed"
}' |
apify call danitn11/flux2-klein-image-generator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=danitn11/flux2-klein-image-generator",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "FLUX.2 Klein Image Generator (Text-to-Image & Image-to-Image)",
        "description": "Fast, cheap AI image generator & editor powered by FLUX.2 Klein. Text-to-image and image-to-image in seconds, just $4/1000 images. No GPU or subscription — a pay-as-you-go Midjourney, DALL-E & Flux alternative.",
        "version": "0.1",
        "x-build-id": "A7dtX26zYXghRkeVn"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/danitn11~flux2-klein-image-generator/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-danitn11-flux2-klein-image-generator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/danitn11~flux2-klein-image-generator/runs": {
            "post": {
                "operationId": "runs-sync-danitn11-flux2-klein-image-generator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/danitn11~flux2-klein-image-generator/run-sync": {
            "post": {
                "operationId": "run-sync-danitn11-flux2-klein-image-generator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "prompt"
                ],
                "properties": {
                    "mode": {
                        "title": "Mode",
                        "enum": [
                            "text-to-image",
                            "image-to-image"
                        ],
                        "type": "string",
                        "description": "Choose Text to Image to generate from a prompt, or Image to Image to edit/transform an existing image. If you provide an Image URL, Image to Image is used automatically.",
                        "default": "text-to-image"
                    },
                    "prompt": {
                        "title": "Prompt",
                        "type": "string",
                        "description": "Describe the image you want. For Image to Image, describe the change or new look you want applied to the input image, e.g. \"make it a watercolor painting at sunset\".",
                        "default": "A beautiful sunset over a calm ocean, cinematic, highly detailed"
                    },
                    "imageUrl": {
                        "title": "Image URL (Image to Image only)",
                        "type": "string",
                        "description": "Publicly accessible URL of the source image to edit (JPG, PNG, or WebP). Required for Image to Image. Must be directly downloadable — no Google Drive share links, localhost, or auth-gated URLs. Example: https://cdn.doggi-dev.net/media-gen-gateway/req-b6f24df387a7461788b4bfafffe9c7e7_0.jpeg"
                    },
                    "imageUrls": {
                        "title": "Additional image URLs (optional)",
                        "type": "array",
                        "description": "Optional extra reference images for multi-image editing/compositing. Used with Image to Image. The main Image URL is included automatically.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "aspectRatio": {
                        "title": "Aspect ratio (Image to Image)",
                        "enum": [
                            "auto",
                            "21:9",
                            "16:9",
                            "3:2",
                            "4:3",
                            "5:4",
                            "1:1",
                            "4:5",
                            "3:4",
                            "2:3",
                            "9:16",
                            "4:1",
                            "1:4",
                            "8:1",
                            "1:8"
                        ],
                        "type": "string",
                        "description": "Output aspect ratio for Image to Image. \"auto\" keeps the input image's ratio.",
                        "default": "auto"
                    },
                    "strength": {
                        "title": "Strength (Image to Image)",
                        "minimum": 0,
                        "maximum": 1,
                        "type": "number",
                        "description": "How much to change the input image, 0–1. Lower keeps more of the original; higher follows the prompt more freely. Leave empty for the model default."
                    },
                    "imageSize": {
                        "title": "Image size (Text to Image)",
                        "enum": [
                            "square_hd",
                            "square",
                            "portrait_4_3",
                            "portrait_16_9",
                            "landscape_4_3",
                            "landscape_16_9",
                            "auto"
                        ],
                        "type": "string",
                        "description": "Output size/orientation for Text to Image.",
                        "default": "landscape_4_3"
                    },
                    "negativePrompt": {
                        "title": "Negative prompt (Text to Image)",
                        "type": "string",
                        "description": "What to avoid in the image, e.g. \"blurry, low quality, distorted, extra fingers\"."
                    },
                    "numImages": {
                        "title": "Number of images",
                        "minimum": 1,
                        "maximum": 4,
                        "type": "integer",
                        "description": "How many images to generate per run, 1–4. You are charged per output image.",
                        "default": 1
                    },
                    "guidanceScale": {
                        "title": "Guidance scale (CFG)",
                        "minimum": 0,
                        "maximum": 20,
                        "type": "number",
                        "description": "How strictly the model follows your prompt. FLUX.2 Klein is guidance-distilled — 1.0 is the recommended default for the best speed and quality. Higher values follow the prompt more literally but can reduce realism.",
                        "default": 1
                    },
                    "outputFormat": {
                        "title": "Output format",
                        "enum": [
                            "jpeg",
                            "png",
                            "webp"
                        ],
                        "type": "string",
                        "description": "Image file format. JPEG is smallest/fastest; PNG is lossless; WebP balances both.",
                        "default": "jpeg"
                    },
                    "seed": {
                        "title": "Seed (optional)",
                        "type": "integer",
                        "description": "Set a seed for reproducible results. Leave empty for a random image each run."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
