aibeginner

Hallucination

When AI confidently says something wrong.

What is Hallucination?

AI tools sometimes generate code that looks correct but doesn't work — or references functions that don't exist. This is called hallucination. Always test AI-generated code rather than assuming it works.

Hallucinations happen because the AI is predicting the most likely next word, not verifying facts. It can be confidently wrong. The bigger and more complex your request, the more likely a hallucination.

In Vibe Coding

In vibe coding, hallucinations look like code that references functions that don't exist, imports packages that were never installed, or uses API methods that don't work. Always test AI-generated code — don't assume it's correct.

Example

For example: You ask Cursor to integrate with a payment API. It writes code using stripe.charges.create() — but that method was deprecated years ago. The code looks right and compiles fine, but fails at runtime.

Related Terms

Related Guides