PortModels
Log in

Image generation

Generating images through the OpenAI-compatible images endpoint.

text
POST /openai/v1/images/generations

Request#

bash
curl https://api.portmodels.com/openai/v1/images/generations \
  -H "Authorization: Bearer $PORTMODELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A lighthouse at dusk, long exposure",
    "model": "dall-e-3",
    "n": 1,
    "size": "1024x1024"
  }'
FieldRequiredNotes
promptyesWhat to generate
modelnoDefaults to dall-e-3
nnoNumber of images
sizenoProvider-supported dimensions, e.g. 1024x1024

Response#

json
{
  "created": 1771200000,
  "data": [
    { "url": "https://...", "revised_prompt": "..." }
  ],
  "usage": { "cost": 0.04 }
}

Providers return either a url or a b64_json payload per image; whichever the provider sent is what you get, alongside revised_prompt when the provider supplies one.

usage.cost is the credit cost of the generation, markup included.

Notes#

  • Image pricing is per image and varies sharply between models. Check the cost of one generation before you loop.
  • Hosted image URLs from providers are usually short-lived. If the user needs to keep an image, download it and store it with file storage rather than saving the URL.
  • The prompt field is required; a request without it returns 400.