图片
创建图片生成任务
根据文本提示词和可选图片参考素材创建异步图片生成任务,参考素材支持文件 ID 或 HTTPS URL。
POST
/
openapi
/
v1
/
images
/
generations
curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "google/nano-banana-2-lite",
"prompt": "白色摄影棚背景上的陶瓷茶壶",
"n": 1,
"resolution": "1K",
"aspect_ratio": "1:1"
}'
curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "openai/gpt-image-2",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [
{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000"
}
],
"n": 1,
"resolution": "1K",
"aspect_ratio": "1:1"
}
'
curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "google/nano-banana-pro",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000"
}],
"n": 1,
"resolution": "2K",
"aspect_ratio": "16:9"
}'
curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "bytedance/seedream-4.5",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000"
}],
"n": 1,
"resolution": "2K",
"aspect_ratio": "1:1"
}'
curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "black-forest-labs/flux-2-pro",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000"
}],
"n": 1,
"resolution": "1K",
"aspect_ratio": "1:1"
}'
import requests
response = requests.post(
"https://api.neural4d.com/openapi/v1/images/generations",
headers={
"Authorization": "Bearer <token>",
"Content-Type": "application/json",
},
json={
"model": "openai/gpt-image-2",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [
{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000",
},
],
"n": 1,
"resolution": "1K",
"aspect_ratio": "1:1",
},
)
print(response.json())
const response = await fetch("https://api.neural4d.com/openapi/v1/images/generations", {
method: "POST",
headers: {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/gpt-image-2",
prompt: "白色摄影棚背景中的陶瓷茶壶",
input_references: [
{ type: "image", file_id: "550e8400-e29b-41d4-a716-446655440000" }
],
n: 1,
resolution: "1K",
aspect_ratio: "1:1",
})
});
const data = await response.json();
console.log(data);
const response: Response = await fetch("https://api.neural4d.com/openapi/v1/images/generations", {
method: "POST",
headers: {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/gpt-image-2",
prompt: "白色摄影棚背景中的陶瓷茶壶",
input_references: [{ type: "image", file_id: "550e8400-e29b-41d4-a716-446655440000" }],
n: 1,
resolution: "1K",
aspect_ratio: "1:1"
})
});
const data = await response.json();
console.log(data);
import java.net.URI;
import java.net.http.*;
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.neural4d.com/openapi/v1/images/generations"))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString("{\n \"model\": \"openai/gpt-image-2\",\n \"prompt\": \"白色摄影棚背景中的陶瓷茶壶\",\n \"input_references\": [{\"type\":\"image\",\"file_id\":\"550e8400-e29b-41d4-a716-446655440000\"}],\n \"n\": 1,\n \"resolution\": \"1K\",\n \"aspect_ratio\": \"1:1\"\n}"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
payload := strings.NewReader(`{"model":"openai/gpt-image-2","prompt":"白色摄影棚背景中的陶瓷茶壶","input_references":[{"type":"image","file_id":"550e8400-e29b-41d4-a716-446655440000"}],"n":1,"resolution":"1K","aspect_ratio":"1:1"}`)
req, _ := http.NewRequest("POST", "https://api.neural4d.com/openapi/v1/images/generations", payload)
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
bodyBytes, _ := io.ReadAll(resp.Body)
fmt.Println(string(bodyBytes))
require "net/http"
require "json"
uri = URI("https://api.neural4d.com/openapi/v1/images/generations")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer <token>"
request["Content-Type"] = "application/json"
request.body = {
model: "openai/gpt-image-2",
prompt: "白色摄影棚背景中的陶瓷茶壶",
input_references: [{ type: "image", file_id: "550e8400-e29b-41d4-a716-446655440000" }],
n: 1,
resolution: "1K",
aspect_ratio: "1:1"
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
puts response.body
<?php
$ch = curl_init("https://api.neural4d.com/openapi/v1/images/generations");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer <token>", "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode([
"model" => "openai/gpt-image-2",
"prompt" => "白色摄影棚背景中的陶瓷茶壶",
"input_references" => [[
"type" => "image",
"file_id" => "550e8400-e29b-41d4-a716-446655440000",
]],
"n" => 1,
"resolution" => "1K",
"aspect_ratio" => "1:1",
]),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
using System.Net.Http;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.neural4d.com/openapi/v1/images/generations");
request.Headers.TryAddWithoutValidation("Authorization", "Bearer <token>");
request.Content = new StringContent("{\"model\":\"openai/gpt-image-2\",\"prompt\":\"白色摄影棚背景中的陶瓷茶壶\",\"input_references\":[{\"type\":\"image\",\"file_id\":\"550e8400-e29b-41d4-a716-446655440000\"}],\"n\":1,\"resolution\":\"1K\",\"aspect_ratio\":\"1:1\"}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
{
"id": "normal-image-c50fe63e-699d-4d61-93f5-2099ab159d6d",
"status": "queued",
"created_at": 1784044800,
"mode": "image_to_image",
"model": "openai/gpt-image-2",
"data": [
{
"uuid": "c6f5dc4e-61ac-4694-9a8b-6a95f3ac4457",
"status": "queued",
"created_at": 1784044800
}
],
"usage": {
"credits": 13
}
}
{
"error": {
"code": "invalid_prompt",
"message": "prompt is required and must be a non-empty string"
}
}
{
"error": {
"code": "unsupported_model",
"message": "Unsupported modelKey: missing-model"
}
}
{
"error": {
"code": "model_unavailable",
"message": "Model is unavailable: openai/gpt-image-2"
}
}
{
"error": {
"code": "invalid_api_key",
"message": "The API key is invalid or expired"
}
}
{
"error": {
"code": "insufficient_credits",
"message": "Insufficient credits for image generation"
}
}
{
"error": {
"code": "reference_too_large",
"message": "Reference file must not exceed 10 MB"
}
}
{
"error": {
"code": "rate_limit_exceeded",
"message": "Too many requests. Retry after the indicated interval."
}
}
{
"error": {
"code": "internal_error",
"message": "An internal error occurred"
}
}
授权
string
默认值:"Bearer ${YOUR_API_KEY}"
必填
使用 Bearer 方式发送的 Neural4D API 密钥。
请求体 application/json
省略可选参数时使用所选模型的当前默认值。超出该模型支持范围的分辨率或宽高比会返回unsupported_resolution 或 unsupported_aspect_ratio。
每张参考图片最多 10 MiB,通过 file_id 或 url 传入时使用相同限制。
- gpt-image-2
- nano-banana-pro
- nano-banana-2-lite
- seedream-4.5
- flux-2-pro
enum<string>
必填
GPT Image 2 模型标识。可选值:
openai/gpt-image-2。string
必填
描述待生成或编辑图片的文本提示词。字符串长度:
1 - 500。object[]
可选参考图片。可将
POST /openapi/v1/files 返回的 id 填入 file_id,或通过 url 直接传入图片的公网 HTTPS 地址。仅支持 JPG、JPEG、PNG 和 WEBP 图片,每张最多 10 MiB。图片须通过内容审核。数组总长度:0 - 6 个元素。可混用文件 ID 和 URL,素材顺序保持不变。每个元素必须且只能提供 file_id、url 中的一个。integer
默认值:1
要创建的图片生成任务数量。取值范围:
1 <= x <= 4。enum<string>
默认值:"2K"
命名输出分辨率。可选值:
1K、2K、4K。enum<string>
默认值:"1:1"
目标图片宽高比。可选值:
1:1、16:9、9:16、4:3、3:4。enum<string>
必填
Nano Banana Pro 模型标识。可选值:
google/nano-banana-pro。string
必填
描述待生成或编辑图片的文本提示词。字符串长度:
1 - 500。object[]
可选参考图片。可将
POST /openapi/v1/files 返回的 id 填入 file_id,或通过 url 直接传入图片的公网 HTTPS 地址。仅支持 JPG、JPEG、PNG 和 WEBP 图片,每张最多 10 MiB。图片须通过内容审核。数组总长度:0 - 6 个元素。可混用文件 ID 和 URL,素材顺序保持不变。每个元素必须且只能提供 file_id、url 中的一个。integer
默认值:1
要创建的图片生成任务数量。取值范围:
1 <= x <= 4。enum<string>
默认值:"2K"
命名输出分辨率。可选值:
1K、2K、4K。enum<string>
默认值:"1:1"
目标图片宽高比。可选值:
1:1、16:9、9:16、4:3、3:4。enum<string>
必填
Nano Banana 2 Lite 模型标识。可选值:
google/nano-banana-2-lite。string
必填
描述待生成或编辑图片的文本提示词。字符串长度:
1 - 500。object[]
可选参考图片。可将
POST /openapi/v1/files 返回的 id 填入 file_id,或通过 url 直接传入图片的公网 HTTPS 地址。仅支持 JPG、JPEG、PNG 和 WEBP 图片,每张最多 10 MiB。图片须通过内容审核。数组总长度:0 - 6 个元素。可混用文件 ID 和 URL,素材顺序保持不变。每个元素必须且只能提供 file_id、url 中的一个。integer
默认值:1
要创建的图片生成任务数量。取值范围:
1 <= x <= 4。enum<string>
默认值:"1K"
命名输出分辨率。可选值:
1K。enum<string>
默认值:"1:1"
目标图片宽高比。可选值:
1:1、16:9、9:16、4:3、3:4。enum<string>
必填
Seedream 4.5 模型标识。可选值:
bytedance/seedream-4.5。string
必填
描述待生成或编辑图片的文本提示词。字符串长度:
1 - 500。object[]
可选参考图片。可将
POST /openapi/v1/files 返回的 id 填入 file_id,或通过 url 直接传入图片的公网 HTTPS 地址。仅支持 JPG、JPEG、PNG 和 WEBP 图片,每张最多 10 MiB。图片须通过内容审核。数组总长度:0 - 6 个元素。可混用文件 ID 和 URL,素材顺序保持不变。每个元素必须且只能提供 file_id、url 中的一个。integer
默认值:1
要创建的图片生成任务数量。取值范围:
1 <= x <= 4。enum<string>
默认值:"2K"
命名输出分辨率。可选值:
2K、4K。enum<string>
默认值:"1:1"
目标图片宽高比。可选值:
1:1、16:9、9:16、4:3、3:4。enum<string>
必填
Flux 2 Pro 模型标识。可选值:
black-forest-labs/flux-2-pro。string
必填
描述待生成或编辑图片的文本提示词。字符串长度:
1 - 500。object[]
可选参考图片。可将
POST /openapi/v1/files 返回的 id 填入 file_id,或通过 url 直接传入图片的公网 HTTPS 地址。仅支持 JPG、JPEG、PNG 和 WEBP 图片,每张最多 10 MiB。图片须通过内容审核。数组总长度:0 - 6 个元素。可混用文件 ID 和 URL,素材顺序保持不变。每个元素必须且只能提供 file_id、url 中的一个。integer
默认值:1
要创建的图片生成任务数量。取值范围:
1 <= x <= 4。enum<string>
默认值:"2K"
命名输出分辨率。可选值:
1K、2K。enum<string>
默认值:"1:1"
目标图片宽高比。可选值:
1:1、16:9、9:16、4:3、3:4。curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "google/nano-banana-2-lite",
"prompt": "白色摄影棚背景上的陶瓷茶壶",
"n": 1,
"resolution": "1K",
"aspect_ratio": "1:1"
}'
curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "openai/gpt-image-2",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [
{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000"
}
],
"n": 1,
"resolution": "1K",
"aspect_ratio": "1:1"
}
'
curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "google/nano-banana-pro",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000"
}],
"n": 1,
"resolution": "2K",
"aspect_ratio": "16:9"
}'
curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "bytedance/seedream-4.5",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000"
}],
"n": 1,
"resolution": "2K",
"aspect_ratio": "1:1"
}'
curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "black-forest-labs/flux-2-pro",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000"
}],
"n": 1,
"resolution": "1K",
"aspect_ratio": "1:1"
}'
import requests
response = requests.post(
"https://api.neural4d.com/openapi/v1/images/generations",
headers={
"Authorization": "Bearer <token>",
"Content-Type": "application/json",
},
json={
"model": "openai/gpt-image-2",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [
{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000",
},
],
"n": 1,
"resolution": "1K",
"aspect_ratio": "1:1",
},
)
print(response.json())
const response = await fetch("https://api.neural4d.com/openapi/v1/images/generations", {
method: "POST",
headers: {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/gpt-image-2",
prompt: "白色摄影棚背景中的陶瓷茶壶",
input_references: [
{ type: "image", file_id: "550e8400-e29b-41d4-a716-446655440000" }
],
n: 1,
resolution: "1K",
aspect_ratio: "1:1",
})
});
const data = await response.json();
console.log(data);
const response: Response = await fetch("https://api.neural4d.com/openapi/v1/images/generations", {
method: "POST",
headers: {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/gpt-image-2",
prompt: "白色摄影棚背景中的陶瓷茶壶",
input_references: [{ type: "image", file_id: "550e8400-e29b-41d4-a716-446655440000" }],
n: 1,
resolution: "1K",
aspect_ratio: "1:1"
})
});
const data = await response.json();
console.log(data);
import java.net.URI;
import java.net.http.*;
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.neural4d.com/openapi/v1/images/generations"))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString("{\n \"model\": \"openai/gpt-image-2\",\n \"prompt\": \"白色摄影棚背景中的陶瓷茶壶\",\n \"input_references\": [{\"type\":\"image\",\"file_id\":\"550e8400-e29b-41d4-a716-446655440000\"}],\n \"n\": 1,\n \"resolution\": \"1K\",\n \"aspect_ratio\": \"1:1\"\n}"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
payload := strings.NewReader(`{"model":"openai/gpt-image-2","prompt":"白色摄影棚背景中的陶瓷茶壶","input_references":[{"type":"image","file_id":"550e8400-e29b-41d4-a716-446655440000"}],"n":1,"resolution":"1K","aspect_ratio":"1:1"}`)
req, _ := http.NewRequest("POST", "https://api.neural4d.com/openapi/v1/images/generations", payload)
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
bodyBytes, _ := io.ReadAll(resp.Body)
fmt.Println(string(bodyBytes))
require "net/http"
require "json"
uri = URI("https://api.neural4d.com/openapi/v1/images/generations")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer <token>"
request["Content-Type"] = "application/json"
request.body = {
model: "openai/gpt-image-2",
prompt: "白色摄影棚背景中的陶瓷茶壶",
input_references: [{ type: "image", file_id: "550e8400-e29b-41d4-a716-446655440000" }],
n: 1,
resolution: "1K",
aspect_ratio: "1:1"
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
puts response.body
<?php
$ch = curl_init("https://api.neural4d.com/openapi/v1/images/generations");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer <token>", "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode([
"model" => "openai/gpt-image-2",
"prompt" => "白色摄影棚背景中的陶瓷茶壶",
"input_references" => [[
"type" => "image",
"file_id" => "550e8400-e29b-41d4-a716-446655440000",
]],
"n" => 1,
"resolution" => "1K",
"aspect_ratio" => "1:1",
]),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
using System.Net.Http;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.neural4d.com/openapi/v1/images/generations");
request.Headers.TryAddWithoutValidation("Authorization", "Bearer <token>");
request.Content = new StringContent("{\"model\":\"openai/gpt-image-2\",\"prompt\":\"白色摄影棚背景中的陶瓷茶壶\",\"input_references\":[{\"type\":\"image\",\"file_id\":\"550e8400-e29b-41d4-a716-446655440000\"}],\"n\":1,\"resolution\":\"1K\",\"aspect_ratio\":\"1:1\"}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
响应
请通过error.code 区分错误原因,不要依赖错误消息文本。
- 202
- 400
- 401
- 403
- 408
- 413
- 415
- 422
- 429
- 500
- 503
已接受生成任务
string
必填
生成请求返回的批次任务 ID。示例:
"normal-image-c50fe63e-699d-4d61-93f5-2099ab159d6d"。object[]
必填
本次请求创建的生成结果子项。数组长度:至少
1 个元素。隐藏 子属性
隐藏 子属性
生成结果子项 UUID。
标准化后的任务生命周期状态。可选值:
queued、processing、succeeded、failed。Unix 时间戳,单位为秒。
任务更新时间的 Unix 时间戳,单位为秒。
可用时返回此任务扣除的点数。
显示 子属性
显示 子属性
该任务或请求扣除的点数。取值范围:
0 <= x <= infinity。示例:13。enum<string>
必填
本次提交的图片任务的当前状态。可选值:
queued、processing、succeeded、failed。integer<int64>
必填
批次任务创建时间的 Unix 时间戳,单位为秒。
enum<string>
必填
本次提交任务使用的图片生成模式。可选值:
text_to_image、image_to_image。enum<string>
必填
本次提交任务使用的图片生成模型。可选值:
openai/gpt-image-2、google/nano-banana-pro、bytedance/seedream-4.5、black-forest-labs/flux-2-pro、google/nano-banana-2-lite。请求无效
object
必填
结构化错误详情。
显示 子属性
显示 子属性
稳定且可供程序读取的错误码。示例:
"invalid_prompt"。URL 素材错误:invalid_reference_source:每个素材必须且只能提供file_id或url。invalid_reference_url:URL 格式或长度不符合要求。unsafe_reference_url:地址或重定向目标不符合安全要求,请使用符合上述要求的公网直链。file_rejected:图片未通过内容审核,请更换图片。
便于阅读的错误说明。示例:
"prompt is required and must be a non-empty string"。包含此错误更多信息的可选文档 URL。示例:
"https://api.neural4d.com/docs/errors#invalid_prompt"。认证失败
当前已认证用户无权访问该资源或点数不足
素材下载超时
素材文件过大
素材文件无效或格式不支持
素材下载失败
已超过请求或配额限制
object
必填
结构化错误详情。
显示 子属性
显示 子属性
稳定且可供程序读取的错误码。示例:
"rate_limit_exceeded"。URL 素材错误:reference_import_busy:素材导入繁忙,请按响应头Retry-After指定的间隔重试。
便于阅读的错误说明。示例:
"Too many requests. Retry after the indicated interval."。包含此错误更多信息的可选文档 URL。示例:
"https://api.neural4d.com/docs/errors#rate_limit_exceeded"。内部或上游服务错误当
error.details.submission_accepted 为 true 时,任务已经入队,但后续处理失败。
error.details.task 保留任务 ID、UUID 和已知积分,retryable 为 false。不要重新提交生成请求,以免重复扣费。
登记成功时,你可以按任务 ID 查询。如果 error.details.registration_failed 为 true,错误码为 task_registration_failed;登记修复前,查询可能返回 404。
当 error.details.submission_uncertain 为 true 时,响应保留本次尝试的任务 ID;先确认原提交结果,再决定是否重新提交。最终扣费未知时不返回积分用量。{
"id": "normal-image-c50fe63e-699d-4d61-93f5-2099ab159d6d",
"status": "queued",
"created_at": 1784044800,
"mode": "image_to_image",
"model": "openai/gpt-image-2",
"data": [
{
"uuid": "c6f5dc4e-61ac-4694-9a8b-6a95f3ac4457",
"status": "queued",
"created_at": 1784044800
}
],
"usage": {
"credits": 13
}
}
{
"error": {
"code": "invalid_prompt",
"message": "prompt is required and must be a non-empty string"
}
}
{
"error": {
"code": "unsupported_model",
"message": "Unsupported modelKey: missing-model"
}
}
{
"error": {
"code": "model_unavailable",
"message": "Model is unavailable: openai/gpt-image-2"
}
}
{
"error": {
"code": "invalid_api_key",
"message": "The API key is invalid or expired"
}
}
{
"error": {
"code": "insufficient_credits",
"message": "Insufficient credits for image generation"
}
}
{
"error": {
"code": "reference_too_large",
"message": "Reference file must not exceed 10 MB"
}
}
{
"error": {
"code": "rate_limit_exceeded",
"message": "Too many requests. Retry after the indicated interval."
}
}
{
"error": {
"code": "internal_error",
"message": "An internal error occurred"
}
}
⌘I
curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "google/nano-banana-2-lite",
"prompt": "白色摄影棚背景上的陶瓷茶壶",
"n": 1,
"resolution": "1K",
"aspect_ratio": "1:1"
}'
curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "openai/gpt-image-2",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [
{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000"
}
],
"n": 1,
"resolution": "1K",
"aspect_ratio": "1:1"
}
'
curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "google/nano-banana-pro",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000"
}],
"n": 1,
"resolution": "2K",
"aspect_ratio": "16:9"
}'
curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "bytedance/seedream-4.5",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000"
}],
"n": 1,
"resolution": "2K",
"aspect_ratio": "1:1"
}'
curl --request POST \
--url https://api.neural4d.com/openapi/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "black-forest-labs/flux-2-pro",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000"
}],
"n": 1,
"resolution": "1K",
"aspect_ratio": "1:1"
}'
import requests
response = requests.post(
"https://api.neural4d.com/openapi/v1/images/generations",
headers={
"Authorization": "Bearer <token>",
"Content-Type": "application/json",
},
json={
"model": "openai/gpt-image-2",
"prompt": "白色摄影棚背景中的陶瓷茶壶",
"input_references": [
{
"type": "image",
"file_id": "550e8400-e29b-41d4-a716-446655440000",
},
],
"n": 1,
"resolution": "1K",
"aspect_ratio": "1:1",
},
)
print(response.json())
const response = await fetch("https://api.neural4d.com/openapi/v1/images/generations", {
method: "POST",
headers: {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/gpt-image-2",
prompt: "白色摄影棚背景中的陶瓷茶壶",
input_references: [
{ type: "image", file_id: "550e8400-e29b-41d4-a716-446655440000" }
],
n: 1,
resolution: "1K",
aspect_ratio: "1:1",
})
});
const data = await response.json();
console.log(data);
const response: Response = await fetch("https://api.neural4d.com/openapi/v1/images/generations", {
method: "POST",
headers: {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/gpt-image-2",
prompt: "白色摄影棚背景中的陶瓷茶壶",
input_references: [{ type: "image", file_id: "550e8400-e29b-41d4-a716-446655440000" }],
n: 1,
resolution: "1K",
aspect_ratio: "1:1"
})
});
const data = await response.json();
console.log(data);
import java.net.URI;
import java.net.http.*;
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.neural4d.com/openapi/v1/images/generations"))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString("{\n \"model\": \"openai/gpt-image-2\",\n \"prompt\": \"白色摄影棚背景中的陶瓷茶壶\",\n \"input_references\": [{\"type\":\"image\",\"file_id\":\"550e8400-e29b-41d4-a716-446655440000\"}],\n \"n\": 1,\n \"resolution\": \"1K\",\n \"aspect_ratio\": \"1:1\"\n}"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
payload := strings.NewReader(`{"model":"openai/gpt-image-2","prompt":"白色摄影棚背景中的陶瓷茶壶","input_references":[{"type":"image","file_id":"550e8400-e29b-41d4-a716-446655440000"}],"n":1,"resolution":"1K","aspect_ratio":"1:1"}`)
req, _ := http.NewRequest("POST", "https://api.neural4d.com/openapi/v1/images/generations", payload)
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
bodyBytes, _ := io.ReadAll(resp.Body)
fmt.Println(string(bodyBytes))
require "net/http"
require "json"
uri = URI("https://api.neural4d.com/openapi/v1/images/generations")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer <token>"
request["Content-Type"] = "application/json"
request.body = {
model: "openai/gpt-image-2",
prompt: "白色摄影棚背景中的陶瓷茶壶",
input_references: [{ type: "image", file_id: "550e8400-e29b-41d4-a716-446655440000" }],
n: 1,
resolution: "1K",
aspect_ratio: "1:1"
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
puts response.body
<?php
$ch = curl_init("https://api.neural4d.com/openapi/v1/images/generations");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer <token>", "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode([
"model" => "openai/gpt-image-2",
"prompt" => "白色摄影棚背景中的陶瓷茶壶",
"input_references" => [[
"type" => "image",
"file_id" => "550e8400-e29b-41d4-a716-446655440000",
]],
"n" => 1,
"resolution" => "1K",
"aspect_ratio" => "1:1",
]),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
using System.Net.Http;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.neural4d.com/openapi/v1/images/generations");
request.Headers.TryAddWithoutValidation("Authorization", "Bearer <token>");
request.Content = new StringContent("{\"model\":\"openai/gpt-image-2\",\"prompt\":\"白色摄影棚背景中的陶瓷茶壶\",\"input_references\":[{\"type\":\"image\",\"file_id\":\"550e8400-e29b-41d4-a716-446655440000\"}],\"n\":1,\"resolution\":\"1K\",\"aspect_ratio\":\"1:1\"}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
{
"id": "normal-image-c50fe63e-699d-4d61-93f5-2099ab159d6d",
"status": "queued",
"created_at": 1784044800,
"mode": "image_to_image",
"model": "openai/gpt-image-2",
"data": [
{
"uuid": "c6f5dc4e-61ac-4694-9a8b-6a95f3ac4457",
"status": "queued",
"created_at": 1784044800
}
],
"usage": {
"credits": 13
}
}
{
"error": {
"code": "invalid_prompt",
"message": "prompt is required and must be a non-empty string"
}
}
{
"error": {
"code": "unsupported_model",
"message": "Unsupported modelKey: missing-model"
}
}
{
"error": {
"code": "model_unavailable",
"message": "Model is unavailable: openai/gpt-image-2"
}
}
{
"error": {
"code": "invalid_api_key",
"message": "The API key is invalid or expired"
}
}
{
"error": {
"code": "insufficient_credits",
"message": "Insufficient credits for image generation"
}
}
{
"error": {
"code": "reference_too_large",
"message": "Reference file must not exceed 10 MB"
}
}
{
"error": {
"code": "rate_limit_exceeded",
"message": "Too many requests. Retry after the indicated interval."
}
}
{
"error": {
"code": "internal_error",
"message": "An internal error occurred"
}
}