curl --request POST \
--url https://api.octen.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"n": 1,
"size": "auto",
"quality": "auto",
"background": "auto",
"output_format": "png",
"output_compression": 100,
"moderation": "auto",
"thinking_level": "minimal",
"response_modalities": [
"text",
"image"
],
"response_format": "b64_json",
"stream": false,
"partial_images": 0,
"user": "<string>",
"image": "<string>",
"mask": "<string>"
}
'import requests
url = "https://api.octen.ai/v1/images/generations"
payload = {
"prompt": "<string>",
"n": 1,
"size": "auto",
"quality": "auto",
"background": "auto",
"output_format": "png",
"output_compression": 100,
"moderation": "auto",
"thinking_level": "minimal",
"response_modalities": ["text", "image"],
"response_format": "b64_json",
"stream": False,
"partial_images": 0,
"user": "<string>",
"image": "<string>",
"mask": "<string>"
}
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>',
n: 1,
size: 'auto',
quality: 'auto',
background: 'auto',
output_format: 'png',
output_compression: 100,
moderation: 'auto',
thinking_level: 'minimal',
response_modalities: ['text', 'image'],
response_format: 'b64_json',
stream: false,
partial_images: 0,
user: '<string>',
image: '<string>',
mask: '<string>'
})
};
fetch('https://api.octen.ai/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.octen.ai/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>',
'n' => 1,
'size' => 'auto',
'quality' => 'auto',
'background' => 'auto',
'output_format' => 'png',
'output_compression' => 100,
'moderation' => 'auto',
'thinking_level' => 'minimal',
'response_modalities' => [
'text',
'image'
],
'response_format' => 'b64_json',
'stream' => false,
'partial_images' => 0,
'user' => '<string>',
'image' => '<string>',
'mask' => '<string>'
]),
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.octen.ai/v1/images/generations"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"n\": 1,\n \"size\": \"auto\",\n \"quality\": \"auto\",\n \"background\": \"auto\",\n \"output_format\": \"png\",\n \"output_compression\": 100,\n \"moderation\": \"auto\",\n \"thinking_level\": \"minimal\",\n \"response_modalities\": [\n \"text\",\n \"image\"\n ],\n \"response_format\": \"b64_json\",\n \"stream\": false,\n \"partial_images\": 0,\n \"user\": \"<string>\",\n \"image\": \"<string>\",\n \"mask\": \"<string>\"\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.octen.ai/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"n\": 1,\n \"size\": \"auto\",\n \"quality\": \"auto\",\n \"background\": \"auto\",\n \"output_format\": \"png\",\n \"output_compression\": 100,\n \"moderation\": \"auto\",\n \"thinking_level\": \"minimal\",\n \"response_modalities\": [\n \"text\",\n \"image\"\n ],\n \"response_format\": \"b64_json\",\n \"stream\": false,\n \"partial_images\": 0,\n \"user\": \"<string>\",\n \"image\": \"<string>\",\n \"mask\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.octen.ai/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 \"n\": 1,\n \"size\": \"auto\",\n \"quality\": \"auto\",\n \"background\": \"auto\",\n \"output_format\": \"png\",\n \"output_compression\": 100,\n \"moderation\": \"auto\",\n \"thinking_level\": \"minimal\",\n \"response_modalities\": [\n \"text\",\n \"image\"\n ],\n \"response_format\": \"b64_json\",\n \"stream\": false,\n \"partial_images\": 0,\n \"user\": \"<string>\",\n \"image\": \"<string>\",\n \"mask\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "img-9f2c1a7b3e6d4082",
"created": 1749812456,
"background": "opaque",
"output_format": "png",
"quality": "high",
"size": "1536x1024",
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}
],
"usage": {
"input_tokens": 22,
"input_tokens_details": {
"text_tokens": 22,
"image_tokens": 0
},
"output_tokens": 1056,
"output_tokens_details": {
"image_tokens": 1056,
"text_tokens": 0
},
"total_tokens": 1078
}
}Image Generation
Compatible with the OpenAI Images protocol. Text-to-image when no image is provided; image editing when an image is provided.
curl --request POST \
--url https://api.octen.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"n": 1,
"size": "auto",
"quality": "auto",
"background": "auto",
"output_format": "png",
"output_compression": 100,
"moderation": "auto",
"thinking_level": "minimal",
"response_modalities": [
"text",
"image"
],
"response_format": "b64_json",
"stream": false,
"partial_images": 0,
"user": "<string>",
"image": "<string>",
"mask": "<string>"
}
'import requests
url = "https://api.octen.ai/v1/images/generations"
payload = {
"prompt": "<string>",
"n": 1,
"size": "auto",
"quality": "auto",
"background": "auto",
"output_format": "png",
"output_compression": 100,
"moderation": "auto",
"thinking_level": "minimal",
"response_modalities": ["text", "image"],
"response_format": "b64_json",
"stream": False,
"partial_images": 0,
"user": "<string>",
"image": "<string>",
"mask": "<string>"
}
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>',
n: 1,
size: 'auto',
quality: 'auto',
background: 'auto',
output_format: 'png',
output_compression: 100,
moderation: 'auto',
thinking_level: 'minimal',
response_modalities: ['text', 'image'],
response_format: 'b64_json',
stream: false,
partial_images: 0,
user: '<string>',
image: '<string>',
mask: '<string>'
})
};
fetch('https://api.octen.ai/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.octen.ai/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>',
'n' => 1,
'size' => 'auto',
'quality' => 'auto',
'background' => 'auto',
'output_format' => 'png',
'output_compression' => 100,
'moderation' => 'auto',
'thinking_level' => 'minimal',
'response_modalities' => [
'text',
'image'
],
'response_format' => 'b64_json',
'stream' => false,
'partial_images' => 0,
'user' => '<string>',
'image' => '<string>',
'mask' => '<string>'
]),
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.octen.ai/v1/images/generations"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"n\": 1,\n \"size\": \"auto\",\n \"quality\": \"auto\",\n \"background\": \"auto\",\n \"output_format\": \"png\",\n \"output_compression\": 100,\n \"moderation\": \"auto\",\n \"thinking_level\": \"minimal\",\n \"response_modalities\": [\n \"text\",\n \"image\"\n ],\n \"response_format\": \"b64_json\",\n \"stream\": false,\n \"partial_images\": 0,\n \"user\": \"<string>\",\n \"image\": \"<string>\",\n \"mask\": \"<string>\"\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.octen.ai/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"n\": 1,\n \"size\": \"auto\",\n \"quality\": \"auto\",\n \"background\": \"auto\",\n \"output_format\": \"png\",\n \"output_compression\": 100,\n \"moderation\": \"auto\",\n \"thinking_level\": \"minimal\",\n \"response_modalities\": [\n \"text\",\n \"image\"\n ],\n \"response_format\": \"b64_json\",\n \"stream\": false,\n \"partial_images\": 0,\n \"user\": \"<string>\",\n \"image\": \"<string>\",\n \"mask\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.octen.ai/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 \"n\": 1,\n \"size\": \"auto\",\n \"quality\": \"auto\",\n \"background\": \"auto\",\n \"output_format\": \"png\",\n \"output_compression\": 100,\n \"moderation\": \"auto\",\n \"thinking_level\": \"minimal\",\n \"response_modalities\": [\n \"text\",\n \"image\"\n ],\n \"response_format\": \"b64_json\",\n \"stream\": false,\n \"partial_images\": 0,\n \"user\": \"<string>\",\n \"image\": \"<string>\",\n \"mask\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "img-9f2c1a7b3e6d4082",
"created": 1749812456,
"background": "opaque",
"output_format": "png",
"quality": "high",
"size": "1536x1024",
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}
],
"usage": {
"input_tokens": 22,
"input_tokens_details": {
"text_tokens": 22,
"image_tokens": 0
},
"output_tokens": 1056,
"output_tokens_details": {
"image_tokens": 1056,
"text_tokens": 0
},
"total_tokens": 1078
}
}Authorizations
Bearer token used for request authentication. Alternatively, you can send the API key in the x-api-key header. Note: A payment method is required to use the API.
Body
JSON request body for the Image Generation API.
The model to use. Aliases nano-banana-pro (= google/gemini-3-pro-image) and nano-banana-2 (= google/gemini-3.1-flash-image) are also accepted.
openai/gpt-image-2.5-flare, openai/gpt-image-2.5-sunburst, openai/gpt-image-2, openai/gpt-image-1-mini, google/gemini-3-pro-image, google/gemini-3.1-flash-image The text description for the model. The length limit is set by the model.
(GPT only) Number of images to generate. For Gemini, request multiple images in the prompt instead.
1 <= x <= 10Output size as width x height (e.g. 1024x1024) or auto.
(GPT only) Generation quality.
low, medium, high, xhigh, max, auto (GPT only) Background setting.
transparent, opaque, auto Output image format. GPT supports png/jpeg/webp; Gemini supports png/jpeg (webp falls back to png).
png, jpeg, webp (GPT only) Compression level (percent). Effective only when output_format is jpeg or webp.
0 <= x <= 100(GPT only) Content moderation strength.
low, auto (Gemini only) Thinking effort before generation.
minimal, high (Gemini only) Controls returned modalities. ["text","image"] returns the image plus accompanying text; ["image"] returns only the image.
text, image (Gemini only) Processing resolution for input reference images.
low, medium, high Return format.
b64_json (GPT only) Whether to stream the response.
(GPT only) Number of intermediate preview images to stream. Effective only when stream=true. Each preview costs an extra 100 image output tokens.
0 <= x <= 3A unique identifier for the end user. Use hashed or pseudonymous identifiers to avoid passing personally identifiable information.
Reference/source image(s) for editing, a data URL prefix or a raw base64 string. Providing an image enters edit mode. An array passes multiple reference images.
(GPT only) Mask image, base64-encoded PNG matching the input size. Transparent areas are repainted. Effective only when image is provided.
Response
Successful image response. When stream=false, returns a single object. When stream=true (GPT only), returns an SSE stream of image_generation.partial_image / image_edit.partial_image preview events followed by a image_generation.completed / image_edit.completed event.
- Option 1
- Option 2
A non-streaming image response. Images are always returned as base64.
The unique identifier for this request.
Unix timestamp (in seconds) of when the request was created.
The generated images, one element per image.
Show child attributes
Show child attributes
Token usage information.
Show child attributes
Show child attributes
(GPT only) The background setting actually applied.
transparent, opaque The output format actually applied; for Gemini, derived from the mimeType.
png, jpeg, webp (GPT only) The quality tier actually applied.
low, medium, high, xhigh, max (GPT only) The output size actually applied; useful when size was auto.
(Gemini only) Plain-text summary of text the model produced alongside the image. For exact interleaving, read parts.
(Gemini only) Content parts in the model's original order, preserving text/image interleaving.
Show child attributes
Show child attributes
Was this page helpful?