Publication Type
Journal Article
Version
acceptedVersion
Publication Date
3-2026
Abstract
API misuse in code generated by large language models (LLMs) presents a serious and growing challenge in software development. While LLMs demonstrate impressive code generation capabilities, their interactions with complex library APIs are often error-prone, potentially leading to software failures and vulnerabilities. In this paper, we conduct a large-scale study of API misuse patterns in LLM-generated code, analyzing both method selection and parameter usage across Python and Java, using three representative LLMs (StarCoder-7B, Qwen2.5-Coder-7B, and GitHub Copilot). Based on extensive manual annotation of 3,209 method-level and 3,492 parameter-level misuses, we identify and categorize four recurring misuse types by building on and refining prior API misuse taxonomies. Our evaluation of three widely used LLMs, StarCoder-7B, Qwen2.5-Coder-7B, and GitHub Copilot, reveals persistent challenges in API usage, particularly hallucination and intent misalignment. To address these issues, we propose Dr.Fix, an LLM-based automatic repair approach guided by our taxonomy. Dr.Fix improves repair accuracy compared to baseline prompting and existing repair methods, with gains of up to 38.4 BLEU and 40% in exact match on benchmark datasets. This work offers important insights into the current limitations of LLMs in API usage and provides insights into current limitations and points to directions for improving automated misuse repair in code generation systems.
Keywords
API Misuse, Automatic Program Repair, Code Generation, Empirical Software Engineering, Large Language Model
Discipline
Artificial Intelligence and Robotics | Software Engineering
Research Areas
Intelligent Systems and Optimization
Areas of Excellence
Digital transformation
Publication
IEEE Transactions on Software Engineering
Volume
52
Issue
3
First Page
855
Last Page
873
ISSN
0098-5589
Identifier
10.1109/TSE.2026.3651566
Publisher
Institute of Electrical and Electronics Engineers
Citation
ZHUO, Terry Yue; HE, Junda; SUN, Jiamou; XING, Zhenchang; LO, David; GRUNDY, John; and DU, Xiaoning.
Identifying and mitigating API misuse in large language models. (2026). IEEE Transactions on Software Engineering. 52, (3), 855-873.
Available at: https://ink.library.smu.edu.sg/sis_research/11283
Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-No Derivative Works 4.0 International License.
Additional URL
https://doi.org/10.1109/TSE.2026.3651566