One prompt. A finished book.

Open Nellie Sign in

POST /v1/book

Start an asynchronous book generation job.

Overview

This endpoint starts a new book generation request. The job runs asynchronously; you’ll receive a requestId immediately that you can use to poll for status or receive results via webhook.

Endpoint

POST https://api.nelliewriter.com/v1/book

Authentication

Required. Include your API key in the X-API-Key header.

X-API-Key: nel_your_api_key_here

Request Headers

HeaderRequiredDescription
X-API-KeyYesYour Nellie API key
Content-TypeYesMust be application/json

Request Body

All parameters are optional. If you send an empty body {}, Nellie will generate a unique book with default settings.

ParameterTypeDefaultDescription
promptstringAuto-generatedYour book idea, synopsis, or detailed instructions
stylestring"automatic"Genre or narrative style
typestring"automatic"Book structure
imagesbooleanfalseGenerate AI illustrations
authorstring"Nellie"Author name for attribution
custom_tonestring""Unique writing style guidance
modelstring"2.0"Nellie AI model version
output_formatstring"txt"File format for export
webhook_urlstringnullURL to notify on completion

Parameter Details

prompt

The core idea for your book. Can range from a single word to a detailed synopsis.

// One Word
{"prompt": "Rebellion"}

// Simple
{"prompt": "A crime mystery set in 1920s Paris"}

// Detailed
{"prompt": "A sci-fi thriller about a Mars colony that discovers alien ruins. The protagonist is a geologist named Dr. Sarah Chen. Include themes of isolation and first contact."}

If omitted, Nellie generates a unique creative prompt automatically.

style

Genre or narrative style. Valid values:

ValueDescription
automaticLet Nellie choose based on prompt
actionFast-paced action sequences
adventureExploration and journey
alternate_historyHistorical “what if” scenarios
comedyHumor and lighthearted tone
crimeCriminal investigations
cyberpunkHigh-tech, low-life futures
dramaCharacter-driven emotional stories
dystopianOppressive future societies
epicGrand scale narratives
fableMoral tales with allegory
fairy_taleMagical traditional stories
fantasyMagic and mythical worlds
folkloreTraditional cultural stories
gothicDark, atmospheric horror
historyHistorical settings
horrorFear and suspense
legendHeroic traditional tales
mysteryPuzzles and detective work
mythologyAncient myths retold
noirDark, cynical crime
paranormalSupernatural elements
post_apocalypticAfter civilization falls
psychologicalMind and perception
romanceLove stories
sci_fiScience fiction
superheroPowers and heroism
surrealismDreamlike, absurd
suspenseTension and anticipation
thrillerHigh-stakes danger
tragedyDownfall narratives
westernAmerican frontier

type

The format and structure of the output:

ValueDescription
automaticLet Nellie choose
novelFull-length fiction
short_storyBrief narrative
comicIllustrated comic format
mangaJapanese-style comic
childrensChildren’s book
non_fictionFactual content
textbookEducational material
self_helpPersonal development

images

Set to true to generate context-relevant AI illustrations or photorealistic portraits throughout the book. Increases generation time.

{"images": true}

author

The name that appears as the author in the generated book.

{"author": "Jessica Walker"}

custom_tone

Additional guidance for the writing style of the text itself.

{"custom_tone": "Write like Shakespeare"}

model

ValueNameCreditsDescription
"2.0"Nellie 2.0 (Standard)250Balanced speed and quality
"3.0"Nellie 3.0 (Premium)500Higher creativity and coherence

output_format

File format for the generated book:

ValueDescription
txtPlain text
pdfPDF document
epubE-book format
mdMarkdown
htmlWeb page
jsonStructured JSON data

webhook_url

HTTPS URL that Nellie will POST to when the job completes or fails:

{"webhook_url": "https://your-site.com/api/nellie-webhook"}

Requirements:

  • Must be a valid HTTPS URL
  • Must be publicly accessible
  • Cannot be localhost or internal IPs (SSRF protection)

See Webhooks for payload details.

Example Requests

Minimal Request

curl -X POST https://api.nelliewriter.com/v1/book \
  -H "X-API-Key: nel_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{}'

Full Request

curl -X POST https://api.nelliewriter.com/v1/book \
  -H "X-API-Key: nel_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A noir detective story in 1940s Los Angeles",
    "style": "noir",
    "type": "novel",
    "images": true,
    "author": "Ray Hamilton",
    "custom_tone": "First-person narration, cynical wit, atmospheric descriptions",
    "model": "3.0",
    "output_format": "epub",
    "webhook_url": "https://myapp.com/webhooks/nellie"
  }'

Python SDK

from nellie_api import Nellie

client = Nellie(api_key="nel_your_api_key")

book = client.books.create(
    prompt="A noir detective story in 1940s Los Angeles",
    style="noir",
    type="novel",
    images=True,
    author="Ray Hamilton",
    custom_tone="First-person narration, cynical wit",
    model="3.0",
    output_format="epub",
    webhook_url="https://myapp.com/webhooks/nellie"
)

print(f"Job started: {book.request_id}")

Response

Success (202 Accepted)

{
  "success": true,
  "requestId": "abcd1234-ef56-7890-abcd-12ef34567890",
  "status": "queued",
  "statusUrl": "https://api.nelliewriter.com/v1/status/abcd1234-ef56-7890-abcd-12ef34567890",
  "message": "Job queued successfully"
}
FieldTypeDescription
successbooleanAlways true for successful requests
requestIdstringUnique job identifier (UUID)
statusstringInitial status, always "queued"
statusUrlstringFull URL to poll for status
messagestringHuman-readable confirmation

Error Responses

400 Bad Request: Invalid Parameter

{
  "success": false,
  "error": "Field 'style' must be one of: action, adventure, automatic, ...",
  "errorCode": "INVALID_PARAMETER"
}

400 Bad Request: Invalid Webhook URL

{
  "success": false,
  "error": "Invalid webhook URL: must be a valid HTTPS URL",
  "errorCode": "INVALID_WEBHOOK_URL"
}

401 Unauthorized

{
  "success": false,
  "error": "Unauthorized",
  "details": "Valid API key required",
  "errorCode": "AUTH_REQUIRED"
}

429 Too Many Requests

{
  "success": false,
  "error": "Rate limit exceeded: Please wait a few seconds between requests",
  "errorCode": "RATE_LIMIT_EXCEEDED"
}

429 Daily Limit Exceeded

{
  "success": false,
  "error": "Daily rate limit exceeded (15 requests/day)",
  "errorCode": "RATE_LIMIT_EXCEEDED"
}

What Happens Next

After a successful response:

  1. Job is queued: Your request enters the generation queue (usually there is no wait, and it will start within minutes)
  2. Processing begins: Nellie generates your book (15-80 minutes typical)
  3. Completion: Either:

Rate Limits

  • Minimum spacing: 6 seconds between requests
  • Daily limit: 15 requests per API key (contact us for increased limits)

See Rate Limits for details.

Credits

Generation costs credits based on:

FactorImpact
Model 2.0~250 credits
Model 3.0~500 credits

Credits are deducted upon successful completion. Failed jobs don’t consume credits. If a failed job consumes credits please contact us.

See Also