Skip to main content
POST
/
v1
/
images
/
generations
Image generation
curl --request POST \
  --url https://openp.ai/v1/images/generations
import requests

url = "https://openp.ai/v1/images/generations"

response = requests.post(url)

print(response.text)
const options = {method: 'POST'};

fetch('https://openp.ai/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://openp.ai/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",
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://openp.ai/v1/images/generations"

req, _ := http.NewRequest("POST", url, nil)

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://openp.ai/v1/images/generations")
.asString();
require 'uri'
require 'net/http'

url = URI("https://openp.ai/v1/images/generations")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
Generate images from a natural-language description.

Request

curl https://openp.ai/v1/images/generations \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A black-and-white pencil sketch of a Shiba Inu wearing glasses",
    "size": "1024x1024",
    "n": 1,
    "quality": "high"
  }'

Parameters

FieldTypeRequiredDescription
modelstringgpt-image-2 / gpt-image-1 / dall-e-3 / dall-e-2
promptstringText prompt, up to 4000 characters
nintegerNumber of images (dall-e-3 supports only 1)
sizestring1024x1024 / 1792x1024 / 1024x1792 (DALL·E 3); gpt-image-1 supports more
qualitystringstandard / hd (dall-e-3); low / medium / high (gpt-image-1)
stylestringvivid / natural (dall-e-3)
response_formatstringurl (default) or b64_json
backgroundstringtransparent / opaque (gpt-image-1)
output_formatstringpng / jpeg / webp (gpt-image-1)

Response

{
  "created": 1715750400,
  "data": [
    {
      "url": "https://...",
      "revised_prompt": "A pencil sketch in black and white of a Shiba Inu..."
    }
  ]
}
The url is usually valid for only 1 hour — download it or copy it to your own storage. With response_format: "b64_json", base64 is returned:
{
  "data": [{"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."}]
}

DALL·E 3 notes

  • Only n=1; call multiple times to generate several images.
  • The prompt is automatically rewritten by the model; the returned revised_prompt is the prompt actually used.
  • No mask editing support (use images/edits).

gpt-image-1 notes

  • Supports n > 1 to generate multiple images at once.
  • Supports three quality tiers with notable price differences.
  • Supports a transparent background (background: "transparent").

Billing

A fixed charge per model × size × quality × count, unlike token billing. The specific multipliers shown in Console → Models are authoritative.