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.

Step 01
Prompt + token
Colorful hand-drawn comic API onboarding illustration showing a prompt sheet and API token note.
Step 02
Send request
Colorful hand-drawn comic API onboarding illustration showing a request moving into the API workspace.
Step 03
Review panels
Colorful hand-drawn comic API onboarding illustration showing finished panels being reviewed before export.

REST + MCP

API tal-Kummiks

Use the Comic API to turn prompts, customer uploads, character references, and story briefs into structured comic pages with generated panel assets.

Awtentikazzjoni

Send your API key with HTTP Bearer Auth on every request.

1Authorization: Bearer $LLAMAGEN_API_KEY

Base URL

All production REST endpoints use the same API host. MCP clients can connect from the docs workflow.

1https://api.llamagen.ai

Endpoints

Create generation

POST /v1/comics/generations

Submit prompt, role references, scene references, layout options, language, upscale, and attachments.

Ġenerazzjoni tal-vidjo

POST /v1/comics/generations

Submit a video generation request through the same endpoint by setting agentType to videoModel and passing videoOptions.

Get status

GET /v1/comics/generations/{generationId}

Poll status, generated assets, panel metadata, and failure details for a generation.

Continue write

PATCH /v1/comics/generations/{generationId}

Extend an existing story or multi-page generation while preserving established characters and settings.

Update panel

PATCH /v1/comics/generations/{generationId}

Regenerate one panel with revised direction while keeping the surrounding comic structure intact.

Create request

Provide prompt text, then layer in optional style, size, character, scene, attachment, language, and upscale 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": 48  }'
1{2  "id": "cmqyt8ea60003lb04uvxug8i9",3  "status": "LOADING",4  "prompt": "A 4-panel comic about Leo finding a glowing key in a quiet library.",5  "usage": {6    "total_comics": 4,7    "amount": 6008  },9  "model": "cyani-model"10}

Input schema

promptstring

Meħtieġ: Yes

Story, scene, or script instructions for the comic generation. Use natural language and include panel-by-panel direction when you need tighter control.

Meħtieġ
prompt

Eżempju: A 4-panel comic strip about The Little Prince meeting the Fox.

promptUrlstring URL

Meħtieġ: No

Optional source file URL or id stored with the generation. The request still needs prompt text.

Format
uri

Eżempju: https://s.llamagen.ai/workspace/storyboard.png

modelstring

Meħtieġ: No

Optional compatibility field returned in the create response. The backend selects the actual generation model from account configuration.

Default
"cyani-model"

Eżempju: cyani-model

presetstring

Meħtieġ: No

Style preset id. Use template ids from the preset catalog to control manga, comic, cartoon, or illustration style.

Default
"neutral"

Eżempju: neutral

sizestring

Meħtieġ: No

Output canvas size in WIDTHxHEIGHT format. Common presets are listed in this field metadata.

Default
"1024x1024"
Presets
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)

Eżempju: 1024x1024

fixPanelNuminteger

Meħtieġ: No

Single-page panel count from 1 to 20. Do not send this field together with pagination.

Default
4
Minimum
1
Maximum
20

Eżempju: 4

paginationobject

Meħtieġ: No

Multi-page mode. Use pagination.totalPages and pagination.panelsPerPage when you want several pages in one request. Do not use top-level totalPages or panelsPerPage.

Conflicts
fixPanelNum

Eżempju: { "totalPages": 2, "panelsPerPage": 4 }

comicRolesArray<Role> | JSON string

Meħtieġ: No

Character references used for identity consistency across panels and pages. Each role can include a name, demographics, clothing, and image URL.

Default
[]

Eżempju: [{ "name": "Alice", "age": 12, "gender": "female" }]

comicLocationsArray<Location> | JSON string

Meħtieġ: No

Scene or background references used to keep environments consistent. Each location should have a stable name and can include an image URL.

Default
[]

Eżempju: [{ "name": "Dreamwood Forest", "image": "https://..." }]

