# FLUX 3 Image Klein

> Generate and edit images with FLUX 3 Image Klein. Use 1K, 2K or 4K output, up to ten editing references, custom dimensions, and PNG, JPEG or WebP output.

## Overview

- Submit: `https://api.poyo.ai/api/generate/submit`
- Status: `https://api.poyo.ai/api/generate/status/{task_id}`
- Page: https://poyo.ai/models/flux-3-klein
- Model page ID: `flux-3-klein`
- API model IDs: `flux-3-klein`, `flux-3-klein-edit`
- Category: Image
- Auth: `Authorization: Bearer $POYO_API_KEY`
- Create a key at https://poyo.ai/dashboard/api-key

This model uses PoYo's unified async API. POST the JSON body below, then poll status with the returned `task_id` or receive a webhook on `callback_url`. Failed tasks are not charged.

## Pricing

- 1K: 1.8 credits ($0.009) per image
- 2K: 2.8 credits ($0.014) per image
- 4K: 7.2 credits ($0.036) per image

For more details, see https://poyo.ai/models/flux-3-klein.

## API Information

The request envelope is always `{ model, input, callback_url? }`. Input fields below are nested under `input`.

### Request envelope

- `model` (`ModelEnum`, required):
  Public model identifier.
  - Options: `"flux-3-klein"`, `"flux-3-klein-edit"`
- `callback_url` (`string`, optional):
  Webhook URL for finished or failed task notifications.

### Input Schema

Parameters for the selected model. Media fields are required only for their corresponding mode.

The API accepts the following `input` parameters:

- `prompt` (`string`, required):
  Describe the complete target image, including the subject, framing, background, and lighting.
  - Length: 1 to unbounded characters
- `image_urls` (`list`, optional):
  Required for flux-3-klein-edit only. Supply 1-10 reference image URLs. Do not send this field for flux-3-klein.
  - Array of string
  - Length: 1 to 10
- `size` (`string`, optional):
  Output aspect ratio: 1:1, 4:3, 3:4, 16:9, 9:16, 3:2, or 2:3; or exact WIDTHxHEIGHT pixels. Custom dimensions must each be 256-4096, divisible by 16, and accompanied by an explicit matching resolution.
  - Default: `"1:1"`
- `resolution` (`ResolutionEnum`, optional):
  Output resolution tier. For an aspect ratio, the long edge is 1024, 2048, or 4096 pixels and the short edge is rounded to the nearest multiple of 16. For custom dimensions, the long edge selects the tier: at most 1024 = 1K, above 1024 through 2048 = 2K, above 2048 through 4096 = 4K.
  - Default: `"1K"`
  - Options: `"1K"`, `"2K"`, `"4K"`
- `n` (`integer`, optional):
  Number of output images.
  - Default: `1`
  - Range: `1` to `4`
- `output_format` (`OutputFormatEnum`, optional):
  Output image format.
  - Default: `"png"`
  - Options: `"jpeg"`, `"png"`, `"webp"`
- `enable_safety_checker` (`boolean`, optional):
  Enable content safety checking.
  - Default: `true`

Required Parameters Example:

```json
{
  "model": "flux-3-klein",
  "input": {
    "prompt": "A red fox in fresh snow at sunrise",
    "size": "3:2",
    "resolution": "2K"
  }
}
```

Full Example:

```json
{
  "model": "flux-3-klein",
  "input": {
    "prompt": "A red fox in fresh snow at sunrise",
    "size": "3:2",
    "resolution": "2K",
    "n": 1,
    "output_format": "png",
    "enable_safety_checker": true
  }
}
```

Edit a reference image:

```json
{
  "model": "flux-3-klein-edit",
  "input": {
    "prompt": "Keep the product from the first image and place it in a sunlit studio",
    "image_urls": [
      "https://example.com/product.png"
    ],
    "size": "4:3",
    "resolution": "1K"
  }
}
```

Use an exact pixel size:

```json
{
  "model": "flux-3-klein",
  "input": {
    "prompt": "An editorial portrait with soft window light",
    "size": "1536x1024",
    "resolution": "2K"
  }
}
```

### Output Schema

Submit returns a `task_id`. Poll `GET /api/generate/status/{task_id}` until `status` is `finished` or `failed`. Completed media is in `data.files`.

Response fields:

- `code` (`CodeEnum`, required):
  - Options: `200`
  - Examples: `200`
- `data` (`object`, required):

Example Response:

```json
{
  "code": 200,
  "data": {
    "task_id": "task_example",
    "status": "finished",
    "files": [
      {
        "file_url": "https://storage.poyo.ai/models/flux-3-klein/examples/klein-coastal-clock-output-4e84ab341601.png",
        "file_type": "image"
      }
    ]
  }
}
```

## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://api.poyo.ai/api/generate/submit \
  --header "Authorization: Bearer $POYO_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"model":"flux-3-klein","input":{"prompt":"A red fox in fresh snow at sunrise","size":"3:2","resolution":"2K"}}'
```

### Python

```python
import json
import os
import time
import requests

API = "https://api.poyo.ai"
headers = {
    "Authorization": f"Bearer {os.environ['POYO_API_KEY']}",
    "Content-Type": "application/json",
}
payload = json.loads("{\n  \"model\": \"flux-3-klein\",\n  \"input\": {\n    \"prompt\": \"A red fox in fresh snow at sunrise\",\n    \"size\": \"3:2\",\n    \"resolution\": \"2K\"\n  }\n}")

submit = requests.post(f"{API}/api/generate/submit", headers=headers, json=payload)
submit.raise_for_status()
task_id = submit.json()["data"]["task_id"]

while True:
    status = requests.get(f"{API}/api/generate/status/{task_id}", headers=headers)
    status.raise_for_status()
    data = status.json()["data"]
    if data["status"] in ("finished", "failed"):
        print(data)
        break
    time.sleep(2)
```

### JavaScript

```javascript
const headers = {
  Authorization: `Bearer ${process.env.POYO_API_KEY}`,
  "Content-Type": "application/json",
};

const submit = await fetch("https://api.poyo.ai/api/generate/submit", {
  method: "POST",
  headers,
  body: JSON.stringify({
  "model": "flux-3-klein",
  "input": {
    "prompt": "A red fox in fresh snow at sunrise",
    "size": "3:2",
    "resolution": "2K"
  }
}),
});

const submitted = await submit.json();
const taskId = submitted.data.task_id;

while (true) {
  const statusResponse = await fetch(`https://api.poyo.ai/api/generate/status/${taskId}`, { headers });
  const status = await statusResponse.json();
  if (["finished", "failed"].includes(status.data.status)) {
    console.log(status.data);
    break;
  }
  await new Promise((resolve) => setTimeout(resolve, 2000));
}
```

## Additional Resources

### Documentation

- [Model Playground](https://poyo.ai/models/flux-3-klein)
- [API Documentation](https://docs.poyo.ai/api-manual/image-series/flux-3-klein)
- [API Documentation (Markdown)](https://docs.poyo.ai/api-manual/image-series/flux-3-klein.md)
- [Task status](https://docs.poyo.ai/api-manual/task-management/query-task-status)
- [Webhooks](https://docs.poyo.ai/api-manual/task-management/webhooks)

### Other agent-readable surfaces

- [Platform overview](https://poyo.ai/llms.txt)
- [Documentation index](https://docs.poyo.ai/llms.txt)
- [Full documentation text](https://docs.poyo.ai/llms-full.txt)
- Any other model: `https://poyo.ai/models/<model-id>/llms.txt`
