AI
LLMs Struggle with APIs: New Study Maps Misuse Patterns and Proposes Automated Repair
Researchers identified recurring API misuse problems in code generated by major language models and developed a taxonomy-guided repair method to automatically fix them.
Large language models have proven remarkably capable at generating code, but a new investigation reveals a persistent blind spot: their interactions with library APIs remain error-prone and frequently lead to broken or unsafe software. Researchers analyzed API misuse patterns across three widely-used code-generating models to understand where and why these failures occur.
The Problem: Widespread API Misuse#
The study examined code produced by StarCoder-7B, Qwen2.5-Coder-7B, and GitHub Copilot, focusing on two categories of mistakes: selecting the wrong method and passing incorrect parameters. By manually annotating over 6,000 instances of misuse—3,209 method-level errors and 3,492 parameter-level errors—across Python and Java, the researchers uncovered a troubling pattern. The models struggle particularly with hallucination (inventing functions or parameters that don't exist) and intent misalignment (using a real API in a way that doesn't match the intended behavior).
A Taxonomy and Automated Fix#
Rather than simply cataloging failures, the team developed a structured taxonomy that groups API misuses into four distinct categories, refining earlier classification schemes. Armed with this framework, they built an LLM-powered repair tool that leverages the taxonomy to guide automatic corrections. The approach significantly outperforms baseline prompting strategies and competing repair methods, achieving improvements of up to 38.4 BLEU score and 72 additional exact-match corrections on benchmark test sets.
Why This Matters#
As LLMs become more embedded in software development workflows—from IDE plugins to code review systems—these API misuse patterns represent a real safety and reliability risk. The research highlights fundamental gaps in how current models understand complex library semantics and usage constraints, pointing toward the need for better training approaches or guardrails that can catch these errors before code is deployed.

