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

# Grok Imagine 1.0 圖像編輯

> 使用 grok-imagine-1.0-edit 基於參考圖進行異步圖像編輯

* 統一圖像編輯接口
* 異步任務模式，返回任務 ID
* 通過 `model` 指定爲 `grok-imagine-1.0-edit`

## Authorizations

<ParamField header="Authorization" type="string" required>
  所有接口均使用 Bearer Token 認證

  獲取 API Key：訪問 [API Key 管理頁面](https://toapis.com/console/token)

  請求頭示例：

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

## Body

<ParamField body="model" type="string" required>
  模型名稱，固定使用：

  * `grok-imagine-1.0-edit`
</ParamField>

<ParamField body="prompt" type="string" required>
  圖像編輯提示詞，支持多語言
</ParamField>

<ParamField body="image_urls" type="string[]" required>
  待編輯的原圖 URL 數組，至少 1 張

  示例：

  * `["https://example.com/original.png"]`

  建議先使用 [圖片上傳接口](../../uploads/images) 上傳後再傳 URL
</ParamField>

<ParamField body="n" type="integer" default={1}>
  生成數量，建議範圍 1-10
</ParamField>

## Response

<ResponseField name="id" type="string">
  任務唯一 ID
</ResponseField>

<ResponseField name="object" type="string">
  固定爲 `generation.task`
</ResponseField>

<ResponseField name="status" type="string">
  任務狀態：`queued` / `in_progress` / `completed` / `failed`
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://toapis.com/v1/images/edits \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "grok-imagine-1.0-edit",
      "prompt": "把背景改成星空，主體保持不變",
      "image_urls": ["https://example.com/original.png"],
      "n": 1
    }'
  ```

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

  resp = requests.post(
      "https://toapis.com/v1/images/edits",
      headers={
          "Authorization": "Bearer your-ToAPIs-key",
          "Content-Type": "application/json",
      },
      json={
          "model": "grok-imagine-1.0-edit",
          "prompt": "把背景改成星空，主體保持不變",
          "image_urls": ["https://example.com/original.png"],
          "n": 1,
      },
  )

  print(resp.status_code)
  print(resp.json())
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch('https://toapis.com/v1/images/edits', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your-ToAPIs-key',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'grok-imagine-1.0-edit',
      prompt: '把背景改成星空，主體保持不變',
      image_urls: ['https://example.com/original.png'],
      n: 1,
    }),
  });

  console.log(resp.status);
  console.log(await resp.json());
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "task_01JNXXXXXXXXXXXXXXXXXX",
    "object": "generation.task",
    "model": "grok-imagine-1.0-edit",
    "status": "queued",
    "progress": 0,
    "created_at": 1768380224,
    "metadata": {}
  }
  ```
</ResponseExample>
