HomeGuide
Updated
How to Get an AI to Write a Script: Prompt Structure
If you want to know how to get an ai to write a script that you can actually film or voice, the answer is structure: tell the model who the script is for, how long it runs, and what shape the output must take.


Key points
- Give the model a role, a length in words, a tone and an output format. Every missing item becomes a guess.
- Short scripts fit one call. Long ones need an outline first, then act-by-act calls.
- Use temperature around 0.8 for drafts and lower for edits; set stop sequences if you need a hard end.
- The 100,000-token window holds a full outline plus all previous acts, so you rarely need tricks.
No card needed. After sign-up, claim $0.50 of free test credit with one click (once per person).
Get API keyThe short answer: five parts in the prompt
Most weak scripts come from weak prompts. A request like "write a script about coffee" leaves the model to choose the length, the voice, the format and the point. Give it these five parts instead:
- Purpose: what the viewer should feel or do at the end.
- Audience and tone: "new parents, warm and a bit tired" works better than "friendly".
- Length: in words, because models count words better than seconds. About 150 words is a minute of speech.
- Format: screenplay, two-column voiceover and visuals, or plain narration.
- Constraints: things to avoid, names to keep, a required last line.
Here is the difference in practice. A weak prompt: "Write a script about sleep." A stronger one: "Write a 120-word narration for a 50-second video that persuades office workers to stop checking email in bed. Tone: gentle, slightly funny. Open with a question. End with one concrete action they can take tonight. Do not mention medication." The second prompt costs about forty more tokens and removes most of the rewriting rounds. Treat the extra words as the cheapest editing you will ever do.
That is the whole method. The rest of this page shows how to turn it into API calls, and how to scale it when the script is long. If you only need a quick test, the API key page gives new accounts a small trial credit.
Pick a format and say so
Models copy the format you show them. If you want a two-column script, show one row. A tiny example in the prompt beats a paragraph of description.
curl https://api.aivideogenapi.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"temperature": 0.8,
"messages": [
{"role": "system", "content": "You are a scriptwriter. Output a two-column script. Format each row as: VISUAL | NARRATION. About 150 words of narration in total. No headings."},
{"role": "user", "content": "Topic: why airports smell the way they do. Tone: wry. Audience: adults who travel for work."}
]
}'
The same request works with any OpenAI client once the base URL is https://api.aivideogenapi.com/v1. Details on authentication and fields are in the documentation.
For dialogue scripts, name the speakers in the prompt and give each a one-line voice note ("Mara: blunt, short sentences. Ilya: over-explains"). Without it, characters tend to sound alike by page two.
Settings that change the result
A few parameters matter more than the rest.
| Parameter | Use it for | Typical value |
|---|---|---|
temperature | Variety of wording | 0.7 to 0.9 for drafts, 0.3 to 0.5 for edits |
top_p | Trims unlikely words | 0.9 to 0.95; change this or temperature, not both |
max_tokens | Hard cap on reply length | Optional; set it when you want a guard against runaway output |
stop | End on a marker | For example "END SCENE" |
frequency_penalty | Reduces repeated phrases | 0.2 to 0.5 for long scripts |
seed | Repeatable drafts | Any integer |
These are passed through to the model. Do not expect identical output from the same seed after you change the prompt by even one word.
Short scripts: one call is enough
A 30 to 90 second script is a few hundred words. Send one request with the five parts and ask for a single draft. Then use a second message for edits, because editing a draft works better than regenerating from scratch.
from openai import OpenAI
client = OpenAI(base_url="https://api.aivideogenapi.com/v1", api_key="YOUR_KEY")
messages = [
{"role": "system", "content": "You write tight scripts for short videos. Plain narration, no stage directions."},
{"role": "user", "content": "Purpose: make viewers check their router settings. Tone: calm, a little amused. Length: 140 words."},
]
draft = client.chat.completions.create(model="uncensored", messages=messages, temperature=0.8)
text = draft.choices[0].message.content
messages += [
{"role": "assistant", "content": text},
{"role": "user", "content": "Keep the structure. Replace the opening line with a question, and cut the last sentence."},
]
final = client.chat.completions.create(model="uncensored", messages=messages, temperature=0.4)
print(final.choices[0].message.content)
Notice the temperature drop in the second call. Edits should follow instructions, not explore. If you want to watch the script appear, add stream: true and print each chunk as it arrives; the usage totals come at the end of the stream. A streamed request holds one of your concurrent slots until it finishes, which matters when you run several drafts in parallel. A full key allows 8 at once.
Long scripts: outline first, then acts
Ask for 4,000 words in one go and the middle sags: the model rushes the ending, repeats ideas and forgets small facts. A better pattern has three steps.
Step 1: the outline
Request a numbered outline with one sentence per scene, the purpose of each scene and a running list of facts that must stay consistent (names, places, what each character knows). Edit this by hand. It is the cheapest place to fix a story.
Step 2: act by act
For each act, send the outline, the style rules, a short summary of earlier acts and the full text of the last act. Ask for only the next act.
acts = []
summary = "None yet."
for n, goal in enumerate(outline_acts, start=1):
prompt = (
f"Outline:\n{outline_text}\n\nStory so far (summary): {summary}\n"
f"Previous act, full text:\n{acts[-1] if acts else '(none)'}\n\n"
f"Write act {n}: {goal}. About 600 words. Match the voice of the previous act."
)
r = client.chat.completions.create(
model="uncensored",
messages=[{"role": "system", "content": STYLE_RULES}, {"role": "user", "content": prompt}],
temperature=0.8,
)
acts.append(r.choices[0].message.content)
summary = summarize(acts) # one more short call
Step 3: the read-through
Send the full script back and ask for a list of contradictions and repeated lines, not a rewrite. Fix those with targeted edits.
Using the 100,000-token window
Prompt plus reply can reach 100,000 tokens, roughly 70,000 words. A full outline, a style guide and every finished act of a feature-length script fit comfortably. That means you can often skip summaries and just send the whole story so far, which keeps small details intact.
Two cautions. First, cost grows because each call re-sends the history. Second, very long prompts still work best when the instructions that matter most sit at the end, close to the request. Put the current task last, after the reference material. The page on the context window goes deeper on how to arrange long inputs.
Price check for a 10-minute script built in acts: suppose the calls total 6,000 input tokens and 4,000 output tokens. That is 6,000 / 1,000,000 x $0.15 = $0.0009 for input and 4,000 / 1,000,000 x $0.50 = $0.002 for output, so $0.0029 in all. Prices are listed on the pricing page.
Common problems and fixes
- The script is too long or too short. State a word range and add a stop point. Check the word count in code and ask for a trim with the exact number.
- Every scene opens the same way. Add a frequency penalty and a line such as "Vary how scenes begin; never open two scenes with a sound or a weather detail."
- The tone drifts. Paste two sample lines of the target voice into the system message and tell the model they are a style reference, not text to reuse.
- Stage directions leak into narration. Ask for separate fields (JSON mode with
response_formatset tojson_object) so narration and visuals never share a string. - HTTP 429. You hit a limit. The code
rate_limitedmeans too many requests per minute,concurrencymeans too many at once. Wait and retry.
More guides
Questions and answers
How many words should I ask for per minute of video?
Plan for about 150 spoken words per minute at a calm pace. Fast social clips can reach 170 or more, so test with a real voiceover.
Should I generate the whole script in one request?
For under about 800 words, yes. For longer scripts, write an outline first and generate act by act, passing the outline and the last act each time.
Does the model keep a memory between requests?
No. Each request is independent, so you send the history you want it to see in the messages list.
Can it write dark or mature fiction scripts?
The model is tuned to answer without content refusals for lawful adult use. Sexual content involving minors is never allowed.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.