
Comic API Documentation
Integrate professional comic generation capabilities into your applications.
How the Comic API works
Three quick onboarding illustrations: prepare the input, send the request, review the result.



REST + MCP
API de cómics
Use the Comic API to turn prompts, customer uploads, character references, and story briefs into structured comic pages with generated panel assets.
Autenticación
Send your API key with HTTP Bearer Auth on every request.
1Authorization: Bearer $LLAMAGEN_API_KEYBase URL
All production REST endpoints use the same API host. MCP clients can connect from the docs workflow.
1https://api.llamagen.aiEndpoints
Create generation
POST /v1/comics/generationsSubmit prompt, role references, scene references, layout options, and webhook configuration.
Get status
GET /v1/comics/generations/{generationId}Poll status, generated assets, panel metadata, and failure details for a generation.
Continue write
POST /v1/comics/generations/{generationId}/continue-writeExtend an existing story or multi-page generation while preserving established characters and settings.
Update panel
PATCH /v1/comics/generations/{generationId}/panels/{panelId}Regenerate one panel with revised direction while keeping the surrounding comic structure intact.
Create request
Provide either prompt or promptUrl, then layer in optional style, size, character, scene, attachment, language, and webhook fields.
1curl -X POST https://api.llamagen.ai/v1/comics/generations \
2 -H "Authorization: Bearer $LLAMAGEN_API_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "prompt": "A 4-panel comic about Leo finding a glowing key in a quiet library.",
6 "size": "1024x1024",
7 "fixPanelNum": 4,
8 "callbackUrl": "https://example.com/webhooks/comic"
9 }'1{
2 "id": "gen_123456789",
3 "status": "PROCESSED",
4 "prompt": "A 4-panel comic about Leo finding a glowing key in a quiet library.",
5 "page": 0,
6 "panel": 2,
7 "pagePrompt": "Leo opens the glowing bookcase door.",
8 "layout": "Layout0",
9 "data": {
10 "assetUrl": "https://cdn.llamagen.ai/comics/panel-2.webp",
11 "panel": 2,
12 "caption": "",
13 "image": []
14 }
15}Input schema
Requerido: Yes, unless promptUrl is provided
Story, scene, or script instructions for the comic generation. Use natural language and include panel-by-panel direction when you need tighter control.
- Requerido
- prompt or promptUrl
Ejemplo: A 4-panel comic strip about The Little Prince meeting the Fox.
Requerido: Yes, unless prompt is provided
Uploaded prompt document or image URL. Send this when the prompt should be read from an uploaded file instead of plain text.
- Requerido
- prompt or promptUrl
- Format
- uri
Ejemplo: https://s.llamagen.ai/workspace/storyboard.png
Requerido: No
Optional generation model override. When omitted, the API selects the best available model for the request and account.
- Default
- "auto"
Ejemplo: auto
Requerido: No
Style preset id. Use template ids from the preset catalog to control manga, comic, cartoon, or illustration style.
- Default
- "neutral"
Ejemplo: neutral
Requerido: No
Output canvas size. Must be one of the supported size values listed in the Supported sizes table below.
- Default
- "1024x1024"
- Enum
- 1024x1024 (1:1), 512x768 (2:3), 512x1024 (1:2), 576x1024 (9:16), 768x1024 (3:4), 1024x768 (4:3), 768x512 (3:2), 1024x576 (16:9), 1024x512 (2:1)
Ejemplo: 1024x1024
Requerido: No
Single-page panel count from 1 to 20. Do not send this field together with pagination.
- Default
- 4
- Minimum
- 1
- Maximum
- 20
Ejemplo: 4
Requerido: No
Multi-page mode. Use pagination.totalPages and pagination.panelsPerPage when you want several pages in one request.
- Conflicts
- fixPanelNum
Ejemplo: { "totalPages": 2, "panelsPerPage": 4 }
Requerido: No
Character references used for identity consistency across panels and pages. Each role can include a name, demographics, clothing, and image URL.
- Default
- []
Ejemplo: [{ "name": "Alice", "age": 12, "gender": "female" }]
Requerido: No
Scene or background references used to keep environments consistent. Each location should have a stable name and can include an image URL.
- Default
- []
Ejemplo: [{ "name": "Dreamwood Forest", "image": "https://..." }]
Requerido: No
Lightweight character reference list for uploaded images, model ids, or reusable assets.
Ejemplo: [{ "name": "Leo", "imageUrl": "https://..." }]
Requerido: No
Additional source files for product images, brand assets, rough sketches, or client references.
- Default
- []
Ejemplo: [{ "type": "image", "url": "https://..." }]
Requerido: No
Webhook endpoint that receives status and asset updates when the job changes state or completes.
- Format
- uri
Ejemplo: https://example.com/webhooks/comic
Requerido: No
Shared secret used to sign webhook payloads. Keep it private and rotate it when needed.
Ejemplo: whsec_live_123
Requerido: No
Preferred language for generated captions, dialogue, and lettering.
- Default
- "auto"
Ejemplo: en
Requerido: No
Whether to run the final panel assets through upscaling.
- Default
- false
Ejemplo: true
Nested objects
Requerido: Required when pagination is used
Number of comic pages to generate.
- Minimum
- 1
- Maximum
- 20
Ejemplo: 2
Requerido: Required when pagination is used
Panels per generated page. Send one number for every page or an array when each page needs a different count.
Ejemplo: [4, 6]
Requerido: Recomendado
Stable character name used by the model and returned panel metadata.
Ejemplo: Alice
Requerido: No
Reference image for character identity, costume, and visual continuity.
Ejemplo: https://cdn.example.com/alice.png
Requerido: Recomendado
Reusable location name for visual continuity across pages and panels.
Ejemplo: Dreamwood Forest
Requerido: Required when attachments are used
Attachment role. Use product for ecommerce source imagery, sketch for layout direction, and image for visual reference.
Ejemplo: product
Requerido: Required when attachments are used
Publicly accessible or signed file URL.
Ejemplo: https://cdn.example.com/reference.png
Supported sizes
Supported size values for Comic API requests: 1024x1024 (1:1), 512x768 (2:3), 512x1024 (1:2), 576x1024 (9:16), 768x1024 (3:4), 1024x768 (4:3), 768x512 (3:2), 1024x576 (16:9), 1024x512 (2:1)
Square format for covers, profile-style art, and balanced compositions.
- Width
- 1024
- Height
- 1024
Portrait format for posters, character art, and book-style layouts.
- Width
- 512
- Height
- 768
Tall vertical format for narrow posters and mobile-first scenes.
- Width
- 512
- Height
- 1024
Vertical video-style format for reels, stories, and phone screens.
- Width
- 576
- Height
- 1024
Classic portrait format for comic covers and character-focused shots.
- Width
- 768
- Height
- 1024
Traditional landscape format for scenes, dialogue panels, and illustrations.
- Width
- 1024
- Height
- 768
Cinematic landscape format for environment shots and wider panels.
- Width
- 768
- Height
- 512
Widescreen format for trailers, hero banners, and dramatic shots.
- Width
- 1024
- Height
- 576
Ultra-wide banner format for panoramic scenes and headers.
- Width
- 1024
- Height
- 512
Output schema
Generation id. Store this value for polling, logs, and support.
Ejemplo: gen_123456789
Current job state. Typical values include QUEUED, PROCESSING, PROCESSED, FAILED, and CANCELLED.
Ejemplo: PROCESSED
Normalized prompt used by the generation.
Zero-based page index for the returned panel asset.
Ejemplo: 0
Panel index inside the returned page.
Ejemplo: 2
Panel-level or page-level prompt used for the returned asset. Useful for review, debugging, and regeneration.
Resolved layout template id.
Ejemplo: Layout0
Generated panel or page asset URL.
Ejemplo: https://cdn.llamagen.ai/comics/panel-2.webp
Generated or supplied caption for the panel.
Error code, message, and details when a request fails validation or generation.
Operations
Get status
Poll generation state until the job is processed, failed, or cancelled.
1curl https://api.llamagen.ai/v1/comics/generations/gen_123456789 \
2 -H "Authorization: Bearer $LLAMAGEN_API_KEY"Update a panel
Regenerate a single panel after review without rebuilding the full comic.
1curl -X PATCH https://api.llamagen.ai/v1/comics/generations/gen_123456789/panels/2 \
2 -H "Authorization: Bearer $LLAMAGEN_API_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "prompt": "Make Leo look more hopeful and keep the same orange wizard robe."
6 }'Webhooks
Use callbackUrl to receive status and generated asset updates. Verify signatures with webhookSecret before accepting the payload.
1{
2 "event": "comic.generation.completed",
3 "generationId": "gen_123456789",
4 "status": "PROCESSED",
5 "assetUrl": "https://cdn.llamagen.ai/comics/page-0.webp",
6 "createdAt": "2026-06-03T10:30:00.000Z"
7}Errors
Validation errors return an error code, message, and field-level details when available.
1{
2 "error": {
3 "code": "invalid_request",
4 "message": "Provide either prompt or promptUrl.",
5 "details": {
6 "field": "prompt"
7 }
8 }
9}Need MCP setup, SDK examples, or rate limit details? Open the full docs
MCP Usage
Connect via Streamable HTTP
Authorization: Bearer YOUR_API_TOKENConfigure your MCP client to use Streamable HTTP transport with the endpoint above. Provide your API token via the Authorization header.
Available Tools
- create_comic_generation— Create a generation job
- get_comic_generation_status— Get status/result by id
- get_api_usage— View current usage and quota
Client Configuration Example
Many MCP clients allow setting a remote HTTP endpoint with custom headers. Below is a generic example:
{
"mcpServers": {
"llamagen": {
"url": "https://llamagen.ai/api/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}The exact configuration format varies by client. Ensure the Authorization header is set with your token.
Cursor Setup
- Open Cursor Settings and find the Model Context Protocol (MCP) section.
- Add a new server using Streamable HTTP.
- Set URL to https://llamagen.ai/api/mcp.
- Under Headers, add Authorization: Bearer YOUR_API_TOKEN.
- Save and test by listing tools; you should see create_comic_generation, get_comic_generation_status, get_api_usage.
Alternatively, you can configure via Cursor's MCP configuration file using the same JSON structure as above, if your version supports it.
Integration Demos
LangChain JS Agent (Streamable HTTP + Azure OpenAI)
import "dotenv/config";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
import { createAgent } from "langchain";
import { DynamicStructuredTool } from "@langchain/core/tools";
import { AzureChatOpenAI } from "@langchain/openai";
async function main() {
const mcpUrl = "https://llamagen.ai/api/mcp";
const YOUR_API_TOKEN = process.env.LLAMAGENAI_API_TOKEN;
const client = new Client(
{ name: "demo-agent", version: "1.0.0" },
{ capabilities: { tools: {} } }
);
let connected = false;
let discoveredTools: any | null = null;
if (mcpUrl && YOUR_API_TOKEN) {
const headers = {
Authorization: "Bearer " + YOUR_API_TOKEN,
Accept: "application/json",
};
const transport = new StreamableHTTPClientTransport(new URL(mcpUrl), {
requestInit: { headers },
});
await client.connect(transport);
discoveredTools = await client.listTools();
connected = true;
}
let tools: any[] = [];
if (connected && discoveredTools) {
tools = discoveredTools.tools.map((tool: any) => {
return new DynamicStructuredTool({
name: tool.name,
description: tool.description ?? "",
schema: tool.inputSchema,
func: async (input: Record<string, any>) => {
const result = await client.callTool({
name: tool.name,
arguments: input,
});
return JSON.stringify(result);
},
});
});
}
console.log("Loaded " + tools.length + " tools");
const AZURE_OPENAI_DEPLOYMENT_NAME = process.env.AZURE_OPENAI_DEPLOYMENT_NAME;
const AZURE_OPENAI_API_KEY = process.env.AZURE_OPENAI_API_KEY;
const AZURE_OPENAI_API_VERSION = process.env.AZURE_OPENAI_API_VERSION;
const AZURE_OPENAI_ENDPOINT = process.env.AZURE_OPENAI_ENDPOINT;
const llm = new AzureChatOpenAI({
model: AZURE_OPENAI_DEPLOYMENT_NAME,
azureOpenAIApiKey: AZURE_OPENAI_API_KEY,
azureOpenAIApiInstanceName: AZURE_OPENAI_DEPLOYMENT_NAME,
azureOpenAIApiDeploymentName: AZURE_OPENAI_DEPLOYMENT_NAME,
azureOpenAIApiVersion: AZURE_OPENAI_API_VERSION,
azureOpenAIEndpoint: AZURE_OPENAI_ENDPOINT,
});
const agent = createAgent({
model: llm,
tools,
});
const result = await agent.invoke({
messages: [
{
role: "user",
content: "Query the current usage and quota for the llamagen project",
},
],
});
console.log(result);
const result1 = await agent.invoke({
messages: [
{
role: "user",
content: "Create a comic of a little girl running in a forest",
},
],
});
console.log(result1);
}
main().catch((err) => {
console.error(err);
process.exit(1);
});SDK Quick Start
Install the SDK first, then create a generation job and wait for the final result in two clear steps.
Install
npm i comicStep 1: Create generation
1import { LlamaGenClient } from 'comic';
2
3const llamagen = new LlamaGenClient({
4 apiKey: process.env.LLAMAGEN_API_KEY!,
5});
6
7const created = await llamagen.comic.create({
8 prompt: 'A detective fox in Tokyo',
9 size: '1024x1024'
10});Step 2: Wait for completion
1const result = await llamagen.comic.waitForCompletion(created.id);
2
3console.log(result);Supported size values: 1024x1024 (1:1), 512x768 (2:3), 512x1024 (1:2), 576x1024 (9:16), 768x1024 (3:4), 1024x768 (4:3), 768x512 (3:2), 1024x576 (16:9), 1024x512 (2:1)
TypeScript Types
The SDK ships with first-class TypeScript types for request payloads and responses.
1import type {
2 CreateComicParams,
3 ComicArtworkResponse,
4 ComicGenerationStatus
5} from 'comic';
6
7const payload: CreateComicParams = {
8 prompt: 'A superhero cat saving a city',
9 preset: 'render',
10 size: '1024x1024'
11};Valid size values: 1024x1024 (1:1), 512x768 (2:3), 512x1024 (1:2), 576x1024 (9:16), 768x1024 (3:4), 1024x768 (4:3), 768x512 (3:2), 1024x576 (16:9), 1024x512 (2:1)
Status Lifecycle
| Status | Meaning |
|---|---|
| LOADING | Request accepted or generation is still running. |
| PROCESSED | Generation completed successfully. |
| FAILED | Generation failed. Inspect error details. |
Recommended: poll every 3-5 seconds with timeout protection and exponential retry for transient failures.
Webhooks
Manage webhook endpoints in Settings → API → Webhooks. You can subscribe to create, update, completed, and failed events for comic generations.
Supported Events
comic.generation.created— Fires after a generation request is accepted.comic.generation.updated— Fires after continue-write or single-panel regenerate is queued.comic.generation.completed— Fires when the generation reaches a processed state.comic.generation.failed— Fires when the generation ends in a failed state.
Signing Headers
X-Llama-Webhook-Id: evt_...
X-Llama-Webhook-Timestamp: 1715510400
X-Llama-Webhook-Signature: v1=...
X-Llama-Webhook-Request-Id: req_...Compute the signature from ${timestamp}.${rawBody} using your webhook secret. The dashboard only shows the secret once when creating or rotating it.
Request Logs
In dashboard settings, use Request Logs to trace endpoint usage, status codes, latency, and credit changes for each API call.
Rate Limits
Demo Users
- 4 requests per minute
- 15 requests per day
- Watermarked outputs
Paid Plans
- 10 requests per minute
- Usage based on credits
- High-resolution, no watermark
Errors
| Code | Description |
|---|---|
| 401 | Unauthorized - Invalid API token. |
| 402 | Payment Required - Insufficient credits. |
| 403 | Forbidden - Access denied. |
| 429 | Too Many Requests - Rate limit exceeded. |
| 500 | Internal Server Error. |