images generate
curl --request POST \
--url https://ai.pmock.com/api/ai/v1/images/generations \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"model": "gpt-image-2",
"quality": "auto",
"size": "1024x1024",
"n": 123,
"user": "<string>",
"output_compression": 123,
"partial_images": 123,
"extra": {}
}
'import requests
url = "https://ai.pmock.com/api/ai/v1/images/generations"
payload = {
"prompt": "<string>",
"model": "gpt-image-2",
"quality": "auto",
"size": "1024x1024",
"n": 123,
"user": "<string>",
"output_compression": 123,
"partial_images": 123,
"extra": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
model: 'gpt-image-2',
quality: 'auto',
size: '1024x1024',
n: 123,
user: '<string>',
output_compression: 123,
partial_images: 123,
extra: {}
})
};
fetch('https://ai.pmock.com/api/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://ai.pmock.com/api/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' => '<string>',
'model' => 'gpt-image-2',
'quality' => 'auto',
'size' => '1024x1024',
'n' => 123,
'user' => '<string>',
'output_compression' => 123,
'partial_images' => 123,
'extra' => [
]
]),
CURLOPT_HTTPHEADER => [
"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://ai.pmock.com/api/ai/v1/images/generations"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"gpt-image-2\",\n \"quality\": \"auto\",\n \"size\": \"1024x1024\",\n \"n\": 123,\n \"user\": \"<string>\",\n \"output_compression\": 123,\n \"partial_images\": 123,\n \"extra\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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://ai.pmock.com/api/ai/v1/images/generations")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"gpt-image-2\",\n \"quality\": \"auto\",\n \"size\": \"1024x1024\",\n \"n\": 123,\n \"user\": \"<string>\",\n \"output_compression\": 123,\n \"partial_images\": 123,\n \"extra\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://ai.pmock.com/api/ai/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"model\": \"gpt-image-2\",\n \"quality\": \"auto\",\n \"size\": \"1024x1024\",\n \"n\": 123,\n \"user\": \"<string>\",\n \"output_compression\": 123,\n \"partial_images\": 123,\n \"extra\": {}\n}"
response = http.request(request)
puts response.read_bodyCompatible
images generate
images generate
POST
/
ai
/
v1
/
images
/
generations
images generate
curl --request POST \
--url https://ai.pmock.com/api/ai/v1/images/generations \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"model": "gpt-image-2",
"quality": "auto",
"size": "1024x1024",
"n": 123,
"user": "<string>",
"output_compression": 123,
"partial_images": 123,
"extra": {}
}
'import requests
url = "https://ai.pmock.com/api/ai/v1/images/generations"
payload = {
"prompt": "<string>",
"model": "gpt-image-2",
"quality": "auto",
"size": "1024x1024",
"n": 123,
"user": "<string>",
"output_compression": 123,
"partial_images": 123,
"extra": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
model: 'gpt-image-2',
quality: 'auto',
size: '1024x1024',
n: 123,
user: '<string>',
output_compression: 123,
partial_images: 123,
extra: {}
})
};
fetch('https://ai.pmock.com/api/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://ai.pmock.com/api/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' => '<string>',
'model' => 'gpt-image-2',
'quality' => 'auto',
'size' => '1024x1024',
'n' => 123,
'user' => '<string>',
'output_compression' => 123,
'partial_images' => 123,
'extra' => [
]
]),
CURLOPT_HTTPHEADER => [
"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://ai.pmock.com/api/ai/v1/images/generations"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"gpt-image-2\",\n \"quality\": \"auto\",\n \"size\": \"1024x1024\",\n \"n\": 123,\n \"user\": \"<string>\",\n \"output_compression\": 123,\n \"partial_images\": 123,\n \"extra\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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://ai.pmock.com/api/ai/v1/images/generations")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"gpt-image-2\",\n \"quality\": \"auto\",\n \"size\": \"1024x1024\",\n \"n\": 123,\n \"user\": \"<string>\",\n \"output_compression\": 123,\n \"partial_images\": 123,\n \"extra\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://ai.pmock.com/api/ai/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"model\": \"gpt-image-2\",\n \"quality\": \"auto\",\n \"size\": \"1024x1024\",\n \"n\": 123,\n \"user\": \"<string>\",\n \"output_compression\": 123,\n \"partial_images\": 123,\n \"extra\": {}\n}"
response = http.request(request)
puts response.read_bodyBody
application/json
prompt
Minimum string length:
1model
Available options:
gpt-image-2 Minimum string length:
1quality grade
Available options:
auto, low, medium, high, standard image size, ① Single side ≤ 3840 px; ② Both width and height are multiples of 16; ③ Long side : short side ≤ 3:1; ④ Total pixels ∈ [655,360, 8,294,400]. Requests that do not meet the constraints or are not supported by the channel for custom sizes will be rejected
Available options:
auto, 1024x1024, 1024x1536, 1536x1024, 2048x2048, 2048x1152, 3840x2160, 2160x3840 Generation quantity (currently only supports 1)
background transparency
Available options:
transparent, opaque, auto Audit intensity
Available options:
auto, low user
Output file format
Available options:
png, jpeg, webp JPEG/WebP compression level 0-100
Response format (compatible with DALL · E; The gpt image series always returns b64_json)
Available options:
url, b64_json Input image fidelity (newly added in gpt-image-2, only effective for editing scenes); Generate can be ignored)
Available options:
high, low partial images
Show child attributes
Show child attributes
Response
200
OK
