Skip to Content

Initiate AI Generation

POST https://embed-api.postnitro.ai/post/initiate/generate

Generates a carousel post using AI with predefined content generation presets.

Headers

  • Content-Type: application/json
  • embed-api-key: your-api-key-here (required)

Request Body

FieldTypeRequiredDescriptionAllowed Values
postTypestringYesType of post to generate"CAROUSEL", "IMAGE"
requestorIdstringNoCustom identifier for trackingAny string
templateIdstringYesID of the template to useValid template ID
brandIdstringYesID of the brand configurationValid brand ID
presetIdstringYesID of the AI configuration presetValid preset ID
responseTypestringNoOutput format (default: “DESIGN”)"DESIGN", "PDF", "PNG"
aiGenerationobjectYesAI generation configurationSee below
generateImagesobjectNoOpt-in AI image generation — generates images and bakes them into the design before renderingSee AI Image Generation

AI Generation Object

FieldTypeRequiredDescriptionAllowed Values
typestringYesType of AI generation"text", "article", "x"
contextstringYesContext/prompt for AI generationAny string
instructionsstringNoAdditional instructions for AIAny string

How type and context work together:

  • "text"context is a plain-text topic or prompt describing what to create (e.g. "Create a carousel about digital marketing tips")
  • "article"context is the URL of an article to turn into a carousel
  • "x"context is the URL of an X (Twitter) post to turn into a carousel

AI Image Generation

Add an optional generateImages object to have the API generate AI images and bake them into the design before it’s rendered. Its presence is the opt-in — omit the field and no images are generated (existing behavior). Works for both CAROUSEL and IMAGE posts and with every responseType (PDF, PNG, DESIGN).

FieldTypeRequiredDefaultAllowed Values
contextstringNoFalls back to aiGeneration.contextAny string — topic/brief that guides the image prompts
imagePlacementstringNo"auto""auto", "background", "in-line"
imageStrategystringNo"strategic""strategic", "all"

These are the only accepted fields — any other key inside generateImages returns a 422. Everything else the image service needs (editorType, image model, and the AI copy config) is resolved server-side: editorType from postType, the platform image model, and socialPlatform/tone/audience/language from your AI preset.

On direct REST calls, context is optional (it falls back as shown above). Over the MCP server and CLI, context is required — the AI agent composes it for the user. That is the only difference in how generateImages behaves across the two.

imagePlacement

ValueBehavior
autoAI decides per slide whether an image is a background or placed in-line with the content.
backgroundImages are generated for slide backgrounds.
in-lineImages are generated to sit inside the slide content, alongside the text.

imageStrategy

ValueBehavior
strategicThe AI picks which slides get images, capped at ~50% of slides for a balanced look.
allEvery eligible slide gets an image, capped only by available credits.

Behavior & limits:

  • Image generation runs after the design is created and before rendering, so a rendered PDF/PNG already contains the images and a DESIGN response has them baked into the saved design (visible via editorUrl). The output shape is unchanged — no new fields.
  • Best-effort: if generation fails or isn’t permitted, the post still completes without images. A GENERATE_IMAGES step appears in the status logs — COMPLETED on success, FAILED (with a skip reason) otherwise.
  • Free plan: AI image generation is not available — the step is skipped (logged as failed) and the post completes without images.
  • Credits: the post’s reported credits (slide-based) are unchanged. AI images bill against the organization’s separate AI-image quota.
  • Image generation adds latency — keep polling status until COMPLETED.

On generate, context plus socialPlatform/tone/audience/language are taken from the request/preset, so generateImages can be as small as { "imagePlacement": "auto" } — or {} to accept all defaults.

Example Request

curl --location 'https://embed-api.postnitro.ai/post/initiate/generate' \ --header 'Content-Type: application/json' \ --header 'embed-api-key: pn-your-api-key' \ --data '{ "postType": "CAROUSEL", "requestorId": "user123", "templateId": "xtrnxgfgk9a08tmsz2601k1c", "brandId": "cmdhb8oe10006v0pmh6a4no6t", "presetId": "preset123", "responseType": "PNG", "aiGeneration": { "type": "text", "context": "Create a carousel about digital marketing tips", "instructions": "Focus on actionable tips for small businesses" } }'

Example Request (with AI image generation)

curl --location 'https://embed-api.postnitro.ai/post/initiate/generate' \ --header 'Content-Type: application/json' \ --header 'embed-api-key: pn-your-api-key' \ --data '{ "postType": "CAROUSEL", "requestorId": "user123", "templateId": "xtrnxgfgk9a08tmsz2601k1c", "brandId": "cmdhb8oe10006v0pmh6a4no6t", "presetId": "preset123", "responseType": "DESIGN", "aiGeneration": { "type": "text", "context": "How our scheduling feature saves marketers time" }, "generateImages": { "imagePlacement": "auto", "imageStrategy": "all" } }'

Response

{ "success": true, "message": "CAROUSEL generation initiated", "data": { "embedPostId": "post123", "status": "PENDING" } }

Generation is asynchronous. This endpoint returns immediately with an embedPostId while the carousel is generated in the background. Poll Check Post Status with the embedPostId until the status is COMPLETED, then call Get Post Output to retrieve the final files.

Last updated on