Skip to main content
POST
/
v1
/
images
/
generations
OpenAI image generations
curl --request POST \
  --url https://api-vip.apigo.ai/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "一只可爱的小猫在花园里玩耍,阳光明媚,油画风格",
  "model": "gpt-image-1",
  "size": "1024x1024",
  "quality": "high"
}
'
import requests

url = "https://api-vip.apigo.ai/v1/images/generations"

payload = {
"prompt": "一只可爱的小猫在花园里玩耍,阳光明媚,油画风格",
"model": "gpt-image-1",
"size": "1024x1024",
"quality": "high"
}
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: '一只可爱的小猫在花园里玩耍,阳光明媚,油画风格',
model: 'gpt-image-1',
size: '1024x1024',
quality: 'high'
})
};

fetch('https://api-vip.apigo.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://api-vip.apigo.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",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '一只可爱的小猫在花园里玩耍,阳光明媚,油画风格',
'model' => 'gpt-image-1',
'size' => '1024x1024',
'quality' => 'high'
]),
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-vip.apigo.ai/v1/images/generations"

payload := strings.NewReader("{\n \"prompt\": \"一只可爱的小猫在花园里玩耍,阳光明媚,油画风格\",\n \"model\": \"gpt-image-1\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\"\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-vip.apigo.ai/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"一只可爱的小猫在花园里玩耍,阳光明媚,油画风格\",\n \"model\": \"gpt-image-1\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api-vip.apigo.ai/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 \"prompt\": \"一只可爱的小猫在花园里玩耍,阳光明媚,油画风格\",\n \"model\": \"gpt-image-1\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\"\n}"

response = http.request(request)
puts response.read_body
{
  "created": 1589478378,
  "background": "auto",
  "output_format": "png",
  "quality": "high",
  "size": "1024x1024",
  "data": [
    {
      "url": "https://example.com/generated-image.png"
    }
  ],
  "usage": {
    "input_tokens": 15,
    "input_tokens_details": {
      "image_tokens": 0,
      "text_tokens": 15
    },
    "output_tokens": 1,
    "total_tokens": 16
  }
}
{
"error": 123,
"message": "<string>"
}
Create images from text prompts.
  • Authenticate with Authorization: Bearer {API_KEY}
  • Use this as the text-to-image route; for edits, inpainting, or image expansion, use /v1/images/edits
  • gpt-image-1, dall-e-3, and dall-e-2 expose different parameter sets, and those differences are now rendered in the native parameter panel above
  • If the response contains temporary url values, mirror them server-side quickly; if it contains b64_json, avoid decoding too many large images on the main thread

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
prompt
string
required

Text prompt for the desired image.

Example:

"一只可爱的小猫在花园里玩耍,阳光明媚,油画风格"

model
enum<string>

Image generation model.

Available options:
gpt-image-1,
dall-e-3,
dall-e-2
background
enum<string>

Only supported by gpt-image-1.

Available options:
transparent,
opaque,
auto
moderation
enum<string>

Only supported by gpt-image-1.

Available options:
auto,
low
n
integer
default:1

Number of images to generate. dall-e-3 only supports 1.

Required range: 1 <= x <= 10
output_compression
integer
default:100

Compression level for gpt-image-1 jpeg/webp output.

Required range: 0 <= x <= 100
output_format
enum<string>

Only supported by gpt-image-1.

Available options:
png,
jpeg,
webp
partial_images
integer
default:0

Number of partial images for streaming previews.

Required range: 0 <= x <= 3
quality
enum<string>

Supported values vary by model.

Available options:
auto,
high,
medium,
low,
hd,
standard
response_format
enum<string>

Only applies to dall-e-2 and dall-e-3.

Available options:
url,
b64_json
size
enum<string>

Allowed values depend on the selected model.

Available options:
1024x1024,
1536x1024,
1024x1536,
auto,
256x256,
512x512,
1792x1024,
1024x1792
stream
boolean
default:false

Only supported by gpt-image-1.

style
enum<string>

Only supported by dall-e-3.

Available options:
vivid,
natural
user
string

Unique identifier for the end user.

Response

Successful image generation response

created
integer<int64>
required

Unix timestamp in seconds.

data
object[]
required
background
enum<string>
Available options:
transparent,
opaque,
auto
output_format
enum<string>
Available options:
png,
jpeg,
webp
quality
enum<string>
Available options:
auto,
high,
medium,
low,
hd,
standard
size
string
usage
object