Docs / AmanDevelops / Comic Page v1
Raw Markdown (AI)

Comic Page v1 Model Specification

Comic Page v1 is a high-speed, serverless comic book page assembler. It takes between 1 and 9 panel images, custom borders, gutters, and layout cell assignments, and automatically renders a high-resolution $2:3$ portrait comic book page ($2048 \times 3072\text{ px}$) using non-distorting center-crop fitting.


1. Quick Overview

  • Model Slug: comic-page-v1
  • Endpoint: POST https://api.amandevelops.com/v1/comic-page-v1/
  • Category: Utility / Image Processing & Comic Creation
  • Output Canvas: $2048 \times 3072\text{ px}$ (Exact 2:3 portrait aspect ratio)
  • Pricing: $0.0010 per page (Flat fixed rate)
  • Execution Modes:
  • Direct Synchronous ("sync": true): Returns the completed $2\text{K}$ image URL directly in the HTTP 200 response in $< 1\text{ second}$.
  • Asynchronous ("sync": false): Returns HTTP 202 Accepted in $< 20\text{ms}$ with task_id for database polling or webhooks.
  • Storage Retention: 48 hours high-availability public CDN storage

2. The 3 × 3 Grid System

Every comic book page is modeled as a $3 \times 3$ grid containing 9 cells in standard Western Z-Reading Order (left to right, top to bottom):

text
┌─────────┬─────────┬─────────┐
│ Cell 1  │ Cell 2  │ Cell 3  │   (Top Row)
├─────────┼─────────┼─────────┤
│ Cell 4  │ Cell 5  │ Cell 6  │   (Middle Row)
├─────────┼─────────┼─────────┤
│ Cell 7  │ Cell 8  │ Cell 9  │   (Bottom Row)
└─────────┴─────────┴─────────┘

Because the outer page is $2:3$ portrait and the grid is divided into 3 equal columns and 3 equal rows, each individual cell has a proportional aspect ratio of $2:3$.

Hard Partition Rules

  1. All 9 cells must be used: Every single cell from 1 to 9 must be assigned to a panel.
  2. Zero Gaps, Zero Overlaps: No cell can be left unassigned, and no cell can belong to more than one panel.
  3. Contiguous Rectangle Rule: Every panel must form a solid rectangular group of cells. Irregular shapes (such as L-shapes or disjoint cells) are strictly rejected with HTTP 422 ERRINVALIDPANEL_SHAPE.

3. Supported Panel Shapes & Ratios

Any contiguous rectangle on a $3 \times 3$ grid matches one of 9 supported panel shapes:

Shape (Cols × Rows)Cells CountProportional RatioCommon Comic FunctionVerified Cell Combinations
$1 \times 1$1$2:3$Single panel / reaction shot[1], [2], [3], [4], [5], [6], [7], [8], [9]
$2 \times 1$2$4:3$Standard landscape / dialogue scene[1,2], [2,3], [4,5], [5,6], [7,8], [8,9]
$3 \times 1$3$2:1$Panoramic wide landscape strip[1,2,3], [4,5,6], [7,8,9]
$1 \times 2$2$1:3$Tall skinny vertical panel[1,4], [2,5], [3,6], [4,7], [5,8], [6,9]
$2 \times 2$4$2:3$Focal miniature block (vertical)[1,2,4,5], [2,3,5,6], [4,5,7,8], [5,6,8,9]
$3 \times 2$6$1:1$Large square hero block[1,2,3,4,5,6], [4,5,6,7,8,9]
$1 \times 3$3$2:9$Full-height vertical banner strip[1,4,7], [2,5,8], [3,6,9]
$2 \times 3$6$4:9$Tall 2-column dominant block[1,2,4,5,7,8], [2,3,5,6,8,9]
$3 \times 3$9$2:3$Full-page splash panel[1,2,3,4,5,6,7,8,9]
TIP
No Image Stretching: Panel images do not need to match these ratios down to the exact pixel. The engine automatically scales and center-crops (object-fit: cover) each panel image to fill the target rectangle cleanly without distortion or stretching.

4. API Request Specification

  • HTTP Method: POST
  • Path: /v1/comic-page-v1/
  • Headers:
http
  Authorization: Bearer <YOUR_API_KEY>
  Content-Type: application/json
  

Full JSON Request Schema

json
{
  "panels": [
    {
      "cells": [1, 2, 4, 5],
      "image": "https://example.com/panels/hero_scene.jpg"
    },
    {
      "cells": [3],
      "image": "https://example.com/panels/reaction.jpg"
    },
    {
      "cells": [6, 9],
      "image": "https://example.com/panels/dialogue.jpg"
    },
    {
      "cells": [7, 8],
      "image": "https://example.com/panels/action.jpg"
    }
  ],
  "border_size": 20,
  "gutter_size": 20,
  "border_color": "#FFFFFF",
  "gutter_color": "#FFFFFF",
  "output_format": "jpg",
  "sync": true,
  "webhook_url": "https://your-domain.com/webhooks/comic"
}

5. Parameter Reference

ParameterTypeRequired?DefaultDescription
panelsarrayRequired—Array of 1 to 9 panel objects. Each panel requires cells (array of integers 1-9) and image (URL or Data URI).
border_sizeintegerOptional20Outer page margin in pixels around the outer edge ($0 - 200\text{px}$). Set to 0 for borderless edge-to-edge pages.
gutter_sizeintegerOptional20Spacing in pixels between adjacent panels ($0 - 200\text{px}$). Set to 0 for seamless adjacent panels.
border_colorstringOptional"#FFFFFF"Hex color code for the outer page border (e.g. "#FFFFFF", "#000000", "#F3F4F6").
gutter_colorstringOptionalborder_colorHex color code for the internal gutters between panels. Defaults to match border_color.
output_formatstringOptional"jpg"Image format of the generated page. Supported: "jpg" or "png".
syncbooleanOptionalfalseWhen true, waits for image rendering and returns HTTP 200 OK directly with the finished image URL in $< 1\text{s}$. When false, returns HTTP 202 Accepted immediately for asynchronous polling.
webhook_urlstringOptionalnullOptional notification URL to receive HMAC-SHA256 signed task.completed event when rendering finishes.

6. Response Schemas

Synchronous Direct Response ("sync": true • HTTP 200 OK)

json
{
  "status": "success",
  "code": "TASK_COMPLETED",
  "message": "Comic page generated successfully.",
  "task_id": "task_comic_7a9f2b1c8e3d",
  "model": "comic-page-v1",
  "state": "completed",
  "cost_usd": 0.0010,
  "remaining_balance_usd": 14.8920,
  "balance_usd": 14.8920,
  "result_url": "https://api.amandevelops.com/storage/comic-page-v1/img_comic_9c8b7a6f5e4d.jpg",
  "poll_url": "https://api.amandevelops.com/v1/tasks/task_comic_7a9f2b1c8e3d",
  "dimensions": [2048, 3072],
  "generation_time_sec": 0.28,
  "created_at": "2026-11-01 05:40:00",
  "completed_at": "2026-11-01 05:40:01"
}

Asynchronous Queued Response ("sync": false • HTTP 202 Accepted)

json
{
  "status": "success",
  "code": "TASK_QUEUED",
  "message": "Generation task accepted and queued for inference.",
  "task_id": "task_comic_7a9f2b1c8e3d",
  "model": "comic-page-v1",
  "state": "queued",
  "cost_usd": 0.0010,
  "remaining_balance_usd": 14.8920,
  "balance_usd": 14.8920,
  "poll_url": "https://api.amandevelops.com/v1/tasks/task_comic_7a9f2b1c8e3d",
  "created_at": "2026-11-01 05:40:00"
}

7. Runnable Integration Code

Python

python
import requests

API_KEY = "ak_live_YOUR_API_KEY_HERE"
url = "https://api.amandevelops.com/v1/comic-page-v1/"

payload = {
    "panels": [
        {"cells": [1, 2, 4, 5], "image": "https://example.com/panel1.jpg"},
        {"cells": [3], "image": "https://example.com/panel2.jpg"},
        {"cells": [6, 9], "image": "https://example.com/panel3.jpg"},
        {"cells": [7, 8], "image": "https://example.com/panel4.jpg"}
    ],
    "border_size": 20,
    "gutter_size": 20,
    "border_color": "#FFFFFF",
    "gutter_color": "#000000",
    "sync": True
}

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)
data = response.json()

if response.status_code == 200:
    print(f"Generated Page URL: {data['result_url']}")
    print(f"Dimensions: {data['dimensions'][0]}x{data['dimensions'][1]}")
else:
    print(f"Error {data.get('code')}: {data.get('message')}")

JavaScript (Node.js / Browser Fetch)

javascript
const API_KEY = 'ak_live_YOUR_API_KEY_HERE';

async function generateComicPage() {
  const response = await fetch('https://api.amandevelops.com/v1/comic-page-v1/', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      panels: [
        { cells: [1, 2, 3], image: 'https://example.com/top_strip.jpg' },
        { cells: [4, 5, 6], image: 'https://example.com/mid_strip.jpg' },
        { cells: [7, 8, 9], image: 'https://example.com/bottom_strip.jpg' }
      ],
      border_size: 24,
      gutter_size: 16,
      border_color: '#FFFFFF',
      gutter_color: '#FFFFFF',
      sync: true
    })
  });

  const data = await response.json();
  if (response.ok) {
    console.log('Comic Page URL:', data.result_url);
  } else {
    console.error('Generation Error:', data.code, data.message);
  }
}

generateComicPage();

8. Common Error Codes

Error CodeHTTP StatusPublic MessageCause & Fix
ERRINVALIDPANEL_LAYOUT422"The comic page panel configuration is invalid. Provide between 1 and 9 valid panels."The panels array was missing, empty, or contained more than 9 items.
ERRINCOMPLETEPAGE422"All 9 cells of the comic page must be covered. Missing cells: [x, y]."One or more grid cells were not assigned. Every cell from 1 to 9 must be covered.
ERRPANELOVERLAP422"Cell [x] is claimed by multiple panels. Panels cannot overlap."Two or more panels claimed the same cell. Check panel assignments.
ERRINVALIDPANEL_SHAPE422"Panel with cells [...] does not form a contiguous rectangle."A panel attempted to claim an irregular, L-shaped, or disconnected group of cells. Panels must be rectangular ($C \times R$).
ERRMEDIACORRUPTED422"Failed to download image for panel #... Please check the URL."A panel image URL was unreachable, timed out, or the binary was not a valid JPEG, PNG, or WebP.
INSUFFICIENT_FUNDS402"Insufficient wallet balance. Required: $0.0010 USD..."Account balance is below \$0.0010 USD. Add funds in Billing portal.

Send to AI Assistant (ChatGPT / Claude / Cursor)

Copy this prompt and paste it into your AI assistant or IDE agent to immediately integrate with this specification:

Copied to clipboard!