> ## 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.

# Qwen Image 2.0 Image Generation

>  - Asynchronous processing mode, returns task ID for subsequent queries
- Supports text-to-image, image-to-image and other generation modes
- Supports 1K/2K resolution tiers, generate up to 6 images 

<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": "qwen-image-2.0",
      "prompt": "A cute orange cat napping in the sunshine"
    }'
  ```

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

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

  payload = {
      "model": "qwen-image-2.0",
      "prompt": "A cute orange cat napping in the sunshine"
  }

  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: "qwen-image-2.0",
    prompt: "A cute orange cat napping in the sunshine",
  };

  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_01JGXYZ1234567890ABCDEF"
      }
    ]
  }
  ```

  ```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                                                           | Max Images | Pricing     |
| -------------------- | --------------------------------------------------------------------- | ---------- | ----------- |
| `qwen-image-2.0`     | Standard version, balanced quality and performance                    | 6          | Fixed price |
| `qwen-image-2.0-pro` | Pro version, stronger text rendering, more refined realistic textures | 6          | Fixed price |

## 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

  * `qwen-image-2.0` - Standard version, balanced quality and performance
  * `qwen-image-2.0-pro` - Pro version, stronger text rendering, more refined realistic textures
</ParamField>

<ParamField body="prompt" type="string" required>
  Text description for image generation, up to 800 characters
</ParamField>

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

  Supported aspect ratios:

  * `1:1` - Square (default)
  * `4:3` - Landscape 4:3
  * `3:4` - Portrait 3:4
  * `16:9` - Landscape widescreen
  * `9:16` - Portrait vertical
  * `3:2` - Landscape 3:2
  * `2:3` - Portrait 2:3
</ParamField>

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

  * `1K` - Standard resolution (default)
  * `2K` - High definition resolution
</ParamField>

<ParamField body="n" type="integer" default="1">
  Number of images to generate

  Range: 1-6
</ParamField>

<ParamField body="negative_prompt" type="string">
  Negative prompt (content you don't want to appear), up to 500 characters
</ParamField>

<ParamField body="image_urls" type="array">
  Reference image URL array (image-to-image mode)

  **Limitations:**

  * Must be publicly accessible URLs
  * Base64 format not supported
</ParamField>

## Resolution Reference Table

Output size is controlled by the combination of `size` (ratio) + `resolution` (resolution tier).

| Ratio  | 1K Tier   | 2K Tier   |
| ------ | --------- | --------- |
| `1:1`  | 1024×1024 | 2048×2048 |
| `4:3`  | 1152×864  | 2048×1536 |
| `3:4`  | 864×1152  | 1536×2048 |
| `16:9` | 1280×720  | 2048×1152 |
| `9:16` | 720×1280  | 1152×2048 |
| `3:2`  | 1248×832  | 2048×1360 |
| `2:3`  | 832×1248  | 1360×2048 |

* Only `size` → defaults to 1K tier: `{"size": "16:9"}` → 1280×720
* `size` + `resolution` → specified tier: `{"size": "16:9", "resolution": "2K"}` → 2048×1152

## Usage Examples

**Text-to-Image (minimal request)**

```json theme={null}
{
  "model": "qwen-image-2.0",
  "prompt": "A cute orange cat napping in the sunshine"
}
```

**Specify ratio and count**

```json theme={null}
{
  "model": "qwen-image-2.0-pro",
  "prompt": "Cyberpunk-style futuristic city nightscape with flickering neon lights",
  "size": "16:9",
  "n": 4
}
```

**High definition 2K tier**

```json theme={null}
{
  "model": "qwen-image-2.0-pro",
  "prompt": "Exquisite food photography, sushi platter",
  "size": "4:3",
  "resolution": "2K",
  "n": 2
}
```

**Image-to-Image (reference image + text description)**

```json theme={null}
{
  "model": "qwen-image-2.0",
  "prompt": "Change the background to a seaside sunset",
  "image_urls": ["https://example.com/my-photo.jpg"]
}
```

## 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. **Asynchronous Processing**: After submission, a `task_id` is returned. Poll `/v1/tasks/{task_id}` to get results
2. **Image Storage**: Generated images are mirrored to platform CDN and are valid long-term
3. **Billing Rules**: Billed per successfully generated image, no charge for failures
4. **Image URL Requirements**: Input images must be publicly accessible URLs, base64 not supported
