OpenAI Images Compatible Image Generation
curl --request POST \
--url https://www.token-nova.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"n": 123,
"size": "<string>",
"quality": "<string>",
"response_format": "<string>",
"style": {},
"background": {},
"watermark": true
}
'import requests
url = "https://www.token-nova.com/v1/images/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"n": 123,
"size": "<string>",
"quality": "<string>",
"response_format": "<string>",
"style": {},
"background": {},
"watermark": True
}
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({
model: '<string>',
prompt: '<string>',
n: 123,
size: '<string>',
quality: '<string>',
response_format: '<string>',
style: {},
background: {},
watermark: true
})
};
fetch('https://www.token-nova.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://www.token-nova.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([
'model' => '<string>',
'prompt' => '<string>',
'n' => 123,
'size' => '<string>',
'quality' => '<string>',
'response_format' => '<string>',
'style' => [
],
'background' => [
],
'watermark' => true
]),
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://www.token-nova.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\",\n \"style\": {},\n \"background\": {},\n \"watermark\": true\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://www.token-nova.com/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\",\n \"style\": {},\n \"background\": {},\n \"watermark\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.token-nova.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 \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\",\n \"style\": {},\n \"background\": {},\n \"watermark\": true\n}"
response = http.request(request)
puts response.read_body{
"created": 1735689600,
"data": [
{
"url": "https://.../images/img-abc123.png",
"revised_prompt": "A minimalist illustration for an API platform homepage, white background with teal accents"
}
]
}
{
"created": 1735689600,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"revised_prompt": "A minimalist illustration for an API platform homepage, white background with teal accents"
}
]
}
{
"error": {
"message": "size must be one of 1024x1024, 1024x1792 or 1792x1024 for dall-e-3",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "User quota is insufficient",
"type": "new_api_error",
"param": "",
"code": "insufficient_user_quota"
}
}
{
"error": {
"message": "The current request rate is too high, please try again later",
"type": "new_api_error",
"param": "",
"code": "too_many_requests"
}
}
{
"error": {
"message": "bad response body",
"type": "new_api_error",
"param": "",
"code": "bad_response_body"
}
}
OpenAI Images Compatible
OpenAI Images Compatible Image Generation
Use POST /v1/images/generations to call the unified image generation entry point, and select compatible models such as gpt-image-1, dall-e-3, and dall-e-2 via model.
POST
https://www.token-nova.com
/
v1
/
images
/
generations
OpenAI Images Compatible Image Generation
curl --request POST \
--url https://www.token-nova.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"n": 123,
"size": "<string>",
"quality": "<string>",
"response_format": "<string>",
"style": {},
"background": {},
"watermark": true
}
'import requests
url = "https://www.token-nova.com/v1/images/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"n": 123,
"size": "<string>",
"quality": "<string>",
"response_format": "<string>",
"style": {},
"background": {},
"watermark": True
}
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({
model: '<string>',
prompt: '<string>',
n: 123,
size: '<string>',
quality: '<string>',
response_format: '<string>',
style: {},
background: {},
watermark: true
})
};
fetch('https://www.token-nova.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://www.token-nova.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([
'model' => '<string>',
'prompt' => '<string>',
'n' => 123,
'size' => '<string>',
'quality' => '<string>',
'response_format' => '<string>',
'style' => [
],
'background' => [
],
'watermark' => true
]),
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://www.token-nova.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\",\n \"style\": {},\n \"background\": {},\n \"watermark\": true\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://www.token-nova.com/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\",\n \"style\": {},\n \"background\": {},\n \"watermark\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.token-nova.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 \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\",\n \"style\": {},\n \"background\": {},\n \"watermark\": true\n}"
response = http.request(request)
puts response.read_body{
"created": 1735689600,
"data": [
{
"url": "https://.../images/img-abc123.png",
"revised_prompt": "A minimalist illustration for an API platform homepage, white background with teal accents"
}
]
}
{
"created": 1735689600,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"revised_prompt": "A minimalist illustration for an API platform homepage, white background with teal accents"
}
]
}
{
"error": {
"message": "size must be one of 1024x1024, 1024x1792 or 1792x1024 for dall-e-3",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "User quota is insufficient",
"type": "new_api_error",
"param": "",
"code": "insufficient_user_quota"
}
}
{
"error": {
"message": "The current request rate is too high, please try again later",
"type": "new_api_error",
"param": "",
"code": "too_many_requests"
}
}
{
"error": {
"message": "bad response body",
"type": "new_api_error",
"param": "",
"code": "bad_response_body"
}
}
OpenAI Images Compatible Image Generation
Submit text-to-image requests through the unified image generation entry point, and return an OpenAI Images-style response.- A unified image generation API that selects different image models through
model. - Preserves the OpenAI Images response structure:
created+data[]. - Supports both
urlandb64_jsonresponse formats. - Size restrictions for
dall-e-2anddall-e-3are validated directly by the unified layer. - When
nis omitted or explicitly set to0, the unified layer automatically defaults it to1.
Method and Path
POST /v1/images/generations
Request Example
curl -X POST https://www.token-nova.com/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "A minimalist illustration for an API platform homepage, white background with teal accents",
"n": 1,
"size": "1024x1024",
"quality": "auto",
"response_format": "url"
}'
import requests
resp = requests.post(
"https://www.token-nova.com/v1/images/generations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"model": "gpt-image-1",
"prompt": "A minimalist illustration for an API platform homepage, white background with teal accents",
"n": 1,
"size": "1024x1024",
"quality": "auto",
"response_format": "url",
},
timeout=60,
)
print(resp.json())
const response = await fetch("https://www.token-nova.com/v1/images/generations", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-image-1",
prompt: "A minimalist illustration for an API platform homepage, white background with teal accents",
n: 1,
size: "1024x1024",
quality: "auto",
response_format: "url",
}),
});
console.log(await response.json());
Response Example
{
"created": 1735689600,
"data": [
{
"url": "https://.../images/img-abc123.png",
"revised_prompt": "A minimalist illustration for an API platform homepage, white background with teal accents"
}
]
}
{
"created": 1735689600,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"revised_prompt": "A minimalist illustration for an API platform homepage, white background with teal accents"
}
]
}
{
"error": {
"message": "size must be one of 1024x1024, 1024x1792 or 1792x1024 for dall-e-3",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "User quota is insufficient",
"type": "new_api_error",
"param": "",
"code": "insufficient_user_quota"
}
}
{
"error": {
"message": "The current request rate is too high, please try again later",
"type": "new_api_error",
"param": "",
"code": "too_many_requests"
}
}
{
"error": {
"message": "bad response body",
"type": "new_api_error",
"param": "",
"code": "bad_response_body"
}
}
Authentication
Authorization: Bearer YOUR_API_KEY
Body
string
required
Model name. The unified layer requires this field to be present.
string
Generation prompt. For image generation, it should be treated as required semantically; whether the request is ultimately blocked is determined jointly by the unified layer and the upstream provider.
integer
Number of images to generate. If omitted or explicitly set to
0, the unified layer falls back to 1.string
Output size.
dall-e-2 accepts only 256x256, 512x512, and 1024x1024; dall-e-3 accepts only 1024x1024, 1024x1792, and 1792x1024.string
Image quality.
dall-e-3 defaults to standard; gpt-image-1 defaults to auto.string
Response format. Common values are
url and b64_json. When b64_json or base64 is requested, the unified layer returns Base64 image data.string | object
Style field, passed through unchanged to supported upstream providers.
string | object
Background control field, passed through unchanged to supported upstream providers.
boolean
Explicit watermark switch.
false is semantically different from omitting it: omission means the default strategy is used, while false explicitly disables it.Response
integer
Generation timestamp.
string
The image URL returned when
response_format = url.string
The Base64 image data returned when
response_format = b64_json.string
Some upstream providers rewrite the prompt and return it in this field.
object
Additional metadata. Whether it exists depends on the specific channel.
Use Cases
Basic Image Generation
curl -X POST https://www.token-nova.com/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "Generate a clean product poster"
}'
High-Quality DALL·E 3
curl -X POST https://www.token-nova.com/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type": "application/json" \
-d '{
"model": "dall-e-3",
"prompt": "A sci-fi city nightscape illustration",
"size": "1792x1024",
"quality": "hd",
"response_format": "url"
}'
Base64 Output
curl -X POST https://www.token-nova.com/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type": "application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "Generate a clean poster of an icon set",
"response_format": "b64_json"
}'
Notes
This page describes only the common semantics of the unified entry point, and does not mean that all image channels support exactly the same fields. Whether fields such as
style, background, and watermark actually take effect depends on the final channel that is hit.