Base URL: https://api.llamagen.ai/v1
This package covers LlamaGen's Comic API and Animation API. Type definitions live in ../src/api-types.ts.
import { LlamaGenClient } from 'comic';
const llamagen = new LlamaGenClient({
apiKey: process.env.LLAMAGEN_API_KEY!,
timeoutMs: 30000,
maxRetries: 2,
retryDelayMs: 500
});Creates a comic generation through POST /comics/generations.
const created = await llamagen.comic.create({
prompt: 'A 4-panel comic about Leo finding a glowing key in a quiet library.',
style: 'manga',
fixPanelNum: 4
});Supported input families:
- Story input:
prompt,promptUrl,style,preset,size. - Layout:
fixPanelNumfor one page, orpagination.totalPagespluspagination.panelsPerPagefor multi-page mode. - Continuity references:
comicRoles,comicLocations,images,attachments. - Output controls:
language,upscale.
The SDK validates that prompt is non-empty, supported size values are used, and fixPanelNum is not mixed with pagination.
Gets a generation through GET /comics/generations/{generationId}.
const generation = await llamagen.comic.get('gen_123');
const singlePanel = await llamagen.comic.get('gen_123', { page: 0, panel: 2 });page and panel are zero-based.
Extends an existing story through PATCH /comics/generations/{generationId} with action: "continueWrite".
await llamagen.comic.continueWrite('gen_123', {
prompt: 'The two friends walk deeper into the neon city and find a hidden arcade.',
pagination: { totalPages: 1, panelsPerPage: 4 },
attachments: [{ type: 'image', url: 'https://example.com/reference.png' }]
});Regenerates one panel through PATCH /comics/generations/{generationId} with action: "regeneratePanel".
await llamagen.comic.updatePanel('gen_123', {
page: 0,
panel: 2,
panelPrompt: 'Make Leo look more hopeful and keep the same orange wizard robe.'
});Accepted aliases include panelIndex, panel_index, pageIndex, page_index, prompt, panel_prompt, and images_url.
const usage = await llamagen.comic.usage();
const upload = await llamagen.comic.upload(file, 'reference.png');
const done = await llamagen.comic.waitForCompletion('gen_123');
const createdAndDone = await llamagen.comic.createAndWait({ prompt: 'A detective fox in Tokyo.' });Batch helpers:
llamagen.comic.createBatch(paramsList, { concurrency, stopOnError })llamagen.comic.waitForMany(ids, { concurrency, intervalMs, timeoutMs })
Creates a video artwork through POST /artworks/generations.
const created = await llamagen.animation.create({
prompt: 'A heroic fox detective walks through neon rain, cinematic camera move.',
videoOptions: {
duration: 5,
resolution: '720p',
aspect_ratio: '16:9',
image: 'https://example.com/first-frame.png',
last_frame_image: 'https://example.com/last-frame.png',
reference_images: ['https://example.com/character.png']
}
});Animation methods:
llamagen.animation.create(params)llamagen.animation.get(id)llamagen.animation.waitForCompletion(id, options?)llamagen.animation.createAndWait(params, options?)
Use this namespace for text-to-video, image-to-video, storyboard-to-video, and reference-driven animation workflows.
import { constructWebhookEvent } from 'comic';
const event = constructWebhookEvent(rawBody, headers, process.env.LLAMAGEN_WEBHOOK_SECRET!);Supported event names include:
comic.generation.createdcomic.generation.updatedcomic.generation.completedcomic.generation.failed
Headers verified by the SDK:
X-Llama-Webhook-IdX-Llama-Webhook-TimestampX-Llama-Webhook-SignatureX-Llama-Webhook-Request-Id
Comic endpoints:
POST /comics/generationsGET /comics/generations/{generationId}PATCH /comics/generations/{generationId}GET /comics/usagePOST /comics/upload
Animation endpoints:
POST /artworks/generationsGET /artworks/generations/{id}
curl -X POST https://api.llamagen.ai/v1/comics/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A fox detective in Tokyo.",
"style": "manga",
"fixPanelNum": 4
}'Remote MCP endpoint:
https://llamagen.ai/api/mcp
Available MCP tools:
create_comic_generationget_comic_generation_statusget_api_usage
- Next.js direct SDK demo:
../examples/nextjs-integration - Express direct SDK demo:
../examples/express-integration
Use MCP Streamable HTTP endpoint:
https://llamagen.ai/api/mcp
Authorization:
Authorization: Bearer YOUR_API_KEYAvailable tools:
create_comic_generationget_comic_generation_statusget_api_usage
Client config example:
{
"mcpServers": {
"llamagen": {
"url": "https://llamagen.ai/api/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}Cursor setup:
- Go to Cursor MCP settings.
- Add a new Streamable HTTP server.
- Set URL to
https://llamagen.ai/api/mcp. - Add header
Authorization: Bearer YOUR_API_KEY. - Confirm tool list is visible.
OAuth metadata endpoint:
https://llamagen.ai/.well-known/oauth-protected-resource