GPT Image
curl --request POST \
--url https://api.mixroute.ai/v1/images/generationsimport requests
url = "https://api.mixroute.ai/v1/images/generations"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.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.mixroute.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://api.mixroute.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://api.mixroute.ai/v1/images/generations")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.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_bodyImage Series
GPT Image
GPT Image image generation fields, model constraints, and request examples.
GPT Image
curl --request POST \
--url https://api.mixroute.ai/v1/images/generationsimport requests
url = "https://api.mixroute.ai/v1/images/generations"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.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.mixroute.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://api.mixroute.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://api.mixroute.ai/v1/images/generations")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.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_bodyGenerate images from text using the OpenAI Images request format for GPT Image models.
GPT Image 2 resolutions above 3686400 total pixels are experimental. These GPT models return Base64 image data; do not send DALL-E-specific
POST https://api.mixroute.ai/v1/images/generations
Models
| Model ID | Capabilities and Limits |
|---|---|
gpt-image-2 | Generation and editing; flexible sizes; fixed high input fidelity. |
gpt-image-1.5 | Generation and editing; standard image sizes. |
gpt-image-1 | Generation and editing; standard image sizes. |
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Complete model ID from the table above. Set it explicitly for routing. |
prompt | string | Yes | Description of the desired output or edit, at most 32000 characters. |
n | integer | No | Number of output images, 1-10; default 1. |
size | string | No | Output dimensions, or auto (default). See the model-specific size rules below. |
quality | string | No | low, medium, high, or auto (default). |
background | string | No | auto (default), opaque, or transparent. Transparency requires PNG or WebP; support on GPT Image 2 is in preview. |
moderation | string | No | auto (default) or low, controlling the model content-filtering level. |
output_format | string | No | Encoded image format: png (default), jpeg, or webp. |
output_compression | integer | No | Compression setting from 0 to 100, default 100. Only applies to JPEG or WebP output. |
stream | boolean | No | Return server-sent events when true; default false. |
partial_images | integer | No | Streaming-only partial-image count, 0-3. With 0, the final image is sent without intermediate images; fewer partial images may arrive if generation finishes early. |
user | string | No | Stable identifier for the end user, used for abuse monitoring. Avoid raw personal information. |
Size Rules
| Model | Allowed Sizes |
|---|---|
| GPT Image 1 / 1.5 | auto, 1024x1024, 1536x1024, 1024x1536 |
| GPT Image 2 | auto or WIDTHxHEIGHT. Both edges must be divisible by 16; each edge is at most 3840 px; long/short ratio at most 3:1; total pixels 655360-8294400. |
response_format or style.
Examples
Use your MixRoute key in theMIXROUTE_API_KEY environment variable. Requests use Authorization: Bearer .... Replace source-image placeholders with accessible images or local files before editing.
curl --request POST "https://api.mixroute.ai/v1/images/generations" \
--header "Authorization: Bearer $MIXROUTE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "gpt-image-2",
"prompt": "A clean product photograph of a red ceramic mug on a white background.",
"size": "1024x1024",
"quality": "low",
"n": 1,
"output_format": "png"
}'
Python
import json
import os
import requests
payload = json.loads(r'''
{
"model": "gpt-image-2",
"prompt": "A clean product photograph of a red ceramic mug on a white background.",
"size": "1024x1024",
"quality": "low",
"n": 1,
"output_format": "png"
}
''')
response = requests.post(
"https://api.mixroute.ai/v1/images/generations",
headers={"Authorization": "Bearer " + os.environ["MIXROUTE_API_KEY"]},
json=payload,
timeout=180,
)
response.raise_for_status()
result = response.json()
import base64
from pathlib import Path
for index, item in enumerate(result["data"]):
Path(f"image_{index}.png").write_bytes(base64.b64decode(item["b64_json"]))
Response
Read each image fromdata[].b64_json and decode it using the requested output_format. Streaming returns partial/completed image events; use the final completed event for the final file.
GPT Image editing