It uses a function that sounds perfect. The function does not exist.
Direct answer
AI hallucinations in code are invented functions, parameters, packages or settings that look real. They happen because models generate likely-looking text rather than verifying facts. Protect yourself by running code, checking the official docs and verifying every new package before you install it.
Typical forms
- A method that is not in the library.
- A configuration option that was removed or never existed.
- A package name that does not exist, which attackers can register to catch people out.
- Confident but wrong explanations.
How to catch them
- Run it. Errors reveal many hallucinations immediately.
- Check documentation for any unfamiliar function.
- Verify packages on the official registry: age, maintainers, downloads.
- Ask for sources and then check them yourself.
- Give the AI the real docs or the actual file to work from.
Where Teyro fits
Teyro's Working with AI Coding Agents course turns this into short lessons you can play in a few minutes a day. It has 60 lessons, and you can start free.
The bottom line
Trust, then verify. Especially before installing anything new.


