Image generation
Create image generation tasks
Creates asynchronous image generation tasks from a prompt and optional image references.
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": "openai/gpt-image-2",
"prompt": "A ceramic teapot on a white studio background",
"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": "A ceramic teapot on a white studio background",
"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": "A ceramic teapot on a white studio background",
"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": "A ceramic teapot on a white studio background",
"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": "A ceramic teapot on a white studio background",
"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: "A ceramic teapot on a white studio background",
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: "A ceramic teapot on a white studio background",
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\": \"A ceramic teapot on a white studio background\",\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":"A ceramic teapot on a white studio background","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: "A ceramic teapot on a white studio background",
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" => "A ceramic teapot on a white studio background",
"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\":\"A ceramic teapot on a white studio background\",\"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": "rate_limit_exceeded",
"message": "Too many requests. Retry after the indicated interval."
}
}
{
"error": {
"code": "internal_error",
"message": "An internal error occurred"
}
}
Authorizations
string
default:"Bearer ${YOUR_API_KEY}"
required
Neural4D API key using the Bearer scheme.
Body application/json
- Option 1
- Option 2
- Option 3
- Option 4
enum<string>
required
GPT Image 2 model identifier.Available option:
openai/gpt-image-2.string
required
Text instruction describing the image to generate or edit.Required string length:
1 - 500.object[]
Optional reference images uploaded through
POST /openapi/v1/files. Only image references are supported. Supported formats are JPG, JPEG, PNG, and WEBP.Allowed array length: 0 - 6 elements.integer
default:1
Number of image generation tasks to create.Required range:
1 <= x <= 4.enum<string>
default:"2K"
Named output resolution.Available options:
1K, 2K, 4K.enum<string>
default:"1:1"
Target image width-to-height ratio.Available options:
1:1, 16:9, 9:16, 4:3, 3:4.enum<string>
required
Nano Banana Pro model identifier.Available option:
google/nano-banana-pro.string
required
Text instruction describing the image to generate or edit.Required string length:
1 - 500.object[]
Optional reference images uploaded through
POST /openapi/v1/files. Only image references are supported. Supported formats are JPG, JPEG, PNG, and WEBP.Allowed array length: 0 - 6 elements.integer
default:1
Number of image generation tasks to create.Required range:
1 <= x <= 4.enum<string>
default:"2K"
Named output resolution.Available options:
1K, 2K, 4K.enum<string>
default:"1:1"
Target image width-to-height ratio.Available options:
1:1, 16:9, 9:16, 4:3, 3:4.enum<string>
required
Seedream 4.5 model identifier.Available option:
bytedance/seedream-4.5.string
required
Text instruction describing the image to generate or edit.Required string length:
1 - 500.object[]
Optional reference images uploaded through
POST /openapi/v1/files. Only image references are supported. Supported formats are JPG, JPEG, PNG, and WEBP.Allowed array length: 0 - 6 elements.integer
default:1
Number of image generation tasks to create.Required range:
1 <= x <= 4.enum<string>
default:"2K"
Named output resolution.Available options:
2K, 4K.enum<string>
default:"1:1"
Target image width-to-height ratio.Available options:
1:1, 16:9, 9:16, 4:3, 3:4.enum<string>
required
Flux 2 Pro model identifier.Available option:
black-forest-labs/flux-2-pro.string
required
Text instruction describing the image to generate or edit.Required string length:
1 - 500.object[]
Optional reference images uploaded through
POST /openapi/v1/files. Only image references are supported. Supported formats are JPG, JPEG, PNG, and WEBP.Allowed array length: 0 - 6 elements.integer
default:1
Number of image generation tasks to create.Required range:
1 <= x <= 4.enum<string>
default:"2K"
Named output resolution.Available options:
1K, 2K.enum<string>
default:"1:1"
Target image width-to-height ratio.Available options:
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": "openai/gpt-image-2",
"prompt": "A ceramic teapot on a white studio background",
"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": "A ceramic teapot on a white studio background",
"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": "A ceramic teapot on a white studio background",
"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": "A ceramic teapot on a white studio background",
"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": "A ceramic teapot on a white studio background",
"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: "A ceramic teapot on a white studio background",
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: "A ceramic teapot on a white studio background",
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\": \"A ceramic teapot on a white studio background\",\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":"A ceramic teapot on a white studio background","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: "A ceramic teapot on a white studio background",
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" => "A ceramic teapot on a white studio background",
"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\":\"A ceramic teapot on a white studio background\",\"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());
Response
- 202
- 400
- 401
- 403
- 429
- 500
Generation tasks accepted
string
required
Batch task ID returned by the generation request.Example:
"normal-image-c50fe63e-699d-4d61-93f5-2099ab159d6d".object[]
required
Generated child items created by the request.Allowed array length: at least
1 element.Hide Child attributes
Hide Child attributes
Generated child item UUID.
Normalized task lifecycle status.Available options:
queued, processing, succeeded, failed.Unix timestamp in seconds.
Unix timestamp in seconds when the task was updated.
Credits charged for this task when available.
Show Child attributes
Show Child attributes
Credits charged for the task or submission.Required range:
0 <= x <= infinity.Example: 13.Failure details when asynchronous processing fails.
Show Child attributes
Show Child attributes
enum<string>
required
Current status shared by the submitted image tasks.Available options:
queued, processing, succeeded, failed.integer<int64>
required
Unix timestamp in seconds when the batch task was created.
enum<string>
required
Image generation mode shared by the submitted tasks.Available options:
text_to_image, image_to_image.enum<string>
required
Image generation model used by the submitted tasks.Available options:
openai/gpt-image-2, google/nano-banana-pro, bytedance/seedream-4.5, black-forest-labs/flux-2-pro.Invalid request
object
required
Structured error details.
Show Child attributes
Show Child attributes
Stable machine-readable error code.Example:
"invalid_prompt".Human-readable explanation of the error.Example:
"prompt is required and must be a non-empty string".Optional documentation URL with more information about the error.Example:
"https://api.neural4d.com/docs/errors#invalid_prompt".Authentication failed
object
required
Structured error details.
Show Child attributes
Show Child attributes
Stable machine-readable error code.Example:
"invalid_api_key".Human-readable explanation of the error.Example:
"The API key is invalid or expired".Optional documentation URL with more information about the error.Example:
"https://api.neural4d.com/docs/errors#invalid_api_key".The authenticated user cannot access this resource or has insufficient credits
object
required
Structured error details.
Show Child attributes
Show Child attributes
Stable machine-readable error code.Example:
"insufficient_credits".Human-readable explanation of the error.Example:
"Insufficient credits for image generation".Optional documentation URL with more information about the error.Example:
"https://api.neural4d.com/docs/errors#insufficient_credits".Request or quota limit exceeded
object
required
Structured error details.
Show Child attributes
Show Child attributes
Stable machine-readable error code.Example:
"rate_limit_exceeded".Human-readable explanation of the error.Example:
"Too many requests. Retry after the indicated interval.".Optional documentation URL with more information about the error.Example:
"https://api.neural4d.com/docs/errors#rate_limit_exceeded".Internal or upstream service error
object
required
Structured error details.
Show Child attributes
Show Child attributes
Stable machine-readable error code.Example:
"internal_error".Human-readable explanation of the error.Example:
"An internal error occurred".Optional documentation URL with more information about the error.Example:
"https://api.neural4d.com/docs/errors#internal_error".{
"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": "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": "openai/gpt-image-2",
"prompt": "A ceramic teapot on a white studio background",
"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": "A ceramic teapot on a white studio background",
"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": "A ceramic teapot on a white studio background",
"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": "A ceramic teapot on a white studio background",
"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": "A ceramic teapot on a white studio background",
"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: "A ceramic teapot on a white studio background",
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: "A ceramic teapot on a white studio background",
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\": \"A ceramic teapot on a white studio background\",\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":"A ceramic teapot on a white studio background","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: "A ceramic teapot on a white studio background",
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" => "A ceramic teapot on a white studio background",
"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\":\"A ceramic teapot on a white studio background\",\"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": "rate_limit_exceeded",
"message": "Too many requests. Retry after the indicated interval."
}
}
{
"error": {
"code": "internal_error",
"message": "An internal error occurred"
}
}

