Generate Images
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>"
}
]
}Image
Generate Images
Creates an image given a prompt.
POST
/
images
/
generations
Generate Images
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
Body
application/json
Prompt and generation options.
Was this page helpful?