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.
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"
}'const response = await fetch("https://hitfactorapp.com/api/v1/scripts/generate", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.HITFACTOR_API_KEY!,
"Idempotency-Key": "req_2026_001",
},
body: JSON.stringify({
"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"
}),
})
const { data, meta } = await response.json()
console.log(data, meta)curl -sS -X POST "https://hitfactorapp.com/api/v1/mcp" \
-H "Content-Type: application/json" \
-H "x-api-key: $HITFACTOR_API_KEY" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "generate_script",
"arguments": {
"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",
"requestId": "req_2026_001"
}
}
}'Parameters
Idempotency-KeyheaderstringUnique retry key (up to 255 characters). Replaying the same key and body returns the original response with 0 extra credits charged.
maxLength: 255Request body
Send a JSON object with Content-Type: application/json. Unknown keys are rejected with 400 invalid_input.
titlestringrequiredminLength: 1maxLength: 300conceptstringrequiredminLength: 1maxLength: 2000targetWordCountintegerTarget word count (300-5000, defaults to 1500 when targetDurationMinutes is omitted).
min: 300max: 5000targetDurationMinutesnumberTarget duration in minutes (2-30), converted via channel speaking pace when targetWordCount is omitted.
min: 2max: 30outlinestringmaxLength: 4000hookstringmaxLength: 1500presenterstringmaxLength: 200notesstringmaxLength: 2000webhookUrlstringmaxLength: 2048Response (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.
operationIdstringrequiredstatus"queued"requiredpollUrlstringrequired{
"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.
scriptstringrequiredFull generated YouTube script text.
wordCountintegerrequiredWord count of the generated script.
min: -9007199254740991max: 9007199254740991estimatedDurationSecondsintegerrequiredEstimated spoken duration in seconds.
min: -9007199254740991max: 9007199254740991rewritePassesUsedintegerrequiredNumber of critic rewrite passes used (0 or 1).
min: -9007199254740991max: 9007199254740991groundingNotesstring[]requiredKnowledge base and exemplar grounding notes used during generation.
{
"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_input401Missing or invalid API key402insufficient_credits403insufficient_scope404operation_not_found409channel_sync_pending or idempotency_conflict429rate_limited