Openai Images Generations
curl --request POST \
--url https://api.deepinfra.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"n": 1,
"response_format": "b64_json",
"size": "1024x1024",
"user": "<string>",
"quality": "<string>",
"style": "<string>"
}
'import requests
url = "https://api.deepinfra.com/v1/images/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"n": 1,
"response_format": "b64_json",
"size": "1024x1024",
"user": "<string>",
"quality": "<string>",
"style": "<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({
model: '<string>',
prompt: '<string>',
n: 1,
response_format: 'b64_json',
size: '1024x1024',
user: '<string>',
quality: '<string>',
style: '<string>'
})
};
fetch('https://api.deepinfra.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://api.deepinfra.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' => 1,
'response_format' => 'b64_json',
'size' => '1024x1024',
'user' => '<string>',
'quality' => '<string>',
'style' => '<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.deepinfra.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 1,\n \"response_format\": \"b64_json\",\n \"size\": \"1024x1024\",\n \"user\": \"<string>\",\n \"quality\": \"<string>\",\n \"style\": \"<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.deepinfra.com/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 1,\n \"response_format\": \"b64_json\",\n \"size\": \"1024x1024\",\n \"user\": \"<string>\",\n \"quality\": \"<string>\",\n \"style\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deepinfra.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\": 1,\n \"response_format\": \"b64_json\",\n \"size\": \"1024x1024\",\n \"user\": \"<string>\",\n \"quality\": \"<string>\",\n \"style\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"b64_json": "<string>",
"revised_prompt": "<string>",
"url": "<string>"
}
],
"created": 123
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Image Generation
Openai Images Generations
Generate image using OpenAI Images API
POST
/
v1
/
images
/
generations
Openai Images Generations
curl --request POST \
--url https://api.deepinfra.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"n": 1,
"response_format": "b64_json",
"size": "1024x1024",
"user": "<string>",
"quality": "<string>",
"style": "<string>"
}
'import requests
url = "https://api.deepinfra.com/v1/images/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"n": 1,
"response_format": "b64_json",
"size": "1024x1024",
"user": "<string>",
"quality": "<string>",
"style": "<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({
model: '<string>',
prompt: '<string>',
n: 1,
response_format: 'b64_json',
size: '1024x1024',
user: '<string>',
quality: '<string>',
style: '<string>'
})
};
fetch('https://api.deepinfra.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://api.deepinfra.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' => 1,
'response_format' => 'b64_json',
'size' => '1024x1024',
'user' => '<string>',
'quality' => '<string>',
'style' => '<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.deepinfra.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 1,\n \"response_format\": \"b64_json\",\n \"size\": \"1024x1024\",\n \"user\": \"<string>\",\n \"quality\": \"<string>\",\n \"style\": \"<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.deepinfra.com/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 1,\n \"response_format\": \"b64_json\",\n \"size\": \"1024x1024\",\n \"user\": \"<string>\",\n \"quality\": \"<string>\",\n \"style\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deepinfra.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\": 1,\n \"response_format\": \"b64_json\",\n \"size\": \"1024x1024\",\n \"user\": \"<string>\",\n \"quality\": \"<string>\",\n \"style\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"b64_json": "<string>",
"revised_prompt": "<string>",
"url": "<string>"
}
],
"created": 123
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
The model to use for image generation.
Example:
"black-forest-labs/FLUX-1-schnell"
A text description of desired image(s).
Example:
"A photo of an astronaut riding a horse on Mars."
The number of images to generate.
Required range:
1 <= x <= 4The format in which the generated images are returned. Currently only b64_json is supported.
Available options:
b64_json The size of the generated images. Available sizes depend on the model.
A unique identifier representing your end-user, which can help to monitor and detect abuse.
The quality of the image that will be generated.
The style of the generated images.
⌘I