Skip to main content

Generate image

POST 

/ai/generate-image

Generate an AI image from a text prompt. The image is stored in your media library and can be attached to posts via media_ids.

Requires the ai scope on your API key.

Copy media_ids straight into your post

The response contains a media_ids array (plural, single-element) — copy it directly into the media_ids field of POST /v1/posts with no transformation. The next_step field contains a human-readable instruction.

Available models:

ModelCreditsSpeedBest for
nano-banana-pro15~5sBest overall quality
ideogram-v28~5sText in images
gemini-3-pro5~8sSmart/contextual
flux-schnell1~2sFast drafts

Request Body Schema

POST /ai/generate-imageContent-Type: application/json

FieldTypeRequiredDescription
promptstringYesText description of the image to generate (max 2000 chars)
aspect_ratiostringNoOutput image aspect ratio. Default 1:1.
modelstringNoAI model to use. Default nano-banana-pro.

Supported aspect ratios

1:1, 16:9, 9:16, 4:3, 3:4, 4:5, 5:4

Request Example

{
"prompt": "A professional photo of a modern office workspace with natural lighting",
"aspect_ratio": "16:9",
"model": "nano-banana-pro"
}

Response Examples

201 — Image generated successfully

{
"data": {
"media_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"media_ids": ["a1b2c3d4-e5f6-7890-abcd-ef1234567890"],
"type": "image",
"width": 1920,
"height": 1080,
"aspect_ratio": "16:9",
"ai": {
"model": "nano-banana-pro",
"prompt": "A professional photo of a modern office workspace with natural lighting"
},
"credits_used": 15,
"credits_remaining": 485,
"created_at": "2026-04-10T12:00:00.000Z",
"next_step": "Image generated. Attach it to a post by passing \"media_ids\": [\"a1b2c3d4-e5f6-7890-abcd-ef1234567890\"] to POST /v1/posts."
},
"error": null,
"meta": {
"request_id": "a1b2c3d4",
"timestamp": "2026-04-10T12:00:00.000Z"
}
}

Response fields

FieldTypeDescription
media_idstring (UUID)The single UUID for the generated image
media_idsstring[] (UUID)Convenience single-element array — copy straight into POST /v1/posts
typestringAlways "image" for this endpoint
widthintegerImage pixel width
heightintegerImage pixel height
aspect_ratiostringAspect ratio of the generated image (matches request)
ai.modelstringAI model used for generation
ai.promptstringPrompt supplied in the request (echoed for round-trip convenience)
credits_usedintegerCredits consumed by this generation
credits_remainingintegerCredits remaining in your workspace after this generation
created_atstring (ISO 8601)UTC timestamp when the media record was created
next_stepstringHuman-readable instruction for attaching the image to a post

400 — Invalid prompt or parameters

{
"data": null,
"error": {
"message": "Invalid aspect ratio. Must be one of: 1:1, 16:9, 9:16, 4:3, 3:4, 4:5, 5:4",
"code": "validation_error"
},
"meta": {
"request_id": "e5f6g7h8",
"timestamp": "2026-04-10T12:00:00.000Z"
}
}

402 — Insufficient credits

{
"data": null,
"error": {
"message": "Not enough credits. This model costs 15 credits but you have 3 available.",
"code": "insufficient_credits",
"details": {
"credits_required": 15,
"credits_available": 3,
"model": "nano-banana-pro"
}
},
"meta": {
"request_id": "i9j0k1l2",
"timestamp": "2026-04-10T12:00:00.000Z"
}
}

Request

Responses

Image generated successfully