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

# Grok Imagine 1.5 Image Editing

>  - Async processing mode, returns task ID for subsequent queries
- High-quality image editing based on reference images, supports multilingual prompts
- Generated image links are valid for 24 hours, please save them promptly 

<Info>
  **Model name compatibility note**: This endpoint also accepts the alias `grok-imagine-1.5-edit-ext`, which is equivalent to `grok-imagine-1.5-edit-gccai`. The two are interchangeable and produce identical results.
</Info>

<RequestExample>
  ```bash cURL theme={null}
  # model can be "grok-imagine-1.5-edit-gccai", or the compatible alias "grok-imagine-1.5-edit-ext"
  curl --request POST \
    --url https://gccai.heqingsong.uk/v1/images/edits \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "grok-imagine-1.5-edit-gccai",
      "prompt": "Change the background to a starry sky, keep the main subject",
      "image_urls": ["https://example.com/original.png"],
      "n": 1
    }'
  ```

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

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

  payload = {
      "model": "grok-imagine-1.5-edit-gccai",
      "prompt": "Change the background to a starry sky, keep the main subject",
      "image_urls": ["https://example.com/original.png"],
      "n": 1
  }

  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/edits";

  const payload = {
    model: "grok-imagine-1.5-edit-gccai",
    prompt: "Change the background to a starry sky, keep the main subject",
    image_urls: ["https://example.com/original.png"],
    n: 1
  };

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

  ```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 and try again",
      "type": "payment_required"
    }
  }
  ```

  ```json 403 theme={null}
  {
    "error": {
      "code": 403,
      "message": "Access forbidden, you do not have permission to access this resource",
      "type": "permission_error"
    }
  }
  ```

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

  ```json 502 theme={null}
  {
    "error": {
      "code": 502,
      "message": "Bad gateway, server temporarily unavailable",
      "type": "bad_gateway"
    }
  }
  ```
</ResponseExample>

## Authorizations

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

  Get API Key:

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

  Add it to the request header:

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

## Body

<ParamField body="model" type="string" default="grok-imagine-1.5-edit-gccai" required>
  Image editing model name

  Supported models:

  * `grok-imagine-1.5-edit-gccai` - Grok Image Editing (compatible alias `grok-imagine-1.5-edit-ext`)

  Example: `"grok-imagine-1.5-edit-gccai"`

  <Note>
    For backward compatibility, the alias `grok-imagine-1.5-edit-ext` (for `grok-imagine-1.5-edit-gccai`) remains usable.
  </Note>
</ParamField>

<ParamField body="prompt" type="string" required>
  Text description for image editing, supports multiple languages
</ParamField>

<ParamField body="image_urls" type="string[]" required>
  Array of source image URLs. The system will use the first image in the array as the editing reference.

  Supports `https://` links or `data:image/...;base64,...` format.
</ParamField>

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

  Range: 1-10 (minimum 1, maximum 10)
</ParamField>

## 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">
      Unique task identifier
    </ResponseField>
  </Expandable>
</ResponseField>

## Use Cases

### Case 1: Background Editing

```json theme={null}
{
  "model": "grok-imagine-1.5-edit-gccai",
  "prompt": "Change the background to a starry sky, keep the main subject",
  "image_urls": ["https://example.com/original.png"]
}
```

### Case 2: Style Transfer

```json theme={null}
{
  "model": "grok-imagine-1.5-edit-gccai",
  "prompt": "Convert the image to cyberpunk style",
  "image_urls": ["https://example.com/original.png"],
  "n": 2
}
```
