curl --request POST \
--url https://api.nano-gpt.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"model": "hidream",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json",
"user": "<string>",
"imageDataUrl": "data:image/jpeg;base64,/9j/4AAQ...",
"imageDataUrls": [
"data:image/jpeg;base64,/9j/4AAQ...",
"data:image/png;base64,iVBORw0KGgo..."
],
"maskDataUrl": "data:image/png;base64,iVBORw0KGgo...",
"strength": 0.8,
"guidance_scale": 7.5,
"num_inference_steps": 30,
"seed": 42,
"kontext_max_mode": false
}
'import requests
url = "https://api.nano-gpt.com/v1/images/generations"
payload = {
"prompt": "<string>",
"model": "hidream",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json",
"user": "<string>",
"imageDataUrl": "data:image/jpeg;base64,/9j/4AAQ...",
"imageDataUrls": ["data:image/jpeg;base64,/9j/4AAQ...", "data:image/png;base64,iVBORw0KGgo..."],
"maskDataUrl": "data:image/png;base64,iVBORw0KGgo...",
"strength": 0.8,
"guidance_scale": 7.5,
"num_inference_steps": 30,
"seed": 42,
"kontext_max_mode": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
model: 'hidream',
n: 1,
size: '1024x1024',
response_format: 'b64_json',
user: '<string>',
imageDataUrl: 'data:image/jpeg;base64,/9j/4AAQ...',
imageDataUrls: ['data:image/jpeg;base64,/9j/4AAQ...', 'data:image/png;base64,iVBORw0KGgo...'],
maskDataUrl: 'data:image/png;base64,iVBORw0KGgo...',
strength: 0.8,
guidance_scale: 7.5,
num_inference_steps: 30,
seed: 42,
kontext_max_mode: false
})
};
fetch('https://api.nano-gpt.com/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nano-gpt.com/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'model' => 'hidream',
'n' => 1,
'size' => '1024x1024',
'response_format' => 'b64_json',
'user' => '<string>',
'imageDataUrl' => 'data:image/jpeg;base64,/9j/4AAQ...',
'imageDataUrls' => [
'data:image/jpeg;base64,/9j/4AAQ...',
'data:image/png;base64,iVBORw0KGgo...'
],
'maskDataUrl' => 'data:image/png;base64,iVBORw0KGgo...',
'strength' => 0.8,
'guidance_scale' => 7.5,
'num_inference_steps' => 30,
'seed' => 42,
'kontext_max_mode' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.nano-gpt.com/v1/images/generations"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"hidream\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"b64_json\",\n \"user\": \"<string>\",\n \"imageDataUrl\": \"data:image/jpeg;base64,/9j/4AAQ...\",\n \"imageDataUrls\": [\n \"data:image/jpeg;base64,/9j/4AAQ...\",\n \"data:image/png;base64,iVBORw0KGgo...\"\n ],\n \"maskDataUrl\": \"data:image/png;base64,iVBORw0KGgo...\",\n \"strength\": 0.8,\n \"guidance_scale\": 7.5,\n \"num_inference_steps\": 30,\n \"seed\": 42,\n \"kontext_max_mode\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.nano-gpt.com/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"hidream\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"b64_json\",\n \"user\": \"<string>\",\n \"imageDataUrl\": \"data:image/jpeg;base64,/9j/4AAQ...\",\n \"imageDataUrls\": [\n \"data:image/jpeg;base64,/9j/4AAQ...\",\n \"data:image/png;base64,iVBORw0KGgo...\"\n ],\n \"maskDataUrl\": \"data:image/png;base64,iVBORw0KGgo...\",\n \"strength\": 0.8,\n \"guidance_scale\": 7.5,\n \"num_inference_steps\": 30,\n \"seed\": 42,\n \"kontext_max_mode\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.nano-gpt.com/v1/images/generations")
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 = "{\n \"prompt\": \"<string>\",\n \"model\": \"hidream\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"b64_json\",\n \"user\": \"<string>\",\n \"imageDataUrl\": \"data:image/jpeg;base64,/9j/4AAQ...\",\n \"imageDataUrls\": [\n \"data:image/jpeg;base64,/9j/4AAQ...\",\n \"data:image/png;base64,iVBORw0KGgo...\"\n ],\n \"maskDataUrl\": \"data:image/png;base64,iVBORw0KGgo...\",\n \"strength\": 0.8,\n \"guidance_scale\": 7.5,\n \"num_inference_steps\": 30,\n \"seed\": 42,\n \"kontext_max_mode\": false\n}"
response = http.request(request)
puts response.read_body{
"created": 123,
"data": [
{
"url": "https://...signed-url..."
}
],
"cost": 123,
"paymentSource": "<string>",
"remainingBalance": 123
}Image Generation (OpenAI-Compatible)
Creates an image generation for the provided prompt (OpenAI-compatible). For unauthenticated accountless x402 quote requests, include x-x402: true.
curl --request POST \
--url https://api.nano-gpt.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"model": "hidream",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json",
"user": "<string>",
"imageDataUrl": "data:image/jpeg;base64,/9j/4AAQ...",
"imageDataUrls": [
"data:image/jpeg;base64,/9j/4AAQ...",
"data:image/png;base64,iVBORw0KGgo..."
],
"maskDataUrl": "data:image/png;base64,iVBORw0KGgo...",
"strength": 0.8,
"guidance_scale": 7.5,
"num_inference_steps": 30,
"seed": 42,
"kontext_max_mode": false
}
'import requests
url = "https://api.nano-gpt.com/v1/images/generations"
payload = {
"prompt": "<string>",
"model": "hidream",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json",
"user": "<string>",
"imageDataUrl": "data:image/jpeg;base64,/9j/4AAQ...",
"imageDataUrls": ["data:image/jpeg;base64,/9j/4AAQ...", "data:image/png;base64,iVBORw0KGgo..."],
"maskDataUrl": "data:image/png;base64,iVBORw0KGgo...",
"strength": 0.8,
"guidance_scale": 7.5,
"num_inference_steps": 30,
"seed": 42,
"kontext_max_mode": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
model: 'hidream',
n: 1,
size: '1024x1024',
response_format: 'b64_json',
user: '<string>',
imageDataUrl: 'data:image/jpeg;base64,/9j/4AAQ...',
imageDataUrls: ['data:image/jpeg;base64,/9j/4AAQ...', 'data:image/png;base64,iVBORw0KGgo...'],
maskDataUrl: 'data:image/png;base64,iVBORw0KGgo...',
strength: 0.8,
guidance_scale: 7.5,
num_inference_steps: 30,
seed: 42,
kontext_max_mode: false
})
};
fetch('https://api.nano-gpt.com/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nano-gpt.com/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'model' => 'hidream',
'n' => 1,
'size' => '1024x1024',
'response_format' => 'b64_json',
'user' => '<string>',
'imageDataUrl' => 'data:image/jpeg;base64,/9j/4AAQ...',
'imageDataUrls' => [
'data:image/jpeg;base64,/9j/4AAQ...',
'data:image/png;base64,iVBORw0KGgo...'
],
'maskDataUrl' => 'data:image/png;base64,iVBORw0KGgo...',
'strength' => 0.8,
'guidance_scale' => 7.5,
'num_inference_steps' => 30,
'seed' => 42,
'kontext_max_mode' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.nano-gpt.com/v1/images/generations"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"hidream\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"b64_json\",\n \"user\": \"<string>\",\n \"imageDataUrl\": \"data:image/jpeg;base64,/9j/4AAQ...\",\n \"imageDataUrls\": [\n \"data:image/jpeg;base64,/9j/4AAQ...\",\n \"data:image/png;base64,iVBORw0KGgo...\"\n ],\n \"maskDataUrl\": \"data:image/png;base64,iVBORw0KGgo...\",\n \"strength\": 0.8,\n \"guidance_scale\": 7.5,\n \"num_inference_steps\": 30,\n \"seed\": 42,\n \"kontext_max_mode\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.nano-gpt.com/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"hidream\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"b64_json\",\n \"user\": \"<string>\",\n \"imageDataUrl\": \"data:image/jpeg;base64,/9j/4AAQ...\",\n \"imageDataUrls\": [\n \"data:image/jpeg;base64,/9j/4AAQ...\",\n \"data:image/png;base64,iVBORw0KGgo...\"\n ],\n \"maskDataUrl\": \"data:image/png;base64,iVBORw0KGgo...\",\n \"strength\": 0.8,\n \"guidance_scale\": 7.5,\n \"num_inference_steps\": 30,\n \"seed\": 42,\n \"kontext_max_mode\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.nano-gpt.com/v1/images/generations")
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 = "{\n \"prompt\": \"<string>\",\n \"model\": \"hidream\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"b64_json\",\n \"user\": \"<string>\",\n \"imageDataUrl\": \"data:image/jpeg;base64,/9j/4AAQ...\",\n \"imageDataUrls\": [\n \"data:image/jpeg;base64,/9j/4AAQ...\",\n \"data:image/png;base64,iVBORw0KGgo...\"\n ],\n \"maskDataUrl\": \"data:image/png;base64,iVBORw0KGgo...\",\n \"strength\": 0.8,\n \"guidance_scale\": 7.5,\n \"num_inference_steps\": 30,\n \"seed\": 42,\n \"kontext_max_mode\": false\n}"
response = http.request(request)
puts response.read_body{
"created": 123,
"data": [
{
"url": "https://...signed-url..."
}
],
"cost": 123,
"paymentSource": "<string>",
"remainingBalance": 123
}Overview
Generate images from text prompts or base64 image inputs using the OpenAI-compatible endpoint. Responses include base64 bytes (b64_json) by default or signed URLs (url) when response_format: "url".
POST /api/v1/images.
Endpoint
- Method/Path:
POST https://api.nano-gpt.com/v1/images/generations - Auth:
Authorization: Bearer <API_KEY> - Required header:
Content-Type: application/json
Request Body (JSON)
Core fields:prompt(string, required): Text prompt to generate an image from.model(string, optional): Model ID. Set it explicitly to select the intended model; useGET /api/v1/image-modelsto discover available IDs.n(integer, optional): Number of images to generate (default1).size(string, optional): Requested output size or model-specific resolution value. UseGET /api/v1/image-models?detailed=trueand readsupported_parameters.resolutionsfor the selected model’s supported values.response_format(string, optional):b64_json(default) orurl.user(string, optional): End-user identifier.
imageDataUrl(string, optional): Base64 data URL for a single input image.imageDataUrls(array, optional): Multiple base64 data URLs for supported models.maskDataUrl(string, optional): Base64 mask data URL for inpainting.
strength,guidance_scale,num_inference_steps,kontext_max_mode.seedis an optional model-specific hint that may improve reproducibility where supported. Identical results are not guaranteed. Check the selected model’ssupported_parametersmetadata before using this field.
gpt-image-1, gpt-image-1.5, gpt-image-2, and the GPT Image 2.5 and 2.6 Flare and Sunburst models):
quality(string, optional): Model-specific quality level, for examplelow,medium, orhigh. GPT Image 2.5 and 2.6 also acceptxhighandmax.output_format(string, optional):png,jpeg, orwebp. GPT Image 2.6 also supports animatedgiffor generation without reference images.output_compression(integer, optional):0–100. Applies tojpegandwebpoutput only.background(string, optional, not supported bygpt-image-2):auto(default),opaque, ortransparent.transparentrequiresoutput_formatpngorwebp. If the prompt describes a backdrop, the model may draw it instead of leaving the background transparent. Requests withopaqueortransparentare only routed to providers that support the setting, so they never fall back to one that would ignore it.
gpt-image-2.6-flare and gpt-image-2.6-sunburst, see GPT Image 2.6 controls and pricing. These models add a separate complexity control and bill from actual token usage; their catalog per-image estimates cover image output only.
See Supported Parameter Discovery for the discovery workflow. If a model/provider route offers a stronger reproducibility guarantee, rely only on documentation for that specific route.
For OpenAI-compatible image editing, use Image Edits.
Response
- Each
data[i]contains eitherb64_json(default) orurl(whenresponse_format: "url"), never both. - When requesting
response_format: "url", the API may still returnb64_jsonif URL generation (upload/presign) fails, as a fallback. - Signed URLs expire after 24 hours, and the stored image is deleted after about a day. Download promptly for long-term storage.
Examples
curl https://api.nano-gpt.com/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "hidream",
"prompt": "A sunset over a mountain range",
"n": 1,
"size": "1024x1024"
}'
curl https://api.nano-gpt.com/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "hidream",
"prompt": "A neon city skyline at night",
"n": 1,
"size": "1024x1024",
"response_format": "url"
}'
curl https://api.nano-gpt.com/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-image-2.5/flare/text-to-image",
"prompt": "A glossy red game controller icon, isolated object",
"n": 1,
"size": "1024x1024",
"background": "transparent",
"output_format": "png"
}'
import base64
import requests
API_KEY = "YOUR_API_KEY"
with open("input.jpg", "rb") as f:
encoded = base64.b64encode(f.read()).decode("utf-8")
image_data_url = f"data:image/jpeg;base64,{encoded}"
response = requests.post(
"https://api.nano-gpt.com/v1/images/generations",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={
"model": "flux-kontext",
"prompt": "Transform this image into a watercolor painting",
"n": 1,
"size": "1024x1024",
"imageDataUrl": image_data_url,
},
)
result = response.json()
Notes & Limits
- Input images must be provided as base64 data URLs; download and convert remote images before sending.
- Uploads should be 4 MB or smaller after encoding. Compress or resize large assets before sending.
- Use
GET /api/v1/image-models?detailed=trueto discover current image model capabilities and supported resolution values. For seed and other model-specific fields, also consult the Image API supported-parameter guidance.
Authorizations
Headers
Body
Parameters for image generation
The format in which the generated images are returned. Use "b64_json" (default) to receive base64-encoded image bytes in data[i].b64_json, or "url" to receive a time-limited, signed download URL in data[i].url (expires after 24 hours). Note: When requesting "url", the API may still return "b64_json" if URL generation (upload/presign) fails, as a fallback.
url, b64_json Base64-encoded image data URL for img2img generation. Single image input for models that support image-to-image transformation. Format: data:image/[type];base64,[data]. Note: Direct URL input is not supported - images must be converted to base64 data URLs before submission.
"data:image/jpeg;base64,/9j/4AAQ..."
Array of base64-encoded image data URLs for models supporting multiple image inputs (e.g., flux-kontext, gpt-4o-image, gpt-image-1). Each URL must follow the format: data:image/[type];base64,[data]
[
"data:image/jpeg;base64,/9j/4AAQ...",
"data:image/png;base64,iVBORw0KGgo..."
]
Response
Image generation response. Each data[i] contains either { url } or { b64_json }. When requesting response_format: "url", the API may fall back to returning { b64_json } if URL generation (upload/presign) fails.