Saltar para o conteúdo principal
POST
/
v1
/
images
/
edits
# model pode ser "grok-imagine-1.5-edit-apimart", também compatível com o 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"
  }
}
Aviso de compatibilidade de nome de modelo: esta interface também é compatível com o alias grok-imagine-1.5-edit-ext, que é equivalente a grok-imagine-1.5-edit-apimart; ambos podem ser usados de forma intercambiável e produzem o mesmo resultado.
# model pode ser "grok-imagine-1.5-edit-apimart", também compatível com o 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"
  }
}

Autorização

Authorization
string
obrigatório
Todas as APIs exigem autenticação por Bearer TokenObtenha sua chave de API:Acesse a página de gerenciamento de chaves de API para obter sua chave de APIAdicione-a ao cabeçalho da requisição:
Authorization: Bearer YOUR_API_KEY

Corpo da requisição

model
string
padrão:"grok-imagine-1.5-edit-apimart"
obrigatório
Nome do modelo de edição de imagensModelos suportados:
  • grok-imagine-1.5-edit-apimart - Edição de imagens Grok (alias compatível grok-imagine-1.5-edit-ext)
Exemplo: "grok-imagine-1.5-edit-apimart"
Para compatibilidade com chamadas de versões anteriores, o alias grok-imagine-1.5-edit-ext (correspondente a grok-imagine-1.5-edit-apimart) continua podendo ser usado normalmente.
prompt
string
obrigatório
Descrição textual para a edição da imagem, com suporte a múltiplos idiomas
image_urls
string[]
obrigatório
Array de URLs das imagens de origem. O sistema usará a primeira imagem do array como referência para a edição.Suporta links https:// ou formato data:image/...;base64,....
n
integer
padrão:1
Número de imagens a serem geradasIntervalo: 1–10 (mínimo 1, máximo 10)

Resposta

code
integer
Código de status da resposta
data
array
Array de dados da resposta

Casos de uso

Caso 1: Edição de fundo

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

Caso 2: Transferência de estilo

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