Langsung ke konten utama
POST
/
v1
/
images
/
edits
# 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
  }'
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())
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));
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01JNXXXXXXXXXXXXXXXXXX"
    }
  ]
}
{
  "error": {
    "code": 400,
    "message": "Invalid request parameters",
    "type": "invalid_request_error"
  }
}
{
  "error": {
    "code": 401,
    "message": "Authentication failed, please check your API key",
    "type": "authentication_error"
  }
}
{
  "error": {
    "code": 402,
    "message": "Insufficient balance, please top up and try again",
    "type": "payment_required"
  }
}
{
  "error": {
    "code": 403,
    "message": "Access forbidden, you do not have permission to access this resource",
    "type": "permission_error"
  }
}
{
  "error": {
    "code": 429,
    "message": "Too many requests, please try again later",
    "type": "rate_limit_error"
  }
}
{
  "error": {
    "code": 500,
    "message": "Internal server error, please try again later",
    "type": "server_error"
  }
}
{
  "error": {
    "code": 502,
    "message": "Bad gateway, server temporarily unavailable",
    "type": "bad_gateway"
  }
}
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.
# 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
  }'
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())
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));
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01JNXXXXXXXXXXXXXXXXXX"
    }
  ]
}
{
  "error": {
    "code": 400,
    "message": "Invalid request parameters",
    "type": "invalid_request_error"
  }
}
{
  "error": {
    "code": 401,
    "message": "Authentication failed, please check your API key",
    "type": "authentication_error"
  }
}
{
  "error": {
    "code": 402,
    "message": "Insufficient balance, please top up and try again",
    "type": "payment_required"
  }
}
{
  "error": {
    "code": 403,
    "message": "Access forbidden, you do not have permission to access this resource",
    "type": "permission_error"
  }
}
{
  "error": {
    "code": 429,
    "message": "Too many requests, please try again later",
    "type": "rate_limit_error"
  }
}
{
  "error": {
    "code": 500,
    "message": "Internal server error, please try again later",
    "type": "server_error"
  }
}
{
  "error": {
    "code": 502,
    "message": "Bad gateway, server temporarily unavailable",
    "type": "bad_gateway"
  }
}

Otorisasi

Authorization
string
wajib
Semua API memerlukan autentikasi Bearer TokenDapatkan API Key:Kunjungi Halaman Manajemen API Key untuk mendapatkan API Key AndaTambahkan ke header permintaan:
Authorization: Bearer YOUR_API_KEY

Body

model
string
default:"grok-imagine-1.5-edit-apimart"
wajib
Nama model pengeditan gambarModel 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"
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.
prompt
string
wajib
Deskripsi teks untuk pengeditan gambar, mendukung beberapa bahasa
image_urls
string[]
wajib
Array URL gambar sumber. Sistem akan menggunakan gambar pertama dalam array sebagai referensi pengeditan.Mendukung tautan https:// atau format data:image/...;base64,....
n
integer
default:1
Jumlah gambar yang akan dibuatRentang: 1-10 (minimum 1, maksimum 10)

Respons

code
integer
Kode status respons
data
array
Array data respons

Kasus Penggunaan

Kasus 1: Pengeditan Latar Belakang

{
  "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

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