Skip to content

Synchronous generation

POST https://api.yexapi.com/v1/images/generations

This endpoint follows the OpenAI Images API. The request stays open until the image is ready and then returns the result, typically in 30–60 seconds (4K images take longer). The server waits for up to 10 minutes.

Request body

Parameter Type Required Description
model string yes gpt-image-2
prompt string yes Text description of the image, up to 32,000 characters.
size string no WIDTHxHEIGHT (e.g. 1024x1024), an aspect ratio (e.g. 16:9) or auto. Default auto. See Size & output pixels.
resolution string no 1k, 2k or 4k. Overrides the tier derived from size. Default 1k.
n integer no Number of images. Only 1 is supported. See Number of images.
response_format string no url (default) or b64_json. With b64_json the response contains both the Base64 data and the URL.
image string or string[] no Public http(s) URLs of reference images (up to 14). See Image edits.
background string no transparent for a transparent background.

Other OpenAI parameters such as quality, style, user, moderation or output_format are accepted and ignored. Images are returned as PNG. Streaming (stream: true) and mask are not supported.

Response

{
  "created": 1796107749,
  "data": [
    { "url": "https://api.yexapi.com/v1/images/files/01M8R5TJAX8YKP68Y851BY595Y/1796107779_9dae96fa.png" }
  ]
}

Image links stay available for 30 days.

Examples

curl https://api.yexapi.com/v1/images/generations \
  -H "Authorization: Bearer $YEXAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A watercolor map of an imaginary island",
    "size": "16:9",
    "resolution": "2k"
  }'
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["YEXAPI_API_KEY"],
    base_url="https://api.yexapi.com/v1",
)

result = client.images.generate(
    model="gpt-image-2",
    prompt="A watercolor map of an imaginary island",
    size="16:9",
    extra_body={"resolution": "2k"},  # parameters outside the OpenAI schema go in extra_body
)
print(result.data[0].url)
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.YEXAPI_API_KEY,
  baseURL: "https://api.yexapi.com/v1",
});

const result = await client.images.generate({
  model: "gpt-image-2",
  prompt: "A watercolor map of an imaginary island",
  size: "16:9",
  resolution: "2k", // extra fields are sent as-is
});
console.log(result.data[0].url);

Timeouts

Set your HTTP client timeout to at least 120 seconds (300 seconds for 4K). The OpenAI SDKs default to 10 minutes, which is fine.

If generation takes longer than the server's 10-minute wait, the request returns 504 while the job keeps running, and a job that finishes is billed. For long or high-resolution jobs, prefer the async endpoint.