attachmentsArray<Attachment> | JSON string

Meħtieġ: No

Additional source files for product images, brand assets, rough sketches, or client references.

Default
[]

Eżempju: [{ "type": "image", "url": "https://..." }]

languagestring

Meħtieġ: No

Preferred language for generated captions, dialogue, and lettering.

Default
"auto"

Eżempju: en

upscale"" | "2K" | "4K"

Meħtieġ: No

Optional upscale target. 2K costs 2x credits and 4K costs 4x credits.

Default
""

Eżempju: 2K

pagination.totalPagesinteger

Meħtieġ: Required when pagination is used

Number of comic pages to generate.

Minimum
1
Maximum
20

Eżempju: 2

pagination.panelsPerPageinteger

Meħtieġ: Required when pagination is used

Panels per generated page.

Minimum
1
Maximum
20

Eżempju: 4

comicRoles[].namestring

Meħtieġ: Rakkomandat

Stable character name used by the model and returned panel metadata.

Eżempju: Alice

comicRoles[].imagestring URL

Meħtieġ: No

Reference image for character identity, costume, and visual continuity.

Eżempju: https://cdn.example.com/alice.png

comicLocations[].namestring

Meħtieġ: Rakkomandat

Reusable location name for visual continuity across pages and panels.

Eżempju: Dreamwood Forest

attachments[].typestring

Meħtieġ: No

Attachment role. When omitted, the API stores it as image.

Default
"image"

Eżempju: product

attachments[].urlstring URL

Meħtieġ: Required when attachments are used

Publicly accessible or signed file URL.

Eżempju: https://cdn.example.com/reference.png

Output schema

idstring

Generation id. Store this value for polling, logs, and support.

Eżempju: cmqyt8ea60003lb04uvxug8i9

statusstring enum

Queued status returned after the create request is accepted.

Eżempju: LOADING

promptstring

Normalized prompt used by the generation.

usage.total_comicsinteger

Total number of comic panel outputs charged for the create request.

Eżempju: 4

usage.amountinteger

Credits charged by the create request.

Eżempju: 600

modelstring

Compatibility model field returned by the create response.

Eżempju: cyani-model

Ġenerazzjoni tal-vidjo

Set agentType to videoModel to create a video job through the Comic API endpoint. Model input parameters are stored on the first comicData item as videoOptions for the video agent.

Text to video

Use this form when the video model should generate directly from a text prompt.

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    "agentType": "videoModel",6    "prompt": "A warm cinematic shot of a traveler standing on a seaside cliff at sunrise, coat moving in the wind, slow dolly-in, soft golden light.",7    "videoOptions": {8      "duration": 5,9      "resolution": "720p",10      "aspect_ratio": "16:9",11      "generate_audio": true,12      "seed": 1234513    }14  }'

Immaġni għal vidjo

Put image, last_frame_image, references, duration, resolution, aspect_ratio, generate_audio, and seed inside videoOptions.

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    "agentType": "videoModel",6    "prompt": "Animate this product photo into a slow studio turntable shot with soft highlights.",7    "videoOptions": {8      "image": "https://cdn.example.com/product-first-frame.png",9      "duration": 5,10      "resolution": "720p",11      "aspect_ratio": "1:1",12      "generate_audio": false13    }14  }'

Input schema

agentTypestring

Meħtieġ: Yes for video model generation

Set this to videoModel to route the same /v1/comics/generations endpoint to the video model agent instead of the comic generator.

Value
"videoModel"

Eżempju: videoModel

videoOptions.imagestring URL

Meħtieġ: No

Optional first-frame image URL for image-to-video.

Eżempju: https://cdn.example.com/first-frame.png

videoOptions.last_frame_imagestring URL

Meħtieġ: No

Optional final-frame image URL. Use it together with videoOptions.image.

Eżempju: https://cdn.example.com/last-frame.png

videoOptions.reference_imagesstring[]

