Generate an image with AI and store it in the media library
POST/ai/generate-image
Generates one image via FAL AI, stores it in the media library and
returns a ready media_id for createPost. Credit cost depends on
the model; credits are reserved atomically and refunded on failure.
Free-trial organizations without a paid subscription get
402 upgrade_required. Prompts are safety-filtered
(400 prompt_rejected). Additional AI burst limits apply on top of
the API-key limit. Error codes: validation_error, prompt_rejected,
upgrade_required, insufficient_credits, rate_limit_exceeded,
generation_failed, internal_error.
Request
Responses
- 201
- 400
- 401
- 402
- 403
- 429
- 500
Image generated and stored
Validation error — see error.code and error.details
Missing/invalid/revoked/expired API key (codes invalid_api_key, api_key_revoked, api_key_expired, api_key_required, auth_failed). Auth-layer 401s omit error.retryable and meta.request_id.
No active subscription (code subscription_required — the error object also carries subscription_status), or insufficient AI credits (insufficient_credits) / paid plan required (upgrade_required).
API key missing the required scope (insufficient_scope), storage quota exceeded (storage_quota_exceeded), or account limit reached (account_limit_reached)
Rate limit exceeded (rate_limit_exceeded, or plan budgets post_limit_reached / daily_limit_reached on schedulePost). All 429s carry Retry-After. The API-key limiter additionally sets the X-RateLimit-* headers and error.details {limit, remaining, reset_at}.
Response Headers
Seconds to wait before retrying
Requests allowed in the window (API-key limiter only)
Requests remaining (API-key limiter only)
Unix seconds when the window resets (API-key limiter only)
Internal error (internal_error and endpoint-specific 5xx codes). Retryable.