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

# wan2.7 Image Generation & Editing

>  - Wan2.7 image series: supports text-to-image, image editing, interactive editing, sequential generation, and multi-image reference
- Asynchronous processing mode — submit a task and poll for results using the returned task_id
- Supports 1K / 2K / 4K resolution; wan2.7-image-pro supports up to 4K for text-to-image
- Billing is based on the number of successfully generated images, regardless of resolution or aspect ratio 

<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": "wan2.7-image-pro",
      "prompt": "A flower shop with exquisite windows, beautiful wooden door, flowers on display"
    }'
  ```

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

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

  payload = {
      "model": "wan2.7-image-pro",
      "prompt": "A flower shop with exquisite windows, beautiful wooden door, flowers on display"
  }

  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: "wan2.7-image-pro",
    prompt: "A flower shop with exquisite windows, beautiful wooden door, flowers on display"
  };

  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));
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "io/ioutil"
      "net/http"
  )

  func main() {
      url := "https://gccai.heqingsong.uk/v1/images/generations"

      payload := map[string]interface{}{
          "model":  "wan2.7-image-pro",
          "prompt": "A flower shop with exquisite windows, beautiful wooden door, flowers on display",
      }

      jsonData, _ := json.Marshal(payload)

      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", "Bearer <token>")
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      body, _ := ioutil.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```

  ```java Java theme={null}
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.net.URI;

  public class Main {
      public static void main(String[] args) throws Exception {
          String payload = """
          {
            "model": "wan2.7-image-pro",
            "prompt": "A flower shop with exquisite windows, beautiful wooden door, flowers on display"
          }
          """;

          HttpClient client = HttpClient.newHttpClient();
          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://gccai.heqingsong.uk/v1/images/generations"))
              .header("Authorization", "Bearer <token>")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(payload))
              .build();

          System.out.println(client.send(request,
              HttpResponse.BodyHandlers.ofString()).body());
      }
  }
  ```

  ```php PHP theme={null}
  <?php

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

  $payload = [
      "model" => "wan2.7-image-pro",
      "prompt" => "A flower shop with exquisite windows, beautiful wooden door, flowers on display"
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Authorization: Bearer <token>",
      "Content-Type: application/json"
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  echo $response;
  ?>
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

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

  payload = {
    model: "wan2.7-image-pro",
    prompt: "A flower shop with exquisite windows, beautiful wooden door, flowers on display"
  }

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(url)
  request["Authorization"] = "Bearer <token>"
  request["Content-Type"] = "application/json"
  request.body = payload.to_json

  response = http.request(request)
  puts response.body
  ```

  ```swift Swift theme={null}
  import Foundation

  let url = URL(string: "https://gccai.heqingsong.uk/v1/images/generations")!

  let payload: [String: Any] = [
      "model": "wan2.7-image-pro",
      "prompt": "A flower shop with exquisite windows, beautiful wooden door, flowers on display"
  ]

  var request = URLRequest(url: url)
  request.httpMethod = "POST"
  request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
  request.setValue("application/json", forHTTPHeaderField: "Content-Type")
  request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

  let task = URLSession.shared.dataTask(with: request) { data, response, error in
      if let error = error { print("Error: \(error)"); return }
      if let data = data, let str = String(data: data, encoding: .utf8) { print(str) }
  }
  task.resume()
  ```

  ```csharp C# theme={null}
  using System;
  using System.Net.Http;
  using System.Text;
  using System.Threading.Tasks;

  class Program
  {
      static async Task Main(string[] args)
      {
          var payload = @"{
              ""model"": ""wan2.7-image-pro"",
              ""prompt"": ""A flower shop with exquisite windows, beautiful wooden door, flowers on display""
          }";

          using var client = new HttpClient();
          client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");

          var content = new StringContent(payload, Encoding.UTF8, "application/json");
          var response = await client.PostAsync(
              "https://gccai.heqingsong.uk/v1/images/generations", content);
          Console.WriteLine(await response.Content.ReadAsStringAsync());
      }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": "success",
    "data": [
      {
        "task_id": "task_01HX...",
        "status": "processing"
      }
    ]
  }
  ```

  ```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 your account.",
      "type": "payment_required"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "code": 429,
      "message": "Too many requests. Please try again later.",
      "type": "rate_limit_error"
    }
  }
  ```

  ```json 500 theme={null}
  {
    "error": {
      "code": 500,
      "message": "Internal server error. Please try again later.",
      "type": "server_error"
    }
  }
  ```
