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

# Grok Imagine 1.5 Pengeditan Gambar

>  - Mode pemrosesan asinkron, mengembalikan ID tugas untuk kueri berikutnya
- Pengeditan gambar berkualitas tinggi berdasarkan gambar referensi, mendukung prompt multibahasa
- Tautan gambar yang dihasilkan berlaku selama 24 jam; harap segera simpan 

<Info>
  **Catatan kompatibilitas nama model**: Antarmuka ini juga mendukung alias `grok-imagine-1.5-edit-ext`, yang setara dengan `grok-imagine-1.5-edit-apimart`; keduanya dapat digunakan secara bergantian dengan hasil yang sama.
</Info>

<RequestExample>
  ```bash cURL theme={null}
  # model dapat diisi "grok-imagine-1.5-edit-apimart", juga kompatibel dengan alias "grok-imagine-1.5-edit-ext"
  curl --request POST \
    --url https://api.apimart.ai/v1/images/edits \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "grok-imagine-1.5-edit-apimart",
      "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://api.apimart.ai/v1/images/edits"

  payload = {
      "model": "grok-imagine-1.5-edit-apimart",
      "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://api.apimart.ai/v1/images/edits";

  const payload = {
    model: "grok-imagine-1.5-edit-apimart",
    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>

## Otorisasi

<ParamField header="Authorization" type="string" required>
  Semua API memerlukan autentikasi Bearer Token

  Dapatkan API Key:

  Kunjungi [Halaman Manajemen API Key](https://apimart.ai/keys) untuk mendapatkan API Key Anda

  Tambahkan ke header permintaan:

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

## Body

<ParamField body="model" type="string" default="grok-imagine-1.5-edit-apimart" required>
  Nama model pengeditan gambar

  Model yang didukung:

  * `grok-imagine-1.5-edit-apimart` - Grok Pengeditan Gambar (alias kompatibel `grok-imagine-1.5-edit-ext`)

  Contoh: `"grok-imagine-1.5-edit-apimart"`

  <Note>
    Untuk kompatibilitas dengan pemanggilan versi lama, alias `grok-imagine-1.5-edit-ext` (sesuai dengan `grok-imagine-1.5-edit-apimart`) tetap dapat digunakan secara normal.
  </Note>
</ParamField>

<ParamField body="prompt" type="string" required>
  Deskripsi teks untuk pengeditan gambar, mendukung beberapa bahasa
</ParamField>

<ParamField body="image_urls" type="string[]" required>
  Array URL gambar sumber. Sistem akan menggunakan gambar pertama dalam array sebagai referensi pengeditan.

  Mendukung tautan `https://` atau format `data:image/...;base64,...`.
</ParamField>

<ParamField body="n" type="integer" default={1}>
  Jumlah gambar yang akan dibuat

  Rentang: 1-10 (minimum 1, maksimum 10)
</ParamField>

## Respons

<ResponseField name="code" type="integer">
  Kode status respons
</ResponseField>

<ResponseField name="data" type="array">
  Array data respons

  <Expandable title="Properti">
    <ResponseField name="status" type="string">
      Status tugas

      * `submitted` - Dikirim
    </ResponseField>

    <ResponseField name="task_id" type="string">
      Pengidentifikasi unik tugas
    </ResponseField>
  </Expandable>
</ResponseField>

## Kasus Penggunaan

### Kasus 1: Pengeditan Latar Belakang

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

### Kasus 2: Transfer Gaya

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