Skip to content

Images

Generate images from text prompts.

Available image models depend on the model permissions assigned to the virtual API key, for example:

  • gpt-image-1.5
  • gpt-image-2

Endpoint

http
POST https://api.nexusmodels.cn/v1/images/generations

Headers

http
Authorization: Bearer YOUR_NEXUSMODELS_API_KEY
Content-Type: application/json

Request parameters

ParameterTypeRequiredDescription
modelstringYesImage generation model name
promptstringYesDescription of the image to generate
nintegerNoNumber of images to generate
sizestringNoImage size supported by the model
qualitystringNoImage quality supported by the model
backgroundstringNoBackground type, such as transparent or opaque
output_formatstringNoOutput format, such as png or jpeg
response_formatstringNoURL or Base64 response, depending on model support
userstringNoEnd-user identifier

Example

bash
curl -sS -X POST \
  'https://api.nexusmodels.cn/v1/images/generations' \
  -H 'Authorization: Bearer YOUR_NEXUSMODELS_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gpt-image-1.5",
    "prompt": "An artificial intelligence research center in a futuristic city, modern architecture and blue lighting",
    "size": "1024x1024",
    "quality": "high",
    "n": 1
  }'

URL response example

json
{
  "created": 1788163200,
  "data": [
    {
      "url": "https://example.com/generated-image.png"
    }
  ]
}

Base64 response example

Some models return Base64 image data directly:

json
{
  "created": 1788163200,
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAA..."
    }
  ]
}

Save a Base64 image

Assuming the API response is saved as response.json:

bash
jq -r '.data[0].b64_json' response.json \
  | base64 --decode \
  > generated-image.png

On macOS:

bash
jq -r '.data[0].b64_json' response.json \
  | base64 -D \
  > generated-image.png