curl --request POST \
--url https://{gatewayBaseURL}/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"model": "<string>",
"background": "<string>",
"moderation": "<string>",
"n": 1,
"output_compression": 123,
"output_format": "<string>",
"partial_images": 0,
"quality": "<string>",
"response_format": "url",
"size": "<string>",
"stream": false,
"style": "<string>",
"user": "<string>"
}
'import requests
url = "https://{gatewayBaseURL}/images/generations"
payload = {
"prompt": "<string>",
"model": "<string>",
"background": "<string>",
"moderation": "<string>",
"n": 1,
"output_compression": 123,
"output_format": "<string>",
"partial_images": 0,
"quality": "<string>",
"response_format": "url",
"size": "<string>",
"stream": False,
"style": "<string>",
"user": "<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>',
model: '<string>',
background: '<string>',
moderation: '<string>',
n: 1,
output_compression: 123,
output_format: '<string>',
partial_images: 0,
quality: '<string>',
response_format: 'url',
size: '<string>',
stream: false,
style: '<string>',
user: '<string>'
})
};
fetch('https://{gatewayBaseURL}/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://{gatewayBaseURL}/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' => '<string>',
'background' => '<string>',
'moderation' => '<string>',
'n' => 1,
'output_compression' => 123,
'output_format' => '<string>',
'partial_images' => 0,
'quality' => '<string>',
'response_format' => 'url',
'size' => '<string>',
'stream' => false,
'style' => '<string>',
'user' => '<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://{gatewayBaseURL}/images/generations"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"background\": \"<string>\",\n \"moderation\": \"<string>\",\n \"n\": 1,\n \"output_compression\": 123,\n \"output_format\": \"<string>\",\n \"partial_images\": 0,\n \"quality\": \"<string>\",\n \"response_format\": \"url\",\n \"size\": \"<string>\",\n \"stream\": false,\n \"style\": \"<string>\",\n \"user\": \"<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://{gatewayBaseURL}/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"background\": \"<string>\",\n \"moderation\": \"<string>\",\n \"n\": 1,\n \"output_compression\": 123,\n \"output_format\": \"<string>\",\n \"partial_images\": 0,\n \"quality\": \"<string>\",\n \"response_format\": \"url\",\n \"size\": \"<string>\",\n \"stream\": false,\n \"style\": \"<string>\",\n \"user\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{gatewayBaseURL}/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\": \"<string>\",\n \"background\": \"<string>\",\n \"moderation\": \"<string>\",\n \"n\": 1,\n \"output_compression\": 123,\n \"output_format\": \"<string>\",\n \"partial_images\": 0,\n \"quality\": \"<string>\",\n \"response_format\": \"url\",\n \"size\": \"<string>\",\n \"stream\": false,\n \"style\": \"<string>\",\n \"user\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"created": 123,
"data": [
{
"url": "<string>",
"b64_json": "<string>",
"revised_prompt": "<string>"
}
]
}Generate Images
Creates an image given a prompt.
curl --request POST \
--url https://{gatewayBaseURL}/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"model": "<string>",
"background": "<string>",
"moderation": "<string>",
"n": 1,
"output_compression": 123,
"output_format": "<string>",
"partial_images": 0,
"quality": "<string>",
"response_format": "url",
"size": "<string>",
"stream": false,
"style": "<string>",
"user": "<string>"
}
'import requests
url = "https://{gatewayBaseURL}/images/generations"
payload = {
"prompt": "<string>",
"model": "<string>",
"background": "<string>",
"moderation": "<string>",
"n": 1,
"output_compression": 123,
"output_format": "<string>",
"partial_images": 0,
"quality": "<string>",
"response_format": "url",
"size": "<string>",
"stream": False,
"style": "<string>",
"user": "<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>',
model: '<string>',
background: '<string>',
moderation: '<string>',
n: 1,
output_compression: 123,
output_format: '<string>',
partial_images: 0,
quality: '<string>',
response_format: 'url',
size: '<string>',
stream: false,
style: '<string>',
user: '<string>'
})
};
fetch('https://{gatewayBaseURL}/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://{gatewayBaseURL}/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' => '<string>',
'background' => '<string>',
'moderation' => '<string>',
'n' => 1,
'output_compression' => 123,
'output_format' => '<string>',
'partial_images' => 0,
'quality' => '<string>',
'response_format' => 'url',
'size' => '<string>',
'stream' => false,
'style' => '<string>',
'user' => '<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://{gatewayBaseURL}/images/generations"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"background\": \"<string>\",\n \"moderation\": \"<string>\",\n \"n\": 1,\n \"output_compression\": 123,\n \"output_format\": \"<string>\",\n \"partial_images\": 0,\n \"quality\": \"<string>\",\n \"response_format\": \"url\",\n \"size\": \"<string>\",\n \"stream\": false,\n \"style\": \"<string>\",\n \"user\": \"<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://{gatewayBaseURL}/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"background\": \"<string>\",\n \"moderation\": \"<string>\",\n \"n\": 1,\n \"output_compression\": 123,\n \"output_format\": \"<string>\",\n \"partial_images\": 0,\n \"quality\": \"<string>\",\n \"response_format\": \"url\",\n \"size\": \"<string>\",\n \"stream\": false,\n \"style\": \"<string>\",\n \"user\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{gatewayBaseURL}/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\": \"<string>\",\n \"background\": \"<string>\",\n \"moderation\": \"<string>\",\n \"n\": 1,\n \"output_compression\": 123,\n \"output_format\": \"<string>\",\n \"partial_images\": 0,\n \"quality\": \"<string>\",\n \"response_format\": \"url\",\n \"size\": \"<string>\",\n \"stream\": false,\n \"style\": \"<string>\",\n \"user\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"created": 123,
"data": [
{
"url": "<string>",
"b64_json": "<string>",
"revised_prompt": "<string>"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Prompt and generation options.
A text description of the desired image(s).
The model to use for image generation.
Sets background transparency for generated images.
Control the content-moderation level for images generated.
The number of images to generate. Must be between 1 and 10.
The compression level (0-100%) for the generated images.
The format in which the generated images are returned.
The number of partial images to generate. Used for streaming responses.
The quality of the image that will be generated.
The format in which generated images are returned. Must be one of url or b64_json.
The size of the generated images.
Generate the image in streaming mode.
The style of the generated images.
A unique identifier representing your end-user.
Was this page helpful?