Skip to main content
  • Home
  • AI Generator
  • Explore
  • Favorites
  • Calendar
  • History
  • Recipes
  • Blog
  • Profile
Back to Blog
technologyaihow-it-works

How AI Writes Fortunes: LLMs, Tokens & Temperature

Fortune Cookie AI Team
December 15, 2025
7 min read
Cover image for How AI Writes Fortunes: LLMs, Tokens & Temperature

Related Articles

The Future of Fate: From Paper Strips to AR Fortune Cookies

Discover how AR, VR, and spatial computing are transforming fortune cookies into immersive digital experiences. Explore the evolution from paper to holographic fortunes.

January 1, 2026

AI Fortune Telling 2025: Digital Destiny & The Future of Luck

Explore how AI is transforming fortune telling in 2025. From digital horoscopes to AI tarot, discover the new era of personalized prophecy.

December 5, 2025

Fortune Cookie Marketing: 5 Ways Brands Use Edible Gamification to Engage Customers (2026)

Learn how brands use fortune cookie marketing for customer engagement. 5 proven strategies with QR codes, social challenges, and AI-generated messaging.

February 8, 2026

🥠 Try Your Luck!

Generate your own personalized fortune cookie message

Open Fortune Cookie

Fortune Cookie AI

Powered by AI

Get personalized fortune cookie messages powered by AI. Inspirational quotes, funny sayings, and lucky numbers await!

Generate

  • Fortune Generator
  • AI Generator
  • Browse Messages

Learn

  • History
  • Who Invented?
  • Recipes

Messages

  • All Messages
  • Funny Messages
  • How to Make

Popular Searches

  • Funny Fortune Messages
  • Who Invented Fortune Cookies
  • How to Make Fortune Cookies
  • Inspirational Quotes

Fortune Categories

  • Love Fortune Cookies
  • Success Messages
  • Wisdom Quotes
  • Friendship Messages

Learn More

  • Fortune Cookie History
  • Fortune Cookie Recipes
  • Blog & Articles
  • AI Generator

Resources

  • My Favorites
  • Fortune Database
  • Sitemap
  • Contact Us

© 2026 Fortune Cookie AI. All rights reserved. Made with love for fortune seekers everywhere

AboutPrivacy PolicyTerms of ServiceCookie Policy

Free online AI-powered fortune cookie generator. Get personalized inspirational messages, funny quotes, and lucky numbers.

When you ask our AI for a fortune, it doesn't pull a pre-written sentence from a database. It generates one on the spot, specifically for you. But how does a collection of silicon chips mimic the wisdom of an ancient oracle?

We built Fortune Cookie AI from scratch, and we want to be transparent about how it actually works — no mysticism, no hand-waving, just the real engineering. Here's a behind-the-scenes look at the technology, the decisions we made, and the trade-offs involved.

The Architecture: What Actually Happens When You Click "Get Fortune"

Here's the real pipeline, step by step:

  1. You choose a theme (funny, inspirational, love, success, wisdom, or random) and optionally set a mood and length preference.
  2. Our server receives the request and first checks a Redis cache to see if a similar fortune was recently generated.
  3. If no cached result exists, we send a request to an LLM (Large Language Model) via the OpenRouter API — a routing service that gives us access to multiple AI models.
  4. The AI generates a fortune based on a carefully crafted system prompt specific to the chosen theme.
  5. We cache the result, assign lucky numbers, and send it back to you.
  6. If anything fails — the API is down, the model is overloaded, or we hit a rate limit — the system falls back to our database of 500+ pre-written fortune messages.

This fallback chain is critical. Nobody should ever click "Get Fortune" and see an error. At worst, you get a pre-written fortune instead of a freshly generated one, and you'd never know the difference.

From Words to Numbers: How Tokenization Works

Computers don't understand words — they understand numbers. Before an LLM can process your request, the text has to be broken into chunks called tokens. A token can be a word, part of a word, or even a single character.

For example:

| Input | Tokens | |-------|--------| | "What is my destiny?" | ["What", " is", " my", " dest", "iny", "?"] | | "fortune cookie" | ["fort", "une", " cookie"] |

Each token gets mapped to a numerical vector — a list of numbers representing its meaning and context. In the model's high-dimensional space, the vector for "destiny" sits close to "fate" and "future" but far from "sandwich" or "spreadsheet."

This is why AI can understand that "What does the future hold?" and "What's my destiny?" are asking essentially the same thing, even though the words are different.

System Prompts: Giving the AI a Persona

The most important part of our engineering isn't the model — it's the system prompt. This is the instruction we give the AI before it sees your request. Think of it as the AI's "character sheet."

