curl --request POST \
--url https://api.ttapi.io/v1/images/generations \
--header 'Content-Type: application/json' \
--header 'TT-API-KEY: <api-key>' \
--data '
{
"prompt": "<string>",
"model": "dall-e-2",
"background": "auto",
"moderation": "auto",
"n": 123,
"output_compression": 100,
"output_format": "png",
"partial_images": 0,
"quality": "auto",
"size": "auto",
"stream": false,
"user": "<string>"
}
'import requests
url = "https://api.ttapi.io/v1/images/generations"
payload = {
"prompt": "<string>",
"model": "dall-e-2",
"background": "auto",
"moderation": "auto",
"n": 123,
"output_compression": 100,
"output_format": "png",
"partial_images": 0,
"quality": "auto",
"size": "auto",
"stream": False,
"user": "<string>"
}
headers = {
"TT-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'TT-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
model: 'dall-e-2',
background: 'auto',
moderation: 'auto',
n: 123,
output_compression: 100,
output_format: 'png',
partial_images: 0,
quality: 'auto',
size: 'auto',
stream: false,
user: '<string>'
})
};
fetch('https://api.ttapi.io/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.ttapi.io/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' => 'dall-e-2',
'background' => 'auto',
'moderation' => 'auto',
'n' => 123,
'output_compression' => 100,
'output_format' => 'png',
'partial_images' => 0,
'quality' => 'auto',
'size' => 'auto',
'stream' => false,
'user' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"TT-API-KEY: <api-key>"
],
]);
$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.ttapi.io/v1/images/generations"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"dall-e-2\",\n \"background\": \"auto\",\n \"moderation\": \"auto\",\n \"n\": 123,\n \"output_compression\": 100,\n \"output_format\": \"png\",\n \"partial_images\": 0,\n \"quality\": \"auto\",\n \"size\": \"auto\",\n \"stream\": false,\n \"user\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("TT-API-KEY", "<api-key>")
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.ttapi.io/v1/images/generations")
.header("TT-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"dall-e-2\",\n \"background\": \"auto\",\n \"moderation\": \"auto\",\n \"n\": 123,\n \"output_compression\": 100,\n \"output_format\": \"png\",\n \"partial_images\": 0,\n \"quality\": \"auto\",\n \"size\": \"auto\",\n \"stream\": false,\n \"user\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.io/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["TT-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"model\": \"dall-e-2\",\n \"background\": \"auto\",\n \"moderation\": \"auto\",\n \"n\": 123,\n \"output_compression\": 100,\n \"output_format\": \"png\",\n \"partial_images\": 0,\n \"quality\": \"auto\",\n \"size\": \"auto\",\n \"stream\": false,\n \"user\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1745818538,
"data": [
{
"url": "https://filesystem.site/cdn/20250428/5LsFMT0Def02RVVUkwJ4v7IslleMzo.webp",
"revised_prompt": "A cute fluffy cat with big, bright eyes, soft fur, and a playful expression. It has a light gray coat with hints of white on its paws and tail. The cat is sitting in a cozy setting, surrounded by soft cushions, with its tail wrapped around its paws. Its ears are perked up, and it's looking directly at the viewer, exuding a sense of curiosity and warmth."
}
],
"usage": {
"input_tokens": 9,
"input_tokens_details": {
"image_tokens": 0,
"text_tokens": 9
},
"output_tokens": 4160,
"total_tokens": 4169
}
}{
"status": "FAILED",
"message": "\"prompt\" cannot be empty.",
"data": {}
}{
"status": "FAILED",
"message": "Wrong TT-API-KEY or email is not activated."
}OpenAI Images Generations
curl --request POST \
--url https://api.ttapi.io/v1/images/generations \
--header 'Content-Type: application/json' \
--header 'TT-API-KEY: <api-key>' \
--data '
{
"prompt": "<string>",
"model": "dall-e-2",
"background": "auto",
"moderation": "auto",
"n": 123,
"output_compression": 100,
"output_format": "png",
"partial_images": 0,
"quality": "auto",
"size": "auto",
"stream": false,
"user": "<string>"
}
'import requests
url = "https://api.ttapi.io/v1/images/generations"
payload = {
"prompt": "<string>",
"model": "dall-e-2",
"background": "auto",
"moderation": "auto",
"n": 123,
"output_compression": 100,
"output_format": "png",
"partial_images": 0,
"quality": "auto",
"size": "auto",
"stream": False,
"user": "<string>"
}
headers = {
"TT-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'TT-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
model: 'dall-e-2',
background: 'auto',
moderation: 'auto',
n: 123,
output_compression: 100,
output_format: 'png',
partial_images: 0,
quality: 'auto',
size: 'auto',
stream: false,
user: '<string>'
})
};
fetch('https://api.ttapi.io/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.ttapi.io/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' => 'dall-e-2',
'background' => 'auto',
'moderation' => 'auto',
'n' => 123,
'output_compression' => 100,
'output_format' => 'png',
'partial_images' => 0,
'quality' => 'auto',
'size' => 'auto',
'stream' => false,
'user' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"TT-API-KEY: <api-key>"
],
]);
$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.ttapi.io/v1/images/generations"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"dall-e-2\",\n \"background\": \"auto\",\n \"moderation\": \"auto\",\n \"n\": 123,\n \"output_compression\": 100,\n \"output_format\": \"png\",\n \"partial_images\": 0,\n \"quality\": \"auto\",\n \"size\": \"auto\",\n \"stream\": false,\n \"user\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("TT-API-KEY", "<api-key>")
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.ttapi.io/v1/images/generations")
.header("TT-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"dall-e-2\",\n \"background\": \"auto\",\n \"moderation\": \"auto\",\n \"n\": 123,\n \"output_compression\": 100,\n \"output_format\": \"png\",\n \"partial_images\": 0,\n \"quality\": \"auto\",\n \"size\": \"auto\",\n \"stream\": false,\n \"user\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.io/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["TT-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"model\": \"dall-e-2\",\n \"background\": \"auto\",\n \"moderation\": \"auto\",\n \"n\": 123,\n \"output_compression\": 100,\n \"output_format\": \"png\",\n \"partial_images\": 0,\n \"quality\": \"auto\",\n \"size\": \"auto\",\n \"stream\": false,\n \"user\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1745818538,
"data": [
{
"url": "https://filesystem.site/cdn/20250428/5LsFMT0Def02RVVUkwJ4v7IslleMzo.webp",
"revised_prompt": "A cute fluffy cat with big, bright eyes, soft fur, and a playful expression. It has a light gray coat with hints of white on its paws and tail. The cat is sitting in a cozy setting, surrounded by soft cushions, with its tail wrapped around its paws. Its ears are perked up, and it's looking directly at the viewer, exuding a sense of curiosity and warmth."
}
],
"usage": {
"input_tokens": 9,
"input_tokens_details": {
"image_tokens": 0,
"text_tokens": 9
},
"output_tokens": 4160,
"total_tokens": 4169
}
}{
"status": "FAILED",
"message": "\"prompt\" cannot be empty.",
"data": {}
}{
"status": "FAILED",
"message": "Wrong TT-API-KEY or email is not activated."
}POST /v1/images/generations.
Documentation translated from the official documentation.
Supported models include gpt-image-2.5-flare, gpt-image-2.5-sunburst, gpt-image-2, gpt-image-1.5, gpt-image-1, dall-e-2, and dall-e-3.
Authorizations
You can obtain your API key from the TTAPI Dashboard.
Body
Text description of the image. gpt-image-2.5-flare, gpt-image-2.5-sunburst, gpt-image-2, gpt-image-1.5, and gpt-image-1 support up to 32,000 characters; dall-e-2 supports up to 1,000 characters; dall-e-3 supports up to 4,000 characters.
The model to use for image generation.
gpt-image-2.5-flare, gpt-image-2.5-sunburst, gpt-image-2, gpt-image-1.5, gpt-image-1, dall-e-2, dall-e-3 Sets the transparency of generated image backgrounds. Applies only to GPT Image models. Choose transparent, opaque, or auto (default). When set to transparent, output_format must support transparency; use png or webp.
transparent, opaque, auto Controls the content moderation level for images generated by GPT Image models. Choose low for less restrictive filtering or auto (default).
low, auto Number of images to generate, default 1. Available range 1-10; dall-e-3 is fixed at 1.
Compression level for generated images (0-100). Applies only to GPT Image models with output_format set to webp or jpeg; defaults to 100.
Return format for generated images. Applies only to GPT Image models. Choose png (default), jpeg, or webp.
png, jpeg, webp Number of partial images to return in the streaming response, from 0 to 3; defaults to 0. Available only when stream is true.
Image quality. auto (default) automatically selects the best quality for the model.
gpt-image-2.5-flare and gpt-image-2.5-sunburst support low, medium, high, xhigh, max, and auto;
Other GPT Image models support high, medium, and low;
dall-e-3 supports hd and standard;
dall-e-2 only supports standard.
Return data format. Only dall-e-2 and dall-e-3 support url or b64_json; URLs are valid for 60 minutes. GPT Image models always return b64_json.
url, b64_json Image size.
GPT Image models support 1024x1024, 1536x1024, 1024x1536, and auto (default).
gpt-image-2, gpt-image-2.5-flare, and gpt-image-2.5-sunburst support arbitrary WIDTHxHEIGHT resolution strings where both dimensions are divisible by 16 and the aspect ratio is between 1:3 and 3:1. For gpt-image-2.5-flare and gpt-image-2.5-sunburst, the longest edge must be ≤ 3840 and the total pixel count must be between 655,360 and 8,294,400.
dall-e-2 supports 256x256, 512x512, 1024x1024;
dall-e-3 supports 1024x1024, 1792x1024, 1024x1792.
Whether to stream generation progress. When enabled, use partial_images to receive partial image events.
Style of generated image. Applies only to dall-e-3.
vivid, natural A unique identifier representing your end-user, which can help OpenAI monitor and detect abuse.
Response
Request successful, returns image generation results (supports url/base64 formats)