Files
AutoGPT/docs/content/platform/blocks/flux_kontext.md
Toran Bruce Richards 3f6585f763 feat(platform/blocks): add AI Image Editor Block powered by flux kontext (#10063)
<!-- Clearly explain the need for these changes: -->

This PR adds a new internal block, **AI Image Editor**, which enables
**text-based image editing** via BlackForest Labs’ Flux Kontext models
on Replicate. This block allows users to input a prompt and optionally a
reference image, and returns a transformed image URL. It supports two
model variants (Pro and Max), with different cost tiers. This
functionality will enhance multimedia capabilities across internal agent
workflows and support richer AI-powered image manipulation.

---

### Changes 🏗️

* Added `FluxKontextBlock` in `backend/blocks/flux_kontext.py`

  * Uses `ReplicateClient` to call Flux Kontext Pro or Max models
* Supports inputs for `prompt`, `input_image`, `aspect_ratio`, `seed`,
and `model`
  * Outputs transformed image URL or error
* Added credit pricing logic for Flux Kontext models to
`block_cost_config.py`:

  * Pro: 10 credits
  * Max: 20 credits
* Added documentation for the new block at
`docs/content/platform/blocks/flux_kontext.md`
* Updated block index at `docs/content/platform/blocks/blocks.md` to
include Flux Kontext

---


![image](https://github.com/user-attachments/assets/0edb2b30-4c37-4184-bcc8-9d733658f620)


### Checklist 📋

#### For code changes:

* [x] I have clearly listed my changes in the PR description
* [x] I have made a test plan
* [x] I have tested my changes according to the test plan:

  <!-- Put your test plan here: -->

  * [x] Prompt-only input generates an image
  * [x] Prompt with image applies edit correctly
  * [x] Image respects specified aspect ratio
  * [x] Invalid image URL returns helpful error
  * [x] Using the same seed gives consistent output
* [x] Output chaining works: result URI can be used in downstream blocks
  * [x] Output from Max model shows higher fidelity than Pro

<details>
  <summary>Example test plan</summary>

* [x] Create from scratch and execute an agent using Flux Kontext with
at least 3 blocks
* [x] Import agent with Flux Kontext from file upload, and confirm
execution
* [x] Upload agent (with Flux Kontext block) to marketplace (internal
test)
* [x] Import agent from marketplace and confirm correct execution
* [x] Edit agent with Flux Kontext block from monitor and confirm output

</details>

#### For configuration changes:

* [x] `.env.example` is updated or already compatible with my changes
* [x] `docker-compose.yml` is updated or already compatible with my
changes
* [x] I have included a list of my configuration changes in the PR
description (under **Changes**)

  * No new environment variables or services introduced

<details>
  <summary>Examples of configuration changes</summary>

* N/A

</details>

---------

Co-authored-by: Zamil Majdy <zamil.majdy@agpt.co>
2025-06-02 20:46:48 +00:00

1.7 KiB

Flux Kontext

What it is

An internal block that performs text-based image editing using BlackForest Labs' Flux Kontext models.

What it does

Takes a prompt describing the desired transformation and optionally a reference image, then returns a new image URL.

How it works

The block sends your prompt, image, and settings to the selected Flux Kontext model on Replicate. The service processes the request and returns a link to the edited image.

Inputs

Input Description
Credentials Replicate API key with permissions for Flux Kontext models
Prompt Text instruction describing the desired edit
Input Image (Optional) Reference image URI (jpeg, png, gif, webp)
Aspect Ratio Aspect ratio of the generated image (e.g. match_input_image, 1:1, 16:9, etc.)
Seed (Optional, advanced) Random seed for reproducible generation
Model Model variant to use: Flux Kontext Pro or Flux Kontext Max

Outputs

Output Description
image_url URL of the transformed image
error Error message if generation failed

Use Cases

  • Enhance a marketing image by requesting "add soft lighting and a subtle vignette" while providing the original asset as the reference image.
  • Generate social media assets with specific aspect ratios and style prompts.
  • Apply creative edits to product photos using text instructions.