curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"n": 1
}'
import requests
url = "https://api.apimart.ai/v1/images/generations"
payload = {
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"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/generations";
const payload = {
model: "gpt-image-1-official",
prompt: "An ancient castle under a starry sky",
size: "1:1",
quality: "auto",
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));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.apimart.ai/v1/images/generations"
payload := map[string]interface{}{
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"n": 1,
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.apimart.ai/v1/images/generations";
String payload = """
{
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"n": 1
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://api.apimart.ai/v1/images/generations";
$payload = [
"model" => "gpt-image-1-official",
"prompt" => "An ancient castle under a starry sky",
"size" => "1:1",
"quality" => "auto",
"n" => 1
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer <token>",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/v1/images/generations")
payload = {
model: "gpt-image-1-official",
prompt: "An ancient castle under a starry sky",
size: "1:1",
quality: "auto",
n: 1
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <token>"
request["Content-Type"] = "application/json"
request.body = payload.to_json
response = http.request(request)
puts response.body
import Foundation
let url = URL(string: "https://api.apimart.ai/v1/images/generations")!
let payload: [String: Any] = [
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"n": 1
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print("Error: \(error)")
return
}
if let data = data, let responseString = String(data: data, encoding: .utf8) {
print(responseString)
}
}
task.resume()
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var url = "https://api.apimart.ai/v1/images/generations";
var payload = @"{
""model"": ""gpt-image-1-official"",
""prompt"": ""An ancient castle under a starry sky"",
""size"": ""1:1"",
""quality"": ""auto"",
""n"": 1
}";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");
var content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
import 'dart:convert';
import 'package:http/http.dart' as http;
void main() async {
final url = Uri.parse('https://api.apimart.ai/v1/images/generations');
final payload = {
'model': 'gpt-image-1-official',
'prompt': 'An ancient castle under a starry sky',
'size': '1:1',
'quality': 'auto',
'n': 1,
};
final response = await http.post(
url,
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json',
},
body: jsonEncode(payload),
);
print(response.body);
}
library(httr)
library(jsonlite)
url <- "https://api.apimart.ai/v1/images/generations"
payload <- list(
model = "gpt-image-1-official",
prompt = "An ancient castle under a starry sky",
size = "1:1",
quality = "auto",
n = 1
)
response <- POST(
url,
add_headers(
Authorization = "Bearer <token>",
`Content-Type` = "application/json"
),
body = toJSON(payload, auto_unbox = TRUE),
encode = "raw"
)
cat(content(response, "text"))
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01KXXXXXXXXXXXXXXX"
}
]
}
{
"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"
}
}
GPT-Image(1/1.5)
Geração de imagens GPT-Image(1/1.5)
- Modo de processamento assíncrono, retorna ID da tarefa para consultas posteriores
- Suporta modos de geração a partir de texto, a partir de imagem e inpainting
- Suporta fundos transparentes, múltiplos formatos de saída e níveis de qualidade
- Gere até 4 imagens por requisição, com até 15 imagens de referência
POST
/
v1
/
images
/
generations
curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"n": 1
}'
import requests
url = "https://api.apimart.ai/v1/images/generations"
payload = {
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"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/generations";
const payload = {
model: "gpt-image-1-official",
prompt: "An ancient castle under a starry sky",
size: "1:1",
quality: "auto",
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));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.apimart.ai/v1/images/generations"
payload := map[string]interface{}{
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"n": 1,
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.apimart.ai/v1/images/generations";
String payload = """
{
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"n": 1
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://api.apimart.ai/v1/images/generations";
$payload = [
"model" => "gpt-image-1-official",
"prompt" => "An ancient castle under a starry sky",
"size" => "1:1",
"quality" => "auto",
"n" => 1
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer <token>",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/v1/images/generations")
payload = {
model: "gpt-image-1-official",
prompt: "An ancient castle under a starry sky",
size: "1:1",
quality: "auto",
n: 1
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <token>"
request["Content-Type"] = "application/json"
request.body = payload.to_json
response = http.request(request)
puts response.body
import Foundation
let url = URL(string: "https://api.apimart.ai/v1/images/generations")!
let payload: [String: Any] = [
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"n": 1
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print("Error: \(error)")
return
}
if let data = data, let responseString = String(data: data, encoding: .utf8) {
print(responseString)
}
}
task.resume()
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var url = "https://api.apimart.ai/v1/images/generations";
var payload = @"{
""model"": ""gpt-image-1-official"",
""prompt"": ""An ancient castle under a starry sky"",
""size"": ""1:1"",
""quality"": ""auto"",
""n"": 1
}";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");
var content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
import 'dart:convert';
import 'package:http/http.dart' as http;
void main() async {
final url = Uri.parse('https://api.apimart.ai/v1/images/generations');
final payload = {
'model': 'gpt-image-1-official',
'prompt': 'An ancient castle under a starry sky',
'size': '1:1',
'quality': 'auto',
'n': 1,
};
final response = await http.post(
url,
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json',
},
body: jsonEncode(payload),
);
print(response.body);
}
library(httr)
library(jsonlite)
url <- "https://api.apimart.ai/v1/images/generations"
payload <- list(
model = "gpt-image-1-official",
prompt = "An ancient castle under a starry sky",
size = "1:1",
quality = "auto",
n = 1
)
response <- POST(
url,
add_headers(
Authorization = "Bearer <token>",
`Content-Type` = "application/json"
),
body = toJSON(payload, auto_unbox = TRUE),
encode = "raw"
)
cat(content(response, "text"))
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01KXXXXXXXXXXXXXXX"
}
]
}
{
"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"
}
}
curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"n": 1
}'
import requests
url = "https://api.apimart.ai/v1/images/generations"
payload = {
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"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/generations";
const payload = {
model: "gpt-image-1-official",
prompt: "An ancient castle under a starry sky",
size: "1:1",
quality: "auto",
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));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.apimart.ai/v1/images/generations"
payload := map[string]interface{}{
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"n": 1,
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.apimart.ai/v1/images/generations";
String payload = """
{
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"n": 1
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://api.apimart.ai/v1/images/generations";
$payload = [
"model" => "gpt-image-1-official",
"prompt" => "An ancient castle under a starry sky",
"size" => "1:1",
"quality" => "auto",
"n" => 1
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer <token>",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/v1/images/generations")
payload = {
model: "gpt-image-1-official",
prompt: "An ancient castle under a starry sky",
size: "1:1",
quality: "auto",
n: 1
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <token>"
request["Content-Type"] = "application/json"
request.body = payload.to_json
response = http.request(request)
puts response.body
import Foundation
let url = URL(string: "https://api.apimart.ai/v1/images/generations")!
let payload: [String: Any] = [
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky",
"size": "1:1",
"quality": "auto",
"n": 1
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print("Error: \(error)")
return
}
if let data = data, let responseString = String(data: data, encoding: .utf8) {
print(responseString)
}
}
task.resume()
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var url = "https://api.apimart.ai/v1/images/generations";
var payload = @"{
""model"": ""gpt-image-1-official"",
""prompt"": ""An ancient castle under a starry sky"",
""size"": ""1:1"",
""quality"": ""auto"",
""n"": 1
}";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");
var content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
import 'dart:convert';
import 'package:http/http.dart' as http;
void main() async {
final url = Uri.parse('https://api.apimart.ai/v1/images/generations');
final payload = {
'model': 'gpt-image-1-official',
'prompt': 'An ancient castle under a starry sky',
'size': '1:1',
'quality': 'auto',
'n': 1,
};
final response = await http.post(
url,
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json',
},
body: jsonEncode(payload),
);
print(response.body);
}
library(httr)
library(jsonlite)
url <- "https://api.apimart.ai/v1/images/generations"
payload <- list(
model = "gpt-image-1-official",
prompt = "An ancient castle under a starry sky",
size = "1:1",
quality = "auto",
n = 1
)
response <- POST(
url,
add_headers(
Authorization = "Bearer <token>",
`Content-Type` = "application/json"
),
body = toJSON(payload, auto_unbox = TRUE),
encode = "raw"
)
cat(content(response, "text"))
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01KXXXXXXXXXXXXXXX"
}
]
}
{
"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"
}
}
Modelos suportados
| Modelo | Descrição | Modos | Geração a partir de imagem | Máx. de imagens | Cobrança |
|---|---|---|---|---|---|
gpt-image-1-official | Estabilidade prioritária, adequado para geração de imagens em geral | Texto para imagem / Imagem para imagem | Suportado | 4 | Size x Quality |
gpt-image-1.5-official | Nova versão, adequada para maior qualidade e edição complexa | Texto para imagem / Imagem para imagem | Suportado | 4 | Size x Quality |
Autorizações
Todas as requisições à API requerem 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 o seguinte aos cabeçalhos da sua requisição:
Authorization: Bearer YOUR_API_KEY
Body
Nome do modelo
gpt-image-1-official- Estabilidade prioritária, adequado para geração de imagens em geralgpt-image-1.5-official- Nova versão, adequada para maior qualidade e edição complexa
Descrição textual para geração da imagem, suporta tanto chinês quanto inglês
Proporção da imagemProporções suportadas:
1:1- Quadrado (padrão)3:2- Paisagem2:3- Retrato
Número de imagens a serem geradasIntervalo: 1-4
- Valores ≤ 0 serão tratados como
1 - Valores > 4 serão tratados como
4
1), não use aspas, caso contrário ocorrerá um erroQualidade da imagem
auto- Seleção automática de qualidade (padrão)low- Mais rápido, mais econômicomedium- Equilíbrio entre qualidade e custohigh- Qualidade mais alta, custo mais alto
Modo de fundo
auto- Fundo automático (padrão)opaque- Fundo opacotransparent- Fundo transparente, recomendado com o formato de saídapng
background: transparent não pode ser usado simultaneamente com output_format: jpegNível de moderação
auto- Nível de moderação padrãolow- Moderação mais permissiva
Formato de saída
png- Formato padrão, adequado para fundos transparentesjpeg- Tamanho de arquivo menor, adequado para saída de imagens em geral
background: transparent não pode ser usado simultaneamente com output_format: jpegNível de compressão de saída, intervalo 0-100
- Recomendado apenas para
jpeg - Não recomendado para
png
Array de URLs de imagens de referência, ativa o modo imagem para imagem quando fornecido
Limite: Até 15 imagens de referência
Mostrar Detalhes
Mostrar Detalhes
- 1 imagem para edição com referência única
- 2-15 imagens para fusão com múltiplas referências
- Mais de 15 imagens serão rejeitadas
- Devem ser URLs de imagens publicamente acessíveis e estáveis
URL da imagem de máscara para inpainting
- Deve ser usado em conjunto com
image_urls - Será submetida via a API oficial de edição
- Antes de fazer o upload da imagem de máscara, confirme que o canal Alpha da imagem está como “Sim”.
- O tamanho da imagem de máscara deve coincidir com a primeira imagem de referência.
Referência de tamanhos
As proporções são usadas externamente; o sistema as mapeia automaticamente para as dimensões oficiais internamente.| Proporção | Tamanho real | Descrição |
|---|---|---|
1:1 | 1024x1024 | Quadrado |
2:3 | 1024x1536 | Retrato |
3:2 | 1536x1024 | Paisagem |
Exemplos de uso
Texto para imagem (mínimo){
"model": "gpt-image-1-official",
"prompt": "An ancient castle under a starry sky"
}
{
"model": "gpt-image-1-official",
"prompt": "A flat icon of a glass bottle with no background",
"size": "2:3",
"quality": "high",
"background": "transparent",
"moderation": "low",
"output_format": "png",
"n": 1
}
{
"model": "gpt-image-1.5-official",
"prompt": "Convert the reference image to illustration style, preserving the main outline",
"size": "1:1",
"quality": "auto",
"image_urls": [
"https://your-cdn.com/input.png"
],
"n": 1
}
{
"model": "gpt-image-1.5-official",
"prompt": "Merge two reference images into an illustration poster, preserving the main outlines",
"size": "1:1",
"quality": "auto",
"background": "transparent",
"image_urls": [
"https://your-cdn.com/input-a.png",
"https://your-cdn.com/input-b.png"
],
"moderation": "low",
"output_format": "png",
"n": 1
}
{
"model": "gpt-image-1-official",
"prompt": "Four minimalist poster variations of a red fox",
"size": "1:1",
"quality": "low",
"output_format": "png",
"n": 4
}
Response
Código de status da resposta
Observações
- Processamento assíncrono: Após o envio, um
task_idé retornado. Faça polling em/v1/tasks/{task_id}para obter os resultados - Escolha do modelo: Use
gpt-image-1-officialpara geração de imagens em geral; usegpt-image-1.5-officialpara edição de alta qualidade e tarefas complexas de imagem para imagem - Requisitos da URL da imagem: Para imagem para imagem, use URLs de imagens publicamente acessíveis e estáveis
- Cobrança: Cobrado por imagem gerada com sucesso; sem cobrança em caso de falha
⌘I