Can hallucinations be prevented completely?
Not today. They can be reduced a lot by giving the model accurate sources, asking it to quote them, and checking results with tests or tools. Any output that matters should still be verified.
When a model confidently produces something false or made up, such as an API that does not exist.
A hallucination is when an AI model produces something false or invented and presents it as fact. Examples include a citation to a paper that does not exist, a function that is not in the library, or a configuration option that was never real. It happens because language models generate likely-sounding text based on patterns, not by looking facts up, so a plausible guess and a true statement can look the same to the model. Hallucinations are less common in newer models and when the model has the real information in front of it, but they have not been eliminated.
In coding, hallucinations show up as calls to methods that do not exist, outdated syntax or made-up command flags. The fix is mostly about the setup: give the agent the real documentation or source, tell it the exact commands in an instructions file, and make it run tests or the build so invented code fails fast instead of reaching review.
Asked to read a config file, a model writes config.loadSync(path), but the library only has config.load(path). In a chat, you might not notice until later. In an agent setup where AGENTS.md says "run npm test before you finish," the test fails, the agent reads the error, and corrects the call itself. The hallucination still happened, but it never reached a human reviewer.
Hallucination is not the model lying. It has no intent; it is producing the most plausible continuation. That is also why asking "are you sure?" is not a reliable check. Verify against a real source or a test.
All 28 terms are in the AI glossary. For models side by side, see frontier vs open-weight.
Not today. They can be reduced a lot by giving the model accurate sources, asking it to quote them, and checking results with tests or tools. Any output that matters should still be verified.
It can make outputs more consistent, but a model can give the same wrong answer every time. Lower temperature reduces randomness, not ignorance. Better context and verification help more.
A citation has a predictable shape, with authors, a title and a year, so the model can generate one that looks right without retrieving a real source. Tools that search and quote real documents reduce this.