</ResponseExample>

## Authorizations

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

  Visit the [API Key Management page](https://gccai.heqingsong.uk/keys) to obtain your API Key, then add it to the request header:

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

## Available Models

| Model              | Description                                       | Max Resolution (Text-to-Image) | Max Resolution (Edit / Sequential) | Price         |
| ------------------ | ------------------------------------------------- | :----------------------------: | :--------------------------------: | ------------- |
| `wan2.7-image-pro` | Professional edition, better details, supports 4K |               4K               |                 2K                 | ¥0.50 / image |
| `wan2.7-image`     | Standard edition, faster generation               |               2K               |                 2K                 | ¥0.20 / image |

<Note>
  Billing is based on **successfully generated images × unit price**. Input is not billed. Resolution and aspect ratio do not affect pricing. Failed requests are not charged.
</Note>

## Body

<ParamField body="model" type="string" required>
  Image generation model name.

  * `wan2.7-image-pro` — Professional edition, up to 4K for text-to-image
  * `wan2.7-image` — Standard edition, faster, up to 2K
</ParamField>

<ParamField body="prompt" type="string">
  Text description for image generation, up to 5000 characters.

  * **Text-to-image** (no `image_urls`): required
  * **Image editing** (with `image_urls`): optional but recommended

  Example: `"A flower shop with exquisite windows, beautiful wooden door, flowers on display"`
</ParamField>

<ParamField body="image_urls" type="array<string>">
  Input image URL array for editing and multi-image reference scenarios.

  Providing this field switches the request to **image editing mode**.

  **Supported formats:** HTTP/HTTPS URLs; `data:image/...;base64,...` Base64

  **Constraints:** Up to 9 images; JPEG / PNG / WEBP / BMP; 240–8000 px, aspect ratio 1:8 \~ 8:1; ≤ 20MB per image

  <Note>
    Output aspect ratio automatically matches the **last** input image. Editing mode supports up to 2K only — 4K is not available.
  </Note>
</ParamField>

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

  * **Standard mode**: 1–4 (default 1)
  * **Sequential mode** (`enable_sequential: true`): 1–12 (default 1)

  <Note>Billed per successfully generated image. Pre-charged based on `n`.</Note>
</ParamField>

<ParamField body="size" type="string">
  Output resolution or aspect ratio. Supports three formats:

  **① Resolution keyword (recommended):** `1K` / `2K` (default) / `4K` (`wan2.7-image-pro` text-to-image only)

  **② Aspect ratio:** `1:1` / `16:9` / `9:16` / `4:3` / `3:4` / `3:2` / `2:3` (defaults to 2K tier)

  **③ Pixel dimensions:** `1024x1024` or `1024*1024`
</ParamField>

<ParamField body="resolution" type="string">
  Resolution tier keyword: `1K` / `2K` / `4K`. Can be combined with `size` (aspect ratio).

  | Model              | Scenario                       |  Supported Tiers | Pixel Range          |
  | ------------------ | ------------------------------ | :--------------: | -------------------- |
  | `wan2.7-image-pro` | Text-to-image (non-sequential) | 1K / **2K** / 4K | 768×768 \~ 4096×4096 |
  | `wan2.7-image-pro` | Editing / sequential           |    1K / **2K**   | 768×768 \~ 2048×2048 |
  | `wan2.7-image`     | All scenarios                  |    1K / **2K**   | 768×768 \~ 2048×2048 |
</ParamField>

<ParamField body="negative_prompt" type="string">
  Negative prompt describing elements to avoid. Example: `"blurry, distorted, low quality"`
</ParamField>

<ParamField body="watermark" type="boolean" default="false">
  Whether to add an "AI Generated" watermark to the bottom-right corner.
</ParamField>

<ParamField body="seed" type="integer">
  Random seed, range 0–2147483647. Same seed with identical parameters produces visually consistent results.
</ParamField>

<ParamField body="thinking_mode" type="boolean" default="true">
  Enable enhanced reasoning mode to improve image quality at the cost of longer generation time.

  <Note>Only effective when **sequential mode is disabled** and **no image input** is provided.</Note>
</ParamField>

<ParamField body="enable_sequential" type="boolean" default="false">
  Enable **sequential image generation** mode — generates multiple thematically coherent images in one request. Ideal for storyboards and series.

  * Maximum `n` is 12 when enabled
  * `thinking_mode` and `color_palette` are ignored in sequential mode
  * `wan2.7-image-pro` supports up to 2K in sequential mode (4K not supported)
</ParamField>

<ParamField body="bbox_list" type="array">
  Bounding boxes for interactive editing — specifies exact regions to edit or insert content.

  **Structure:** `[[[x1, y1, x2, y2], ...], ...]`

  * Outer array length must equal the length of `image_urls`
  * Pass `[]` for images with no bounding box
  * Max 2 boxes per image; coordinates are absolute pixel values, origin (0,0) at top-left

  Example: `[[], [[989, 515, 1138, 681]]]`
</ParamField>

<ParamField body="color_palette" type="array<object>">
  Custom color theme. **Standard mode only** (not sequential mode).

  * 3–10 entries (8 recommended); each entry requires `hex` and `ratio`
  * All `ratio` values must sum to exactly `100.00%`

  ```json theme={null}
  [
    { "hex": "#C2D1E6", "ratio": "23.51%" },
    { "hex": "#636574", "ratio": "76.49%" }
  ]
  ```
</ParamField>

## Response

<ResponseField name="code" type="string">
  Response status. Returns `"success"` on success.
</ResponseField>

<ResponseField name="data" type="array">
  <Expandable title="Array Elements">
    <ResponseField name="task_id" type="string">
      Unique task identifier used to query generation results.
    </ResponseField>

    <ResponseField name="status" type="string">
      Initial task status, always `processing` upon submission.
    </ResponseField>
  </Expandable>
</ResponseField>

## Examples

### Text-to-Image (minimal)

```json theme={null}
{
  "model": "wan2.7-image-pro",
  "prompt": "A flower shop with exquisite windows, beautiful wooden door, flowers on display"
}
```

### Text-to-Image (with resolution)

```json theme={null}
{
  "model": "wan2.7-image-pro",
  "prompt": "Summer beach, blue sky and white clouds, 4K ultra HD",
  "size": "4K",
  "thinking_mode": true
}
```

### Text-to-Image (custom color palette)

```json theme={null}
{
  "model": "wan2.7-image-pro",
  "prompt": "Minimalist modern living room",
  "size": "2K",
  "color_palette": [
    { "hex": "#C2D1E6", "ratio": "23.51%" },
    { "hex": "#CDD8E9", "ratio": "20.13%" },
    { "hex": "#B5C8DB", "ratio": "15.88%" },
    { "hex": "#C0B5B4", "ratio": "13.27%" },
    { "hex": "#DAE0EC", "ratio": "10.11%" },
    { "hex": "#636574", "ratio": "8.93%" },
    { "hex": "#CACAD2", "ratio": "5.55%" },
    { "hex": "#CBD4E4", "ratio": "2.62%" }
  ]
}
```

### Sequential Image Generation

```json theme={null}
{
  "model": "wan2.7-image-pro",
  "prompt": "Cinematic series: the same stray orange cat, consistent features. First: under cherry blossoms in spring. Second: old street shade in summer. Third: fallen leaves in autumn. Fourth: snow footprints in winter.",
  "enable_sequential": true,
  "n": 4,
  "size": "2K"
}
```

### Single Image Editing

```json theme={null}
{
  "model": "wan2.7-image",
  "prompt": "Replace the background with a sunset scene, warm color tones",
  "image_urls": ["https://example.com/portrait.jpg"],
  "size": "2K"
}
```

### Multi-Image Reference / Element Fusion

```json theme={null}
{
  "model": "wan2.7-image-pro",
  "prompt": "Apply the graffiti from image 2 onto the car in image 1",
  "image_urls": [
    "https://example.com/car.webp",
    "https://example.com/paint.webp"
  ],
  "size": "2K"
}
```

### Interactive Editing (Bounding Box)

`bbox_list` corresponds 1-to-1 with `image_urls`. Pass `[]` for images with no selection.

```json theme={null}
{
  "model": "wan2.7-image-pro",
  "prompt": "Place the alarm clock from image 1 into the selected area of image 2, blending naturally",
  "image_urls": [
    "https://example.com/clock.webp",
    "https://example.com/desk.webp"
  ],
  "bbox_list": [
    [],
    [[989, 515, 1138, 681]]
  ],
  "size": "2K"
}
```

<Note>
  **Querying Results**

  Image generation is asynchronous. Poll the [Task Status](/en/api-reference/tasks/status) endpoint using the returned `task_id` until `status == completed`.
</Note>
