Build an AI story generator with the chat API
An AI story generator can use an ordinary chat API for outlining, scene drafting and revision. Give the model a clear brief and a compact story bible, then generate one scene at a time. Keep character facts and plot decisions in your application so each new chapter can stay consistent.
Separate the outline, scene and revision requests
Start with genre, audience, tone, point of view and a target scene length. Ask for an outline before prose so a reader can approve the plot direction. Turn each outline beat into a scene request, then use a separate revision pass to check character names, timeline, established facts and pacing.
Store approved character facts, world rules, unresolved threads and a short chapter summary outside the conversation. Attach only the relevant parts when you draft the next scene. This makes continuity explicit and avoids repeatedly sending every earlier chapter. Keep the original draft and revised version so editors can accept changes selectively.
Example: generate a short story scene
This plain text example uses the listed gpt-6.1-sol chat ID. It requests a short scene with constrained characters and a plot beat. Output length is a prompt target, not a guarantee; max_tokens is a separate token cap. Check for truncation before showing a finished scene.
curl https://www.keyoapi.xyz/v1/chat/completions \
-H "Authorization: Bearer $KEYO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-6.1-sol","messages":[{"role":"system","content":"Write an original scene from the supplied brief. Preserve the established facts and avoid adding new main characters."},{"role":"user","content":"Genre: gentle mystery. Audience: adults. Story bible: Mira repairs clocks; her brother Len has been away for a year. Beat: Mira finds a clock running backward with a note signed Len. Write approximately 300 words in third person, ending with a question Mira must investigate."}],"max_tokens":700}'
Choose the model by editorial results
Evaluate a small fixed set of briefs across candidate models. Ask editors to score adherence to the brief, continuity, dialogue, pacing and the amount of rewriting required. The model with the lowest input price is not necessarily the cheapest per approved scene if its drafts need repeated retries.
Use the gpt-6.1-sol model page as a starting integration guide, GPT-6.1 Sol vs GPT-6 Astra for a GPT-class price comparison, and the Claude API pricing page for Claude-class candidates. Save the prompt and model alongside each draft so an editor can reproduce the workflow. Avoid claiming that a generated story is factually true or that every draft is publication-ready.
Plan the cost of a story workflow
For an illustrative 5,000-input and 1,000-output request, the checked Sol default-group rates produce about $0.003677. Three requests with that identical token mix cost about $0.011031 before retries and any extra charges. Outlining, drafting and revision usually have different token counts, so sum the actual usage from each response.
Expose a scene-length setting and a maximum revision count in your application. Reuse a compact story bible, stop when the editor accepts the draft, and keep failed drafts out of the published story. Audio narration is a separate workflow and charge; see the TTS API guide if you later add narration.
FAQ
Is there a dedicated story endpoint?
This guide uses POST /v1/chat/completions with a story prompt. Your application provides the story state, editor interface and revision workflow.
How do I keep characters consistent across chapters?
Store a story bible and approved chapter summaries, attach the relevant facts to each new request, and validate drafts against those facts before approval.
Is AI story generation free?
These chat requests are billed by usage. Welcome gift credits apply only to eligible gift-credit model IDs, are consumed first, and any shortfall is charged to recharge balance. The bare model in this example uses recharge balance; see the pricing page for current rates.