Skip to content

Image Generation API

Generate an image and save it to the unified assets system in a single request.

POST /api/images/generate

The endpoint is guarded by an agent API key. AI agents call it with their organisation’s agent API key sent as the X-Agent-Api-Key header.

FieldTypeRequiredDescription
organizationIdstringYesMust match the agent API key’s organisation.
promptstringYesImage description.
fileNamestringYesName for the saved file; include .jpg or .png.
jobIdstringOne of jobId/requestIdAssociates the asset with a job.
requestIdstringOne of jobId/requestIdAlternative association identifier.
descriptionstringNoDescription stored on the asset.
modelstringNoDefaults to fal-ai/nano-banana.
numImagesnumberNo1–10, defaults to 1.
outputFormatstringNojpeg or png, defaults to jpeg.
aspectRatiostringNoDefaults to 1:1.
metadataobjectNoAdditional metadata stored on the asset.
createdByAgentTypestringNoAgent type for tracking; defaults to ai-agent.
Terminal window
curl -X POST https://api.runnit.io/api/images/generate \
-H "Content-Type: application/json" \
-H "X-Agent-Api-Key: <your-agent-api-key>" \
-d '{
"organizationId": "your-org-id",
"jobId": "your-job-id",
"prompt": "Detailed image description",
"fileName": "my_image.jpg",
"description": "Description for the asset",
"aspectRatio": "16:9",
"outputFormat": "jpeg",
"createdByAgentType": "copywriter"
}'
{
"success": true,
"message": "Images generated and saved successfully",
"assets": [
{
"id": "asset-uuid",
"fileName": "my_image.jpg",
"fileType": "image",
"mimeType": "image/jpeg",
"fileSize": 125432,
"description": "AI-generated image",
"createdAt": "2025-10-08T12:00:00Z"
}
],
"generationInfo": {
"model": "fal-ai/nano-banana",
"prompt": "...",
"aspectRatio": "16:9",
"outputFormat": "jpeg"
}
}
  • The response returns saved asset metadata (assets[] + generationInfo); it does not return image URLs or base64 content.
  • Provide either jobId or requestId: one is required so the asset can be associated correctly.
  • For a task-oriented walkthrough, see the Image Generation guide.