Skip to content

Generate video script

Generate a full YouTube script grounded in the connected channel voice, knowledge base, and exemplars, with the rewrite loop capped to 1 pass. Async operation; costs 100 credits.

POSThttps://hitfactorapp.com/api/v1/scripts/generate
MCP toolgenerate_scriptCost100 creditsModeAsync (202 Accepted)Scopescripts:writeChannel syncRequired

Request examples

curl -sS -X POST "https://hitfactorapp.com/api/v1/scripts/generate" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $HITFACTOR_API_KEY" \
  -H "Idempotency-Key: req_2026_001" \
  -d '{
  "title": "Why Every AI Agent Breaks in Production",
  "concept": "Walk through the three failure modes we hit scaling tool-calling agents and how deterministic state graphs fixed them.",
  "targetWordCount": 1500,
  "targetDurationMinutes": 10,
  "outline": "1. The demo trap 2. Deterministic state 3. Eval harness 4. Production numbers"
}'

Parameters

Idempotency-Keyheaderstring

Unique retry key (up to 255 characters). Replaying the same key and body returns the original response with 0 extra credits charged.

maxLength: 255

Request body

Send a JSON object with Content-Type: application/json. Unknown keys are rejected with 400 invalid_input.

titlestringrequired
minLength: 1maxLength: 300
conceptstringrequired
minLength: 1maxLength: 2000
targetWordCountinteger

Target word count (300-5000, defaults to 1500 when targetDurationMinutes is omitted).

min: 300max: 5000
targetDurationMinutesnumber

Target duration in minutes (2-30), converted via channel speaking pace when targetWordCount is omitted.

min: 2max: 30
outlinestring
maxLength: 4000
hookstring
maxLength: 1500
presenterstring
maxLength: 200
notesstring
maxLength: 2000
webhookUrlstring
maxLength: 2048

Response (202 Accepted)

Returns HTTP 202 immediately with an operationId and pollUrl. Poll GET /operations/{operationId} (0 credits) or pass webhookUrl to receive the finished payload.

operationIdstringrequired
status"queued"required
pollUrlstringrequired
Example 202 response
{
  "data": {
    "operationId": "apiop_01j9example0000000000000",
    "status": "queued",
    "pollUrl": "/api/v1/operations/apiop_01j9example0000000000000"
  },
  "meta": {
    "requestId": "req_01j9example0000000000000",
    "creditsCharged": 1,
    "creditsRemaining": 499,
    "replayed": false
  }
}

Completed operation result

When the async operation reaches status: "succeeded", this schema is returned inside data.result on GET /operations/{operationId} and webhook deliveries.

scriptstringrequired

Full generated YouTube script text.

wordCountintegerrequired

Word count of the generated script.

min: -9007199254740991max: 9007199254740991
estimatedDurationSecondsintegerrequired

Estimated spoken duration in seconds.

min: -9007199254740991max: 9007199254740991
rewritePassesUsedintegerrequired

Number of critic rewrite passes used (0 or 1).

min: -9007199254740991max: 9007199254740991
groundingNotesstring[]required

Knowledge base and exemplar grounding notes used during generation.

Example completed result
{
  "script": "[0:00] Most AI agents work on the happy path and fall apart the moment a tool times out...",
  "wordCount": -9007199254740991,
  "estimatedDurationSeconds": -9007199254740991,
  "rewritePassesUsed": -9007199254740991,
  "groundingNotes": [
    "example_groundingNotes"
  ]
}

Error responses

400invalid_input
401Missing or invalid API key
402insufficient_credits
403insufficient_scope
404operation_not_found
409channel_sync_pending or idempotency_conflict
429rate_limited