Skip to main content
Create images from a text prompt using the native OpenAI-style API.

Basics

  • Endpoint: POST /v1/images/generations/
  • Host: https://tokensmind.ai
  • Auth: Bearer Token
  • Content-Type: application/json

Request body

FieldTypeRequiredDefaultDescription
modelstringNodall-e-2Model: dall-e-2, dall-e-3, or gpt-image-1.
promptstringYes-Text description. Up to 32k chars for GPT-image-1.
nintegerNo1Number of images (1–10). dall-e-3 only supports 1.
sizestringNo1024x1024Size. gpt-image-1: 1024x1024, 1536x1024, 1024x1536, or auto.
backgroundstringNoautoBackground transparency (gpt-image-1 only): transparent, opaque, or auto.
moderationstringNoautoModeration: low (fewer restrictions) or auto.
qualitystringNo-Quality (HD / standard).
stylestringNo-Style hint.

Response

200 OK
FieldTypeDescription
createdintegerUnix timestamp.
dataarrayImage objects.
└─ urlstringHosted image URL.
└─ b64_jsonstringBase64 image data.
usageobjectUsage stats.
└─ total_tokensintegerTotal tokens for this request.

Request example

{
  "model": "gpt-image-1",
  "prompt": "A cute baby sea otter",
  "n": 1,
  "size": "1024x1024",
  "background": "transparent"
}

Response example

{
  "created": 1713833628,
  "data": [
    {
      "url": "https://example.com/generated_image.png",
      "b64_json": ""
    }
  ],
  "usage": {
    "total_tokens": 100,
    "input_tokens": 50,
    "output_tokens": 50,
    "input_tokens_details": {
      "text_tokens": 10,
      "image_tokens": 40
    }
  }
}

Notes

  1. Transparency: When background is transparent, ensure the returned asset is PNG or WebP with an alpha channel.
  2. Model limits: DALL·E vs GPT-image differ on size and n; pick the model that matches your constraints.