Hallucination
When a model states something false with complete confidence — an API that does not exist, a function that was never written.
Not the same as a bug
A bug is code that does the wrong thing. A hallucination is code that calls something which was never there — a function, a flag, a whole library — stated with exactly the confidence of the parts that were right.
Where it bites
It clusters at the edges of what is popular. Common libraries are usually fine; the invented call shows up in the small, recent or niche API, which is precisely where you are least able to spot it.
In practice
The cheap check is to run it. An invented import fails on the first execution, which is why running beats reading for this specific class of error.
Covered in these lessons
Related terms
Where this comes up
Also written as hallucination, hallucinate. Checked 2026-08-06.