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

# Flux 2.0 Image Generation

>  - Asynchronous processing mode, returns task ID for subsequent queries
- Supports text-to-image and image-to-image generation
- Generated image links are valid for 24 hours, please save promptly 

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://gccai.heqingsong.uk/v1/images/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "flux-2-flex",
      "prompt": "A blue cat on the grass",
      "resolution": "1K",
      "size": "16:9"
    }'
  ```

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

  url = "https://gccai.heqingsong.uk/v1/images/generations"

  payload = {
      "model": "flux-2-flex",
      "prompt": "A blue cat on the grass",
      "resolution": "1K",
      "size": "16:9"
  }

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }

  response = requests.post(url, json=payload, headers=headers)

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const url = "https://gccai.heqingsong.uk/v1/images/generations";

  const payload = {
    model: "flux-2-flex",
    prompt: "A blue cat on the grass",
    resolution: "1K",
    size: "16:9"
  };

  const headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
  };

  fetch(url, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(payload)
  })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 200,
    "data": [
      {
        "status": "submitted",
        "task_id": "task_01KFG5BBFNK1YQDTJDZY0P0QT2"
      }
    ]
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "code": 400,
      "message": "Invalid request parameters",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": 401,
      "message": "Authentication failed, please check your API key",
      "type": "authentication_error"
    }
  }
  ```

  ```json 402 theme={null}
  {
    "error": {
      "code": 402,
      "message": "Insufficient balance, please top up",
      "type": "payment_required"
    }
  }
  ```
</ResponseExample>

## Supported Models

| Model         | Description                                                                  | Pricing               |
| ------------- | ---------------------------------------------------------------------------- | --------------------- |
| `flux-2-flex` | Flux 2.0 Flex image generation model (faster, suitable for quick iterations) | By resolution (1K/2K) |
| `flux-2-pro`  | Flux 2.0 Pro image generation model (higher quality, better details)         | By resolution (1K/2K) |

## Authorizations

<ParamField header="Authorization" type="string" required>
  All endpoints require Bearer Token authentication

  Get API Key:

  Visit [API Key Management](https://gccai.heqingsong.uk/keys) to get your API Key

  Add to request header:

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Body

<ParamField body="model" type="string" required>
  Model name

  * `flux-2-flex` - Flux 2.0 Flex model (faster, suitable for quick iterations)
  * `flux-2-pro` - Flux 2.0 Pro model (higher quality, better details)
</ParamField>

<ParamField body="prompt" type="string" required>
  Text description for image generation
</ParamField>

<ParamField body="resolution" type="string" default="1K">
  Image resolution

  Supported resolutions:

  * `1K` - Default, 1080p level
  * `2K` - HD, max 2048 pixels

  > Case insensitive: `1k`, `1K`, `2k`, `2K` all work
</ParamField>

<ParamField body="size" type="string" default="1:1">
  Image aspect ratio

  Supported aspect ratios:

  * `1:1` - Square (default)
  * `4:3` - Landscape
  * `3:4` - Portrait
  * `16:9` - Widescreen
  * `9:16` - Vertical
  * `3:2` - Classic landscape
  * `2:3` - Classic portrait

  > Only these 7 ratios are supported, unsupported ratios will return an error
</ParamField>

<ParamField body="image_urls" type="array">
  Reference image URL list

  **Limitations:**

  * Maximum 8 images
  * Must be publicly accessible URL
  * Base64 format not supported
</ParamField>

## Resolution Reference Table

| Ratio  | Name              | 1K Size   | 2K Size   |
| ------ | ----------------- | --------- | --------- |
| `1:1`  | Square            | 1440×1440 | 1536×1536 |
| `4:3`  | Landscape         | 1664×1248 | 1824×1368 |
| `3:4`  | Portrait          | 1248×1664 | 1368×1824 |
| `16:9` | Widescreen        | 1920×1080 | 2048×1152 |
| `9:16` | Vertical          | 1080×1920 | 1152×2048 |
| `3:2`  | Classic Landscape | 1728×1152 | 1872×1248 |
| `2:3`  | Classic Portrait  | 1152×1728 | 1248×1872 |

## Usage Examples

**Basic Text-to-Image**

```json theme={null}
{
    "model": "flux-2-flex",
    "prompt": "A blue cat",
    "resolution": "1K",
    "size": "16:9"
}
```

**High Resolution Generation**

```json theme={null}
{
    "model": "flux-2-pro",
    "prompt": "Detailed landscape painting with mountains and rivers",
    "resolution": "2K",
    "size": "16:9"
}
```

**Image-to-Image (up to 8 reference images)**

```json theme={null}
{
    "model": "flux-2-flex",
    "prompt": "Convert image to watercolor style",
    "image_urls": [
        "https://example.com/input1.jpg",
        "https://example.com/input2.jpg"
    ],
    "resolution": "1K"
}
```

## Response

<ResponseField name="code" type="integer">
  Response status code
</ResponseField>

<ResponseField name="data" type="array">
  Response data array

  <Expandable title="Properties">
    <ResponseField name="status" type="string">
      Task status

      * `submitted` - Submitted
    </ResponseField>

    <ResponseField name="task_id" type="string">
      Task unique identifier
    </ResponseField>
  </Expandable>
</ResponseField>

## Notes

1. **Image URL Requirements**: Input images must be publicly accessible URLs, base64 not supported
2. **Result Storage**: Generated images are automatically stored, URLs valid for 24 hours
3. **Task Polling**: Tasks are processed asynchronously, poll `/v1/tasks/{task_id}` for results
4. **Input Image Limits**: Up to 8 reference images supported
