Passer au contenu principal
POST
/
v1
/
images
/
edits
# Le champ model peut valoir "grok-imagine-1.5-edit-apimart" ou son alias compatible "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"
  }
}
Alias de modèle compatible : cette API prend également en charge l’alias grok-imagine-1.5-edit-ext, équivalent à grok-imagine-1.5-edit-apimart ; les deux sont interchangeables et produisent des résultats identiques.
# Le champ model peut valoir "grok-imagine-1.5-edit-apimart" ou son alias compatible "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"
  }
}

Autorisations

Authorization
string
requis
Toutes les API nécessitent une authentification Bearer TokenObtenez votre clé API :Visitez la page de gestion des clés API pour obtenir votre clé APIAjoutez-la à l’en-tête de la requête :
Authorization: Bearer YOUR_API_KEY

Body

model
string
défaut:"grok-imagine-1.5-edit-apimart"
requis
Nom du modèle d’édition d’imagesModèles pris en charge :
  • grok-imagine-1.5-edit-apimart — édition d’images Grok (alias compatible grok-imagine-1.5-edit-ext)
Exemple : "grok-imagine-1.5-edit-apimart"
Pour assurer la compatibilité avec les anciens appels, l’alias grok-imagine-1.5-edit-ext (correspondant à grok-imagine-1.5-edit-apimart) reste utilisable normalement.
prompt
string
requis
Description textuelle pour l’édition d’image, prend en charge plusieurs langues
image_urls
string[]
requis
Tableau d’URL d’images sources. Le système utilisera la première image du tableau comme référence d’édition.Prend en charge les liens https:// ou le format data:image/...;base64,....
n
integer
défaut:1
Nombre d’images à générerPlage : 1–10 (minimum 1, maximum 10)

Response

code
integer
Code de statut de la réponse
data
array
Tableau de données de la réponse

Cas d’utilisation

Cas 1 : édition d’arrière-plan

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

Cas 2 : transfert de style

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