ImagemOpenAI
GPT Image 2
OpenAI’s GPT Image 2: image generation and editing at 1K, 2K or 4K, with up to sixteen reference images.
- ID do modelo
openai/gpt-image-2- Endpoint
POST /v1/tasks
Preço
| Aplica-se a | Minu | Preço oficial | vs. preço oficial |
|---|---|---|---|
| 1Kpor imagem | $0.03 | — | — |
| 2Kpor imagem | $0.05 | — | — |
| 4Kpor imagem | $0.08 | — | — |
O preço é reservado quando a tarefa é criada e cobrado apenas pelos resultados entregues. Uma tarefa que falha não custa nada.
Exemplo de requisição
Crie a tarefa e depois consulte-a até que ela chegue a um status final. Ou passe callback_url e receba um webhook assinado.
# Create the task
curl https://api.minu.ai/v1/tasks \
-H "Authorization: Bearer $MINU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-image-2",
"input": {
"prompt": "A paper boat on a rain puddle, macro, soft morning light",
"aspect_ratio": "auto",
"resolution": "1K"
}
}'
# Then poll it with the id from the response
curl https://api.minu.ai/v1/tasks/$TASK_ID \
-H "Authorization: Bearer $MINU_API_KEY"const headers = {
Authorization: `Bearer ${process.env.MINU_API_KEY}`,
'Content-Type': 'application/json',
};
// Create the task
let task = await fetch('https://api.minu.ai/v1/tasks', {
method: 'POST',
headers,
body: JSON.stringify({
model: 'openai/gpt-image-2',
input: {
prompt: 'A paper boat on a rain puddle, macro, soft morning light',
aspect_ratio: 'auto',
resolution: '1K',
},
}),
}).then((response) => response.json());
// Poll until it reaches a final state
const done = ['succeeded', 'partially_succeeded', 'failed', 'canceled', 'expired'];
while (!done.includes(task.status)) {
await new Promise((resolve) => setTimeout(resolve, 2000));
task = await fetch(`https://api.minu.ai/v1/tasks/${task.id}`, { headers }).then((response) => response.json());
}
console.log(task.status, task.outputs);import os
import time
import requests
headers = {"Authorization": f"Bearer {os.environ['MINU_API_KEY']}"}
# Create the task
task = requests.post(
"https://api.minu.ai/v1/tasks",
headers=headers,
json={
"model": "openai/gpt-image-2",
"input": {
"prompt": "A paper boat on a rain puddle, macro, soft morning light",
"aspect_ratio": "auto",
"resolution": "1K",
},
},
).json()
# Poll until it reaches a final state
done = {"succeeded", "partially_succeeded", "failed", "canceled", "expired"}
while task["status"] not in done:
time.sleep(2)
task = requests.get(f"https://api.minu.ai/v1/tasks/{task['id']}", headers=headers).json()
print(task["status"], task["outputs"])Parâmetros de entrada
Campos do objeto input de POST /v1/tasks.
| Parâmetro | Tipo | Padrão | Valores permitidos | Descrição |
|---|---|---|---|---|
promptobrigatório | string | — | Até 20.000 caracteres | What the image should show. |
image_urlsopcional | string[] | — | Até 16 itens; URL | Reference images: people, objects or styles the result should keep, or the image to edit. PNG, JPEG or WebP. |
aspect_ratioopcional | string | auto | Um de: auto, 1:1, 3:2, 2:3, 4:3, 3:4, 5:4, 4:5, 16:9, 9:16, 2:1, 1:2, 3:1, 1:3, 21:9, 9:21 | Shape of the result. With auto the model chooses, following the reference images when there are any. |
resolutionopcional | string | 1K | Um de: 1K, 2K, 4K | Size of the image. Each size has its own price. 5:4, 4:5, 3:1, 1:3, 9:21 cannot be made at 2K. 3:1, 1:3, 9:21 cannot be made at 4K. |
O que volta
Uma tarefa concluída, como GET /v1/tasks/{id} a retorna. Os valores são um exemplo.
{
"id": "task_1k8r2m4p0a7c9e3g5j6n8q2s",
"object": "task",
"model": "openai/gpt-image-2",
"status": "succeeded",
"input": {
"prompt": "A paper boat on a rain puddle, macro, soft morning light",
"aspect_ratio": "auto",
"resolution": "1K"
},
"outputs": [
{
"index": 0,
"type": "image",
"url": "https://…",
"mime": "image/png",
"bytes": 1482930
}
],
"error": null,
"estimated_cost_usd": "0.030000",
"cost_usd": "0.030000",
"metadata": null,
"created_at": 1796212800,
"started_at": 1796212801,
"completed_at": 1796212842
}