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.5gpt-image-2
Endpoint
http
POST https://api.nexusmodels.cn/v1/images/generationsHeaders
http
Authorization: Bearer YOUR_NEXUSMODELS_API_KEY
Content-Type: application/jsonRequest parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Image generation model name |
prompt | string | Yes | Description of the image to generate |
n | integer | No | Number of images to generate |
size | string | No | Image size supported by the model |
quality | string | No | Image quality supported by the model |
background | string | No | Background type, such as transparent or opaque |
output_format | string | No | Output format, such as png or jpeg |
response_format | string | No | URL or Base64 response, depending on model support |
user | string | No | End-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.pngOn macOS:
bash
jq -r '.data[0].b64_json' response.json \
| base64 -D \
> generated-image.png