curl --request POST \
--url https://api.deepinfra.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "black-forest-labs/FLUX-1-schnell",
"prompt": "A photo of an astronaut riding a horse on Mars.",
"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": "black-forest-labs/FLUX-1-schnell",
"prompt": "A photo of an astronaut riding a horse on Mars.",
"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: 'black-forest-labs/FLUX-1-schnell',
prompt: 'A photo of an astronaut riding a horse on Mars.',
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' => 'black-forest-labs/FLUX-1-schnell',
'prompt' => 'A photo of an astronaut riding a horse on Mars.',
'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\": \"black-forest-labs/FLUX-1-schnell\",\n \"prompt\": \"A photo of an astronaut riding a horse on Mars.\",\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\": \"black-forest-labs/FLUX-1-schnell\",\n \"prompt\": \"A photo of an astronaut riding a horse on Mars.\",\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\": \"black-forest-labs/FLUX-1-schnell\",\n \"prompt\": \"A photo of an astronaut riding a horse on Mars.\",\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>"
}
]
}Openai Images Generations
Generate image using OpenAI Images API
curl --request POST \
--url https://api.deepinfra.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "black-forest-labs/FLUX-1-schnell",
"prompt": "A photo of an astronaut riding a horse on Mars.",
"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": "black-forest-labs/FLUX-1-schnell",
"prompt": "A photo of an astronaut riding a horse on Mars.",
"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: 'black-forest-labs/FLUX-1-schnell',
prompt: 'A photo of an astronaut riding a horse on Mars.',
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' => 'black-forest-labs/FLUX-1-schnell',
'prompt' => 'A photo of an astronaut riding a horse on Mars.',
'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\": \"black-forest-labs/FLUX-1-schnell\",\n \"prompt\": \"A photo of an astronaut riding a horse on Mars.\",\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\": \"black-forest-labs/FLUX-1-schnell\",\n \"prompt\": \"A photo of an astronaut riding a horse on Mars.\",\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\": \"black-forest-labs/FLUX-1-schnell\",\n \"prompt\": \"A photo of an astronaut riding a horse on Mars.\",\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
The model to use for image generation.
"black-forest-labs/FLUX-1-schnell"
A text description of desired image(s).
"A photo of an astronaut riding a horse on Mars."
The number of images to generate.
1 <= x <= 4The format in which the generated images are returned: 'b64_json' (default) or 'url'. For most models 'url' points to a temporary copy we host that expires after about a day; for some provider-backed models it is the provider's own URL with the provider's own lifetime.
b64_json, url 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.