Zum Hauptinhalt springen
POST
/
v1
/
images
/
edits
# model kann "grok-imagine-1.5-edit-apimart" sein, alternativ auch der 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"
  }
}
Hinweis zur Modellnamen-Kompatibilität: Diese Schnittstelle unterstützt auch den Alias grok-imagine-1.5-edit-ext, der grok-imagine-1.5-edit-apimart entspricht. Beide sind austauschbar und liefern identische Ergebnisse.
# model kann "grok-imagine-1.5-edit-apimart" sein, alternativ auch der 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"
  }
}

Autorisierung

Authorization
string
erforderlich
Alle APIs erfordern eine Bearer-Token-AuthentifizierungAPI-Key abrufen:Besuchen Sie die API-Key-Verwaltungsseite, um Ihren API-Key zu erhaltenFügen Sie ihn dem Request-Header hinzu:
Authorization: Bearer YOUR_API_KEY

Body

model
string
Standard:"grok-imagine-1.5-edit-apimart"
erforderlich
Name des BildbearbeitungsmodellsUnterstützte Modelle:
  • grok-imagine-1.5-edit-apimart – Grok-Bildbearbeitung (kompatibler Alias grok-imagine-1.5-edit-ext)
Beispiel: "grok-imagine-1.5-edit-apimart"
Zur Kompatibilität mit älteren Aufrufen kann der Alias grok-imagine-1.5-edit-ext (entspricht grok-imagine-1.5-edit-apimart) weiterhin verwendet werden.
prompt
string
erforderlich
Textbeschreibung für die Bildbearbeitung, unterstützt mehrere Sprachen
image_urls
string[]
erforderlich
Array von Quellbild-URLs. Das System verwendet das erste Bild im Array als Bearbeitungsreferenz.Unterstützt https://-Links oder das Format data:image/...;base64,....
n
integer
Standard:1
Anzahl der zu generierenden BilderBereich: 1–10 (Minimum 1, Maximum 10)

Response

code
integer
Antwort-Statuscode
data
array
Antwortdaten-Array

Anwendungsfälle

Fall 1: Hintergrundbearbeitung

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

Fall 2: Stilübertragung

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