Skip to article

Batch NPC

Generate a consistent cast of four, nine or sixteen NPCs.

What you can create

Create a coordinated cast of 4, 9 or 16 NPCs in a single generation. Use archetypes such as blacksmith, healer, merchant and guard to populate a town. The output is a generated cast with its available extracted assets, rather than separate unrelated style requests.

Prepare the cast

Provide exactly 4, 9 or 16 nonempty archetypes. Choose exactly one style source: stylePreset, stylePrompt, styleReferenceAssetId or templateId. A reference must be a ready image you own. Choose framing: bust, full-body or avatar.

Create NPCs in the workspace

  1. Open Batch NPC generator.
  2. Choose the cast size and fill every archetype slot.
  3. Choose one style source and framing; set age and gender variation.
  4. Select a project, review the batch cost and generate.
  5. Inspect the cast and reuse individual ready assets from the result.

Choices, limits and cost

The whole cast costs 4 credits, including the 16-NPC option. This business currently uses one media generation and one charge; the public task's item count is therefore not the number of NPCs. mixAges and mixGenders default to true. Output generation is 2k. Keep names and occupations concise; each archetype is limited to 50 characters.

NPC generation selects a project destination. To organize individual NPCs further, use the existing workspace asset workflow; this integration does not create or manage full character records.

Parameters

These fields are generated from the same input Schema used by REST and MCP. Nested required fields apply when their parent object or selected variant is present. Business conditions described above are validated before submission.

FieldTypeRequiredDefault and limits
templateIdstringNoSee the workflow requirements above.
stylePresetstringNo"16-bit-pixel", "modern-anime", "cyberpunk-chibi", "dark-fantasy"
stylePromptstringNominLength: 3; maxLength: 1000
archetypesarrayYesmaxItems: 20
framingstringYes"bust", "full-body", "avatar"
mixAgesbooleanNoDefault: true
mixGendersbooleanNoDefault: true
projectIdstringNominLength: 1; maxLength: 255
folderIdstring / nullNoSee the workflow requirements above.
styleReferenceAssetIdstringNoSee the workflow requirements above.

API example

This example costs 4 credits. A quote does not reserve balance or bypass subscription requirements. Set SPRITEFLOW_API_KEY in your shell. Replace the placeholder asset ID 00000000-0000-4000-8000-000000000001 with a ready asset you own when present. Use a new idempotency key for each intentional generation; keep it unchanged when retrying.

bash

# Use the same BASE_URL for credentials, uploads and generation.
BASE_URL="https://spriteflow.io"
IDEMPOTENCY_KEY="example-workflow-001"

cat > request.json <<'JSON'
{
  "operation": "generate_npcs",
  "input": {
    "stylePreset": "16-bit-pixel",
    "archetypes": [
      "Blacksmith",
      "Healer",
      "Merchant",
      "Guard"
    ],
    "framing": "full-body"
  }
}
JSON

curl --fail-with-body "$BASE_URL/api/v1/estimates" \
  -H "Authorization: Bearer $SPRITEFLOW_API_KEY" \
  -H "Content-Type: application/json" --data-binary @request.json

curl --fail-with-body "$BASE_URL/api/v1/tasks" \
  -H "Authorization: Bearer $SPRITEFLOW_API_KEY" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -H "Content-Type: application/json" --data-binary @request.json

An accepted request returns HTTP 202, Location and Retry-After headers. Example response (IDs are illustrative):

json
{"taskId":"00000000-0000-4000-8000-000000000002","status":"accepted","statusUrl":"/api/v1/tasks/00000000-0000-4000-8000-000000000002","pollAfterSeconds":10,"replayed":false}

MCP example

Call estimate_cost with the same operation and input, then call generate_npcs. The following is a tools/call params object:

json
{
  "name": "generate_npcs",
  "arguments": {
    "input": {
      "stylePreset": "16-bit-pixel",
      "archetypes": [
        "Blacksmith",
        "Healer",
        "Merchant",
        "Guard"
      ],
      "framing": "full-body"
    },
    "idempotencyKey": "example-workflow-001"
  }
}

The tool returns the same task receipt in structuredContent and a JSON text result. Pass taskId to get_task. Tool annotations describe behavior; permissions are still checked on the server.

Completion, download and reuse

Poll the returned statusUrl after pollAfterSeconds. Continue while terminal is false. Read items for per-task results, progress for batch counts and assets for ready files. A batch can be partially_completed: use its successful assets and review each failed item before deciding whether to create a separate retry.

For each returned asset ID, call get_download_url or GET /api/v1/assets/{assetId}/download. Download the temporary URL before it expires. Image assets can be passed into a compatible operation as inputAssetId or a style reference. Do not pass provider task IDs, download URLs or local filesystem paths as asset IDs.

Failures and recovery

  • INVALID_PARAMETERS: fix the field errors before submitting. Check the business conditions and defaults above.
  • INPUT_ASSET_UNAVAILABLE: confirm the upload, check ownership and ensure the asset is ready and not trashed.
  • INSUFFICIENT_CREDITS: add credits before a new request; a cost estimate does not reserve them.
  • A timeout or lost response: resend the identical request with the original idempotency key. Never invent a new key just because the response was lost.
  • A terminal generation failure: inspect the item error and refund information. Refund handling uses the existing generation workflow. Do not assume an in-progress or unknown submission is safe to repeat.

Uploads · Tasks · Credits · Idempotency · Save destinations · Download and export