TY - GEN
T1 - LLM-based API Argument Completion with Knowledge-Augmented Prompts
AU - Akram, Waseem
AU - Jiang, Yanjie
AU - Khan, Haris Ali
AU - Jalil, Furqan
AU - Liu, Hui
N1 - Publisher Copyright:
© 2026 Copyright held by the owner/author(s).
PY - 2026/9/11
Y1 - 2026/9/11
N2 - Application Programming Interfaces (APIs) are fundamental to modern software development, yet accurately completing API method arguments remains a challenging task. Existing methods, such as information retrieval and hybrid program analysis with language models, often struggle with static code patterns and limited domain-specific knowledge. To this end, in this paper, we introduce APICopilot, a novel approach that enhances LLM-based API argument completion using dynamically generated, context-rich prompts. First, it creates an input knowledge graph (KG) from the preceding code for the to-be-complete API invocation, and a targeted knowledge graph from a collection of similar code files, both representing the anticipated API call. Second, it quantifies structural and semantic alignment between the two KGs and retrieves relevant subgraphs from the targeted graph. These subgraphs provide crucial structural context for in-context learning, enabling significantly more accurate and context-specific argument completions. Finally, we integrate the subgraphs into prompts and request LLMs to recommend API arguments. Our evaluation results on 54,000 Java files suggest that the proposed approach outperforms the state-of-the-art approach, improving precision, recall, and mean reciprocal rank by 38%, 36% and 23%, respectively.
AB - Application Programming Interfaces (APIs) are fundamental to modern software development, yet accurately completing API method arguments remains a challenging task. Existing methods, such as information retrieval and hybrid program analysis with language models, often struggle with static code patterns and limited domain-specific knowledge. To this end, in this paper, we introduce APICopilot, a novel approach that enhances LLM-based API argument completion using dynamically generated, context-rich prompts. First, it creates an input knowledge graph (KG) from the preceding code for the to-be-complete API invocation, and a targeted knowledge graph from a collection of similar code files, both representing the anticipated API call. Second, it quantifies structural and semantic alignment between the two KGs and retrieves relevant subgraphs from the targeted graph. These subgraphs provide crucial structural context for in-context learning, enabling significantly more accurate and context-specific argument completions. Finally, we integrate the subgraphs into prompts and request LLMs to recommend API arguments. Our evaluation results on 54,000 Java files suggest that the proposed approach outperforms the state-of-the-art approach, improving precision, recall, and mean reciprocal rank by 38%, 36% and 23%, respectively.
KW - API
KW - Code Completion
KW - Knowledge Graph
KW - LLM
UR - https://www.scopus.com/pages/publications/105051915621
U2 - 10.1145/3744916.3773158
DO - 10.1145/3744916.3773158
M3 - Conference contribution
AN - SCOPUS:105051915621
T3 - Proceedings - 2026 IEEE/ACM 48th International Conference on Software Engineering, ICSE 2026
SP - 881
EP - 893
BT - Proceedings - 2026 IEEE/ACM 48th International Conference on Software Engineering, ICSE 2026
PB - Association for Computing Machinery, Inc
T2 - 48th International Conference on Software Engineering, ICSE 2026
Y2 - 12 April 2026 through 18 April 2026
ER -