curl --request POST \
--url https://api.photalabs.com/v2/phota/generate \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"num_output_images": 1,
"prompt": "Generate a photo of [[abc123]] on a tropical beach"
}
'import requests
url = "https://api.photalabs.com/v2/phota/generate"
payload = {
"num_output_images": 1,
"prompt": "Generate a photo of [[abc123]] on a tropical beach"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
num_output_images: 1,
prompt: 'Generate a photo of [[abc123]] on a tropical beach'
})
};
fetch('https://api.photalabs.com/v2/phota/generate', 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.photalabs.com/v2/phota/generate",
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([
'num_output_images' => 1,
'prompt' => 'Generate a photo of [[abc123]] on a tropical beach'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-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.photalabs.com/v2/phota/generate"
payload := strings.NewReader("{\n \"num_output_images\": 1,\n \"prompt\": \"Generate a photo of [[abc123]] on a tropical beach\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-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.photalabs.com/v2/phota/generate")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"num_output_images\": 1,\n \"prompt\": \"Generate a photo of [[abc123]] on a tropical beach\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.photalabs.com/v2/phota/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"num_output_images\": 1,\n \"prompt\": \"Generate a photo of [[abc123]] on a tropical beach\"\n}"
response = http.request(request)
puts response.read_body{
"known_subjects": {
"counts": {}
},
"images": [
"<string>"
],
"download_urls": [
"<string>"
]
}{
"job_id": "<string>",
"poll_url": "<string>",
"status": "pending"
}{
"detail": "<string>",
"code": "CONTENT_MODERATION",
"request_id": "<string>"
}{
"detail": "<string>",
"code": "NOT_FOUND",
"request_id": "<string>"
}{
"detail": "<string>",
"code": "NO_IMAGE_GENERATED",
"request_id": "<string>"
}{
"detail": "<string>",
"code": "INTERNAL_ERROR",
"request_id": "<string>"
}{
"detail": "<string>",
"code": "SERVICE_UNAVAILABLE",
"request_id": "<string>"
}{
"detail": "<string>",
"code": "TIMEOUT",
"request_id": "<string>"
}Generate
Generate images from a text prompt without input images.
Provide a prompt describing the desired image. Returns base64 images or signed download URLs.
curl --request POST \
--url https://api.photalabs.com/v2/phota/generate \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"num_output_images": 1,
"prompt": "Generate a photo of [[abc123]] on a tropical beach"
}
'import requests
url = "https://api.photalabs.com/v2/phota/generate"
payload = {
"num_output_images": 1,
"prompt": "Generate a photo of [[abc123]] on a tropical beach"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
num_output_images: 1,
prompt: 'Generate a photo of [[abc123]] on a tropical beach'
})
};
fetch('https://api.photalabs.com/v2/phota/generate', 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.photalabs.com/v2/phota/generate",
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([
'num_output_images' => 1,
'prompt' => 'Generate a photo of [[abc123]] on a tropical beach'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-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.photalabs.com/v2/phota/generate"
payload := strings.NewReader("{\n \"num_output_images\": 1,\n \"prompt\": \"Generate a photo of [[abc123]] on a tropical beach\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-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.photalabs.com/v2/phota/generate")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"num_output_images\": 1,\n \"prompt\": \"Generate a photo of [[abc123]] on a tropical beach\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.photalabs.com/v2/phota/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"num_output_images\": 1,\n \"prompt\": \"Generate a photo of [[abc123]] on a tropical beach\"\n}"
response = http.request(request)
puts response.read_body{
"known_subjects": {
"counts": {}
},
"images": [
"<string>"
],
"download_urls": [
"<string>"
]
}{
"job_id": "<string>",
"poll_url": "<string>",
"status": "pending"
}{
"detail": "<string>",
"code": "CONTENT_MODERATION",
"request_id": "<string>"
}{
"detail": "<string>",
"code": "NOT_FOUND",
"request_id": "<string>"
}{
"detail": "<string>",
"code": "NO_IMAGE_GENERATED",
"request_id": "<string>"
}{
"detail": "<string>",
"code": "INTERNAL_ERROR",
"request_id": "<string>"
}{
"detail": "<string>",
"code": "SERVICE_UNAVAILABLE",
"request_id": "<string>"
}{
"detail": "<string>",
"code": "TIMEOUT",
"request_id": "<string>"
}Body
Request body for the generate endpoint.
Provide a text prompt describing the image you want to create.
Reference profiles inline using [[profile_id]] syntax to
specify which people should appear in the generated image.
Output aspect ratio (1:1, 3:4, 4:3, 9:16, 16:9; 'auto' matches the input image where supported). Omit to use the model's default: 'auto' for models that support it, '4:3' otherwise. 'auto' is rejected with 400 for models that do not support it.
auto, 1:1, 3:4, 4:3, 9:16, 16:9 Quality tier (auto, low, medium, high; xhigh and max on GPT Image 2.5 only). Only supported by the GPT Image models (gpt-image-2, gpt-image-2.5-sunburst, gpt-image-2.5-flare); passing this field for other models returns 400. Omit (or pass 'auto') to let the provider pick — on the GPT Image models this resolves to OpenAI's auto tier. Lower tiers reduce output tokens and therefore settled cost.
auto, low, medium, high, xhigh, max Exact GPT Image output size as WIDTHxHEIGHT, e.g. 1536x864. Edges must be multiples of 16, at most 3840, with aspect ratio at most 3:1 and 655360-3686400 total pixels. Replaces the default 1K tier; cannot combine with a non-default resolution or aspect_ratio. Other base models return 400.
^[1-9][0-9]{0,3}x[1-9][0-9]{0,3}$Base model identifier. Omit to use the default base model. Unknown ids are rejected with 400; base models that do not support this endpoint's capability are also rejected with 400.
flux-2, flux-2-pro, gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst, nb2, qwen-image-2, seedream-5-pro Response
Successful Response
Response returned by the edit, generate, and enhance endpoints.