For each theme, we use a different prompt. Here's a simplified version of what the "wisdom" theme prompt looks like:

"You are a wise fortune cookie writer. Create thoughtful, philosophical messages that offer life wisdom, ancient proverbs, and timeless truths. Focus on deeper meaning and reflection. Output ONLY the fortune message itself — no explanations, no additional text. Just the fortune in 1-2 sentences under 100 characters."

That last constraint — "under 100 characters" — is crucial. A real fortune cookie slip is about 7cm long. If the AI writes a paragraph, it stops feeling like a fortune and starts feeling like a blog post. The art is in the compression.

We've iterated on these prompts dozens of times. Early versions produced fortunes that were too generic ("Good things are coming") or too long ("In the grand tapestry of life, every thread of experience weaves together to create the beautiful pattern of your unique journey"). Getting the tone right — concise, warm, slightly mysterious — took more experimentation than we expected.

Temperature: The Creativity Dial

If the AI always picked the statistically most likely next word, every fortune would sound the same. It might always say: "You will have a good day."

To introduce variety, LLMs have a parameter called temperature:

| Temperature | Behavior | Example Output | |-------------|----------|----------------| | 0.1 (low) | Conservative, predictable, repetitive | "You will find success in your endeavors." | | 0.5 (medium) | Balanced creativity with coherence | "The detour you're taking is the shortcut you didn't know existed." | | 0.9 (high) | Creative, surprising, occasionally weird | "Your shadow has been taking notes. It's impressed." | | 1.2+ (very high) | Chaotic, often incoherent | "Purple velocities dream the accordion of starfish wisdom." |

We use a moderate temperature setting — high enough to avoid repetition, low enough to keep the output coherent and meaningful. Finding this sweet spot was one of our earliest challenges. Too conservative and the fortunes feel mass-produced; too creative and they stop making sense.

The 500+ Fallback Database

AI generation is unreliable by nature. Models go down, APIs time out, rate limits hit. So we maintain a curated database of 500+ pre-written fortune messages across six categories: funny, inspirational, love, success, wisdom, and general.

These aren't random sentences — each one was written and categorized by hand, with tags, lucky numbers, and a popularity score. When the AI isn't available, the system selects from this database based on your chosen theme and mood.

In practice, about 15–20% of fortunes served on any given day come from this fallback database. Users don't notice, and that's the point — the experience should be seamless whether the fortune was generated by AI or pulled from our curated collection.

Traditional vs. AI Fortune Writing: A Comparison

| Aspect | Traditional (Factory) | AI-Generated | |--------|----------------------|--------------| | Writer | Single person (e.g., Donald Lau at Wonton Food wrote fortunes for 30+ years) | Language model with billions of parameters | | Variety | ~10,000 fortunes in rotation | Virtually unlimited unique combinations | | Personalization | None — same fortune for everyone | Theme, mood, and language customization | | Production speed | One writer can produce a few fortunes per day | Hundreds per second | | Quality control | Human editorial review | Prompt engineering + output constraints | | Cultural nuance | Deep personal knowledge of the audience | Trained on diverse text corpus, but can miss subtle context | | Cost per fortune | Salary of a writer | Fraction of a cent per API call |

Neither approach is strictly "better." Traditional fortune writing has a human warmth and cultural intuition that's hard to replicate. AI brings scale and personalization that a single writer can't match. Our approach uses both — AI for fresh content, human-curated database for reliability.

What AI Can't Do (Yet)

Honesty matters, so here's what our AI doesn't do well:

  • It doesn't know you. It can't read your palm, your birth chart, or your browsing history. The "personalization" comes from theme and mood selection, not from anything mystical or invasive.
  • It sometimes generates bland output. Not every AI fortune is a gem. Some are generic, some are awkward. We filter for quality, but the hit rate is about 80%, not 100%.
  • It can't predict the future. Obviously. But neither could the fortune writers of the past. The value of a fortune isn't in its accuracy — it's in the moment of reflection it creates.

Key Takeaway

Behind every AI-generated fortune is a pipeline of engineering decisions: which model to use, how to prompt it, what temperature to set, how to handle failures, and when to fall back to human-written alternatives. It's not magic — it's a carefully balanced system designed to deliver a moment of surprise and reflection.

The technology is impressive, but the goal is simple: give you something worth reading when you crack open that virtual cookie.


Ready to see it in action? Generate your own AI fortune and see what the algorithm has in store for you. Or if you're curious about the psychology behind why fortunes feel so personal, read our deep dive into the psychology of fortune cookies.