HomeGuide
Updated
AI Video Script Generator Built on an LLM API
An ai video script generator is a text model with a good prompt around it. This guide shows how to build one on an OpenAI-compatible API, with a Python template and the real cost per script.


Key points
- The API writes text only: scripts, shot lists and voiceover. It does not render video.
- Ask for JSON so each scene lands in a field your editor or video tool can read.
- A 60-second script with shot list costs about a tenth of a cent at $0.15 and $0.50 per 1M tokens.
- Keep the brief, tone and past scenes in the prompt; the window is 100,000 tokens.
No card needed. After sign-up, claim $0.50 of free test credit with one click (once per person).
Get API keyWhat a script generator actually does
An ai video script generator takes a short idea and returns the text a video needs: a hook, scenes, narration, on-screen text and notes for visuals. The model does the writing. Your code does the rest: it builds the prompt, sends it, checks the answer and hands the parts to whatever makes the pictures.
This API is text only. It will not generate images, audio or video. That fits the job well, because the script is the step where most video projects stall, and it is also the cheapest step to automate. Pictures and voices come from other tools you already use. The model, run by an independent provider, is tuned to answer without content refusals for lawful adult use, which matters if your scripts cover mature fiction, horror, crime stories or dark humor. If you want the wider picture of how text fits into video pipelines, see the AI video API guide.
Three outputs are worth asking for in one call: the voiceover text (what the narrator says), the shot list (what the viewer sees) and a timing estimate per scene. Splitting them into separate fields makes later steps simple.
Set up the client
The endpoint is OpenAI-compatible, so the standard SDK works. Get a key on the API key page, then point the client at the base URL and use the model ID uncensored.
from openai import OpenAI
client = OpenAI(
base_url="https://api.aivideogenapi.com/v1",
api_key="YOUR_KEY",
)
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Write a 3-line hook for a video about night trains."}],
)
print(resp.choices[0].message.content)
print(resp.usage)
The same request works in curl or Node with only the base URL and key changed. Full parameter details are in the API docs. New accounts can claim $0.50 of trial credit with one click on the key page, which is enough to test everything in this article many times.
A prompt template that returns usable scenes
A vague request gives vague scripts. A good template fixes four things: the audience, the length, the tone and the output format. Put the rules in the system message and the idea in the user message.
import json
from openai import OpenAI
client = OpenAI(base_url="https://api.aivideogenapi.com/v1", api_key="YOUR_KEY")
SYSTEM = """You write short video scripts.
Return JSON only, with this shape:
{"title": str, "hook": str,
"scenes": [{"n": int, "seconds": int, "voiceover": str,
"shot": str, "on_screen_text": str}]}
Rules:
- Total length matches the requested duration.
- Voiceover is spoken language: short sentences, no stage directions.
- 'shot' describes what the camera shows, in one sentence.
- First scene is a hook that works without sound."""
def make_script(idea, seconds=60, tone="dry, curious", audience="adults"):
user = f"Idea: {idea}\nDuration: {seconds} seconds\nTone: {tone}\nAudience: {audience}"
r = client.chat.completions.create(
model="uncensored",
temperature=0.8,
response_format={"type": "json_object"},
messages=[{"role": "system", "content": SYSTEM},
{"role": "user", "content": user}],
)
return json.loads(r.choices[0].message.content), r.usage
script, usage = make_script("why night trains are coming back")
for s in script["scenes"]:
print(s["n"], s["seconds"], s["voiceover"])
JSON mode (response_format with json_object) keeps the reply parseable. Still wrap json.loads in a try block and retry once on failure, since any model can occasionally produce a broken string. A temperature of 0.7 to 0.9 gives varied wording; drop it to 0.3 when you need near-identical structure across a batch.
Check length before you trust it
Models are poor at counting seconds. A reliable rule is about 150 spoken words per minute for a calm narrator, a bit more for fast social clips. After each call, count the words in all voiceover fields and compare them with the target.
def spoken_seconds(script, wpm=150):
words = sum(len(s["voiceover"].split()) for s in script["scenes"])
return round(words / wpm * 60)
est = spoken_seconds(script)
if abs(est - 60) > 8:
print("Off target:", est, "seconds. Ask for a rewrite.")
If the script is too long, send a second message with the actual numbers: "The voiceover runs about 78 seconds; cut it to 60 without losing the hook." Concrete feedback works better than "make it shorter". Keep the first reply in the message list so the model sees what it wrote.
Shot lists and voiceover as separate passes
For longer videos, one call for everything gets thin. Use two passes instead. First ask for an outline of scene titles and one-line goals. Then generate each scene in its own call, passing the outline and the previous scene's voiceover so the tone carries over.
- Pass 1, outline: 6 to 12 scenes, each with a goal and a rough duration.
- Pass 2, scenes: voiceover and shot for one scene at a time, with the outline and the last two scenes in context.
- Pass 3, polish: read the full voiceover back and ask for repeated phrases to be varied.
The context window is 100,000 tokens for prompt plus reply, so even a 20-minute documentary script with its full outline fits in one conversation. For how memory behaves in long sessions, the page on the context window covers the practical limits. Streaming (stream: true) is useful if you show the script to a person as it is written.
What a script costs
Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, paid from prepaid credit. Take a typical 60-second script with a shot list. Say the prompt is 1,200 tokens (rules plus idea) and the reply is 1,800 tokens.
| Part | Tokens | Math | Cost |
|---|---|---|---|
| Input | 1,200 | 1,200 / 1,000,000 x $0.15 | $0.00018 |
| Output | 1,800 | 1,800 / 1,000,000 x $0.50 | $0.0009 |
| Total | 3,000 | $0.00108 |
That is about a tenth of a cent per script. A channel that makes 1,000 scripts pays roughly $1.08 in model fees. Retries and polish passes add to this, but even three calls per script keep it near a cent each. Failed or refused requests are not charged. Credit never expires, and the pricing page lists the top-up amounts, from $20 to $500, and the bonus tiers.
The usage field in each response gives exact token counts, so you can log the real cost per script instead of estimating.
Limits and habits that save time
A full key allows 8 concurrent requests and 300 requests per minute. A trial key allows 2 concurrent and 60 per minute. When you batch many scripts, use a small worker pool of 4 to 6 and back off when you see HTTP 429. The error code tells you which limit you hit: rate_limited for requests per minute, concurrency for too many at once. On temporary overload the reply carries a Retry-After: 5 header, so wait five seconds and retry.
- Save every script with its prompt, so you can reproduce a good one. The
seedparameter is passed through if you want repeatable runs. - Keep a style sheet (banned phrases, recurring character names, brand voice) in the system prompt and reuse it across videos.
- Log
X-Request-Idfrom each response; it helps when you ask support about a specific call. - Read every script before publishing. The model writes fluent text, not verified facts.
import time
def call_with_retry(fn, tries=4):
for i in range(tries):
try:
return fn()
except Exception as e:
if "429" in str(e) and i < tries - 1:
time.sleep(5 * (i + 1))
continue
raise
Prompts are not used for training. Sexual content involving minors is not allowed, whatever the framing.
More guides
Questions and answers
Can this API make the video itself?
No. It generates text only. Use it for scripts, shot lists, captions and voiceover text, and pass those to the video and voice tools you already use.
How long can a script be?
The context window is 100,000 tokens for prompt and reply together, and max_tokens is optional, so very long scripts fit. For anything over a few minutes, an outline pass followed by scene-by-scene calls gives better quality.
Do I need to pay to try it?
No. New users can claim $0.50 of trial credit with one click on the API key page after sign-up. Later top-ups are made in crypto (USDT on TRC20 or USDC on Base).
Will it refuse dark or mature story topics?
The model is tuned to answer without content refusals for lawful adult use. Content involving minors in a sexual context is never allowed.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.