What is AI hallucination?
A hallucination is a confident, fluent answer that happens to be wrong. It follows from how language models work, and the fixes are about grounding and checking, not hoping.

Key takeaways
- A hallucination is AI output that sounds right but is false or invented, such as a fake citation or a function that does not exist.
- It happens because models generate likely text rather than look facts up.
- Reduce it by giving the model the source material, asking for structured output, allowing "I don't know", and verifying by running or checking.
An AI hallucination is output from an AI model that is presented confidently but is false, unsupported or made up, like an invented statistic, a quote nobody said, a court case that does not exist, or code that calls a library function with the right-sounding name and no real existence.
An everyday parallel is a well-meaning stranger asked for directions in a city they half know. Rather than say "not sure", they point confidently down a street. The tone gives no clue that they are guessing.
Why it happens
A large language model produces text by predicting what plausibly comes next. For well-covered facts, plausible and true usually coincide. For rare facts, recent events, exact numbers or specifics it never saw, the most plausible-sounding continuation can be invented. Training rewards fluent, helpful answers, so without care a model may fill a gap rather than admit it. Missing context makes it worse: ask about your own company's refund policy without supplying it, and the model will describe a typical one.
The forms it takes
- Invented facts and figures: a precise percentage with no source.
- Fake references: real-looking article titles, URLs or paper authors that do not exist.
- Code hallucinations: imports of packages that were never published, options a library does not support, outdated APIs.
- Misread input: a summary that adds a claim the document never made.
- False confirmation: "I have fixed the bug" when nothing was tested.
How this plays out when you build with Startbase
For code, the cure is running it. Startbase's agent tests what it builds and runs your app before it finishes a turn, so a made-up function or package tends to surface as an error it then fixes, rather than reaching you (how the agent checks its work). It is still worth clicking through the changed screens yourself, and if a turn went wrong, restore the earlier version (checkpoints and undo). When something is broken, describe what you see rather than accept a claimed fix (fixing bugs with AI).
For AI features inside your own app, design against hallucination from the start:
- 01Ground it: put the real source text in the prompt, retrieved from your data (what RAG is).
- 02Allow "I don't know": tell the model to say so when the answer is not in the provided text, and show that state in the UI.
- 03Ask for structure: JSON with fixed fields and allowed values is easier to validate than free prose.
- 04Show sources: link each answer to the passage it came from so users can check.
- 05Keep humans on high-stakes calls: anything medical, legal, financial or irreversible gets a review step.
Make the help assistant answer only from our help articles. For each question, retrieve the three most relevant articles and pass them to invokeLLM with the instruction: answer only from these articles; if they do not contain the answer, reply exactly "I could not find that in our help center" and offer the contact form. Show links to the articles used under each answer.
Common confusions
- "Newer models do not hallucinate." They do it less in many areas, but no current model is free of it. Design for checking.
- Hallucination vs bias. Bias is a skewed pattern in answers; hallucination is fabricated content. Both need different checks.
- "Asking it to be accurate fixes it." Instructions help a little. Supplying the facts and verifying the output help far more.
For the broader question of trusting generated software, read is AI-generated code safe?
Frequently asked questions
Can AI hallucination be fully eliminated?
Not with current technology. It can be reduced a lot by grounding answers in real sources, constraining the output and checking results automatically or by a person.
How do I spot a hallucination?
Be most suspicious of specific details: exact numbers, names, dates, quotes, links and package names. Check them against a source or by running the code.