Meħtieġ: No

Reference image URLs for the video model. Do not combine with image or last_frame_image.

Eżempju: ["https://cdn.example.com/reference.png"]

videoOptions.reference_videosstring[]

Meħtieġ: No

Reference video URLs for style, motion, or character guidance.

Eżempju: ["https://cdn.example.com/reference.mp4"]

videoOptions.reference_audiosstring[]

Meħtieġ: No

Reference audio URLs when audio generation is enabled.

Eżempju: ["https://cdn.example.com/reference.wav"]

videoOptions.durationnumber

Meħtieġ: No

Video duration in seconds. The current video model accepts short-form durations.

Default
5

Eżempju: 5

videoOptions.resolution480p | 720p | 1080p | 4k

Meħtieġ: No

Requested output resolution. Current pricing is 1,920 credits/s at 480p, 4,320 credits/s at 720p, 10,800 credits/s at 1080p, and 24,000 credits/s at 4k.

Default
"720p"

Eżempju: 720p

videoOptions.aspect_ratio16:9 | 4:3 | 1:1 | 3:4 | 9:16 | 21:9 | 9:21 | adaptive

Meħtieġ: No

Requested output aspect ratio. Use aspectRatio as a camelCase alias in form clients if needed.

Default
"16:9"

Eżempju: 16:9

videoOptions.generate_audioboolean

Meħtieġ: No

Whether the video model should generate audio with the video.

Default
true

Eżempju: true

videoOptions.seednumber

Meħtieġ: No

Optional deterministic seed.

Eżempju: 12345

Output schema

idstring

Generation id for polling.

Eżempju: gen_video_123456789

statusstring enum

Current video generation status.

Eżempju: PROCESSED

promptstring

Prompt used by the video generation.

comics[].videoUrlstring URL

Playable video URL.

Eżempju: https://s.llamagen.ai/team/video-watermarked.mp4

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"

Input schema

generationIdstring path parameter

Meħtieġ: Yes

Generation id returned by create generation.

Eżempju: gen_123456789

pageinteger query parameter

Meħtieġ: No

Zero-based page index. Only used when requesting a single panel together with panel.

Default
0

Eżempju: 0

panelinteger query parameter

Meħtieġ: No

Zero-based panel index. When omitted, the endpoint returns generation status and comics[].

Eżempju: 2

Output schema

idstring

Generation id.

Eżempju: gen_123456789

statusstring enum

Current generation status.

Eżempju: PROCESSED

promptstring

Original generation prompt.

comics[]array

Meħtieġ: When not requesting a single panel

Normalized comic pages returned by the status endpoint, including panels with assetUrl, panel, caption, and image.

Continue write

Extend an existing story or multi-page generation while preserving established characters and settings.

1curl -X PATCH https://api.llamagen.ai/v1/comics/generations/gen_123456789 \2  -H "Authorization: Bearer $LLAMAGEN_API_KEY" \3  -H "Content-Type: application/json" \4  -d '{5    "action": "continueWrite",6    "prompt": "The two friends walk deeper into the neon city and discover a hidden arcade.",7    "pagination": {8      "totalPages": 2,9      "panelsPerPage": 410    },11    "attachments": [12      {13        "type": "image",14        "url": "https://example.com/reference-1.png"15      }16    ]17  }'

Input schema

generationIdstring path parameter

Meħtieġ: Yes

Existing comic generation id to extend.

Eżempju: gen_123456789

actionstring

Meħtieġ: Yes

Set to continueWrite so PATCH routes to the continue-write operation.

Value
"continueWrite"

Eżempju: continueWrite

promptstring

Meħtieġ: Yes

Story direction for the next page or pages.

Eżempju: The two friends discover a hidden arcade.

paginationobject

Meħtieġ: No

Use pagination.totalPages and pagination.panelsPerPage to append multiple pages. Do not send top-level totalPages or panelsPerPage.

Conflicts
fixPanelNum

