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

# FLUX.1 Kontext [pro]

> FLUX.1 Kontext [pro] image editing & generation model by Black Forest Labs via Anyfast API.

FLUX.1 Kontext \[pro] is a context-aware image generation model from Black Forest Labs, available through Anyfast. It can generate new images from text prompts, or edit existing images based on text instructions. Both endpoints are **synchronous** — they return the generated image directly as base64-encoded data.

* **Text-to-image** — POST JSON to `/v1/images/generations`
* **Image editing** — POST multipart form data to `/v1/images/edits`

## Key capabilities

* **Image editing** — Modify existing images with text instructions (e.g. "change the red car to blue")
* **Text-to-image** — Generate images from text prompts
* **Context-aware** — Understands and preserves context from the reference image
* **Reproducible** — Use `seed` for deterministic generation

## Quick example

### Text-to-image

<CodeGroup>
  ```bash cURL theme={null}
  curl https://www.anyfast.ai/v1/images/generations \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "flux-1-kontext-pro",
      "prompt": "A cute baby polar bear",
      "size": "1024x1024"
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://www.anyfast.ai/v1/images/generations",
      headers={"Authorization": "Bearer YOUR_API_KEY"},
      json={
          "model": "flux-1-kontext-pro",
          "prompt": "A cute baby polar bear",
          "size": "1024x1024"
      }
  )

  result = response.json()
  # result["data"][0]["b64_json"] contains the base64-encoded image
  ```
</CodeGroup>

### Image editing

<CodeGroup>
  ```bash cURL theme={null}
  curl https://www.anyfast.ai/v1/images/edits \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -F "model=flux-1-kontext-pro" \
    -F "image=@/path/to/photo.jpg" \
    -F "prompt=Change the background to a sunset beach" \
    -F "size=1024x1024"
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://www.anyfast.ai/v1/images/edits",
      headers={"Authorization": "Bearer YOUR_API_KEY"},
      files={"image": open("/path/to/photo.jpg", "rb")},
      data={
          "model": "flux-1-kontext-pro",
          "prompt": "Change the background to a sunset beach",
          "size": "1024x1024"
      }
  )

  result = response.json()
  # result["data"][0]["b64_json"] contains the base64-encoded image
  ```
</CodeGroup>

## Text-to-image parameters

| Parameter       | Type    | Required | Description                                         |
| --------------- | ------- | -------- | --------------------------------------------------- |
| `model`         | string  | Yes      | Must be `flux-1-kontext-pro`                        |
| `prompt`        | string  | Yes      | Image description. **⚠️ Prompt must be in English** |
| `n`             | integer | No       | Number of images. Only `1` is supported             |
| `size`          | string  | No       | Output size, e.g. `1024x1024`                       |
| `output_format` | string  | No       | `jpeg` or `png`                                     |
| `seed`          | integer | No       | Random seed for reproducibility                     |

## Image editing parameters

| Parameter | Type    | Required | Description                                            |
| --------- | ------- | -------- | ------------------------------------------------------ |
| `model`   | string  | Yes      | Must be `flux-1-kontext-pro`                           |
| `image`   | file    | Yes      | Image file to edit (multipart upload)                  |
| `prompt`  | string  | Yes      | Editing instructions. **⚠️ Prompt must be in English** |
| `n`       | integer | No       | Number of images. Only `1` is supported                |
| `size`    | string  | No       | Output size, e.g. `1024x1024`                          |

## Response

| Field             | Description               |
| ----------------- | ------------------------- |
| `data[].b64_json` | Base64-encoded image data |
| `created`         | Unix timestamp            |

<Card title="API Reference" icon="code" href="/api-reference/model-api/blackforestlabs/flux-1-kontext-pro">
  View the interactive API playground for FLUX.1 Kontext \[pro].
</Card>

<script src="/feedback.js" />