Eżempju: { "totalPages": 2, "panelsPerPage": 4 }

fixPanelNuminteger

Meħtieġ: No

Panel count for one appended page when pagination is not used. Defaults to the previous page panel count.

Minimum
1
Maximum
20

Eżempju: 4

attachmentsArray<Attachment> | JSON string

Meħtieġ: No

Optional references attached to the first appended page. Fields such as size, promptUrl, comicRoles, comicLocations, language, and upscale are not supported by continue-write.

Eżempju: [{ "type": "image", "url": "https://example.com/reference-1.png" }]

Output schema

idstring

Generation id being extended.

Eżempju: gen_123456789

statusstring enum

Queued status after the continue-write request is accepted.

Eżempju: LOADING

pageinteger

Zero-based index of the first appended page.

Eżempju: 2

usage.total_comicsinteger

Number of new panel outputs charged.

Eżempju: 8

usage.amountinteger

Credits charged by the request.

Eżempju: 1200

paginationobject

Meħtieġ: When pagination is provided

Returned pagination.totalPages and pagination.panelsPerPage.

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 \2  -H "Authorization: Bearer $LLAMAGEN_API_KEY" \3  -H "Content-Type: application/json" \4  -d '{5    "page": 0,6    "panel": 2,7    "panelPrompt": "Make Leo look more hopeful and keep the same orange wizard robe."8  }'

Input schema

generationIdstring path parameter

Meħtieġ: Yes

Existing comic generation id containing the panel.

Eżempju: gen_123456789

pageinteger

Meħtieġ: No

Zero-based page index. pageIndex and page_index are accepted aliases.

Default
0

Eżempju: 0

panelinteger

Meħtieġ: Yes

Zero-based panel index. panelIndex and panel_index are accepted aliases.

Eżempju: 2

panelPromptstring

Meħtieġ: One of panelPrompt, prompt, images, or caption

Replacement prompt for the selected panel. prompt and panel_prompt are accepted aliases.

Eżempju: Make Leo look more hopeful.

imagesstring | string[]

Meħtieġ: One of panelPrompt, prompt, images, or caption

Optional reference image URL or URLs for the selected panel. images_url is accepted as an alias.

Eżempju: ["https://example.com/reference.png"]

captionstring

Meħtieġ: One of panelPrompt, prompt, images, or caption

Replacement caption for the selected panel.

Eżempju: Leo whispers, I found it.

Output schema

idstring

Generation id containing the regenerated panel.

Eżempju: gen_123456789

statusstring enum

Queued status after the panel regeneration is accepted.

Eżempju: LOADING

panel.pageinteger

Zero-based page index for the regenerated panel.

Eżempju: 0

panel.panelinteger

Zero-based panel index for the regenerated panel.

Eżempju: 2

usage.redraw_panelsinteger

Number of panels queued for redraw.

Eżempju: 1

usage.amountinteger

Credits charged by the request.

Eżempju: 150

MCP Usage

Connect via Streamable HTTP

MCP Endpoint
https://llamagen.ai/api/mcp
Authorization Header
Authorization: Bearer YOUR_API_TOKEN

Configure 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

  1. Open Cursor Settings and find the Model Context Protocol (MCP) section.
  2. Add a new server using Streamable HTTP.
  3. Set URL to https://llamagen.ai/api/mcp.
  4. Under Headers, add Authorization: Bearer YOUR_API_TOKEN.
  5. 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 comic

Step 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  ComicGenerationStatus5} 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

StatusMeaning
LOADINGRequest accepted or generation is still running.
PROCESSEDGeneration completed successfully.
FAILEDGeneration 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.

Keep a request ID in your app logs and correlate it with dashboard request logs for faster debugging.

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

CodeDescription
401Unauthorized - Invalid API token.
402Payment Required - Insufficient credits.
403Forbidden - Access denied.
429Too Many Requests - Rate limit exceeded.
500Internal Server Error.