Intelligent API Contract Testing Using Large Language Models and Machine Learning Techniques

Authors

  • Nithish Yadav Thotla

Keywords:

Intelligent API contract testing, Large Language Models, Machine Learning, cloud-native applications, semantic drift detection, software quality, API validation, CI/CD.

Abstract

Intelligent API Contract Testing has emerged as a vital tool for software quality improvement in cloud-native microservice architectures. However, traditional methods for API contract testing validate only schemas of requests and responses without discovering semantic inconsistencies, behavioural drifts, and changes in API interaction. This paper explores how Large Language Models (LLMs) and Machine Learning (ML) enhance the process of API contract testing by means of automatic validation, reasoning, anomaly detection, and test generation. The study has been carried out via secondary data collection by reviewing the existing literature based on peer-reviewed journal papers, technical reports, industry materials, and the Stanford Artificial Intelligence Index Report 2021. Qualitative research was chosen to interpret the available evidence, and an inductive approach for developing the findings on the basis of the existing research. The thematic analysis was used as a tool for identifying themes associated with the performance of LLMs, accuracy of machine learning, API contract error detection, software quality, and cloud-native testing. The results indicate that API validation through machine learning provides accuracy of 79% to 92.1% in contract violation prediction and semantic consistency detection. Hybrid approaches using both LLMs and machine learning (ML) enhance the accuracy of the validation process, minimise false alerts and provide support. The paper also draws attention to the fact that AI is becoming increasingly involved in software engineering, which is evident from the number of publications and cooperation with the industry. As a result, intelligent API contract testing can be considered an automated approach that guarantees API compatibility and software quality.

Downloads

Download data is not yet available.

References

Ali, S. O., Ali, S. A., & Jafri, R. (2026). Data-Driven Contract Management at Scale: A Zero-Shot LLM Architecture for Big Data and Legal Intelligence. Technologies, 14(2), 88.

Artificial Intelligence Index Report 2021. Artificial Intelligence Index Report 2021. https://hai.stanford.edu/assets/files/2021-ai-index-report_master.pdf

Burke, B., 2022. Artificial Intelligence & Machine Learning Report. https://pitchbook.com/news/reports/2021-annual-artificial-intelligence-machine-learning-report

Control System Cyber Security Association International & KPMG International (2020). CS²AI–KPMG Control System Cyber Security Annual Report 2020.https://assets.kpmg.com/content/dam/kpmg/xx/pdf/2020/10/kpmg-control-system-cyber-security-annual-report.pdf

Jin, H., Huang, L., Cai, H., Yan, J., Li, B., & Chen, H. (2024). From LLMs to LLM-based agents for software engineering: A survey of current, challenges and future. arXiv preprint arXiv:2408.02479.

Karlsson, S., Hughes, J., Jongeling, R., Čaušević, A., & Sundmark, D. (2024). Exploring API behaviours through generated examples. Software Quality Journal, 32(2), 729-763.

Khairunnesa, S. S., Ahmed, S., Imtiaz, S. M., Rajan, H., & Leavens, G. T. (2023). What kinds of contracts do ML APIs need?. Empirical Software Engineering, 28(6), 142.

Li, M., Li, D., Liu, J., Cao, J., Tian, Y., & Cheung, S. C. (2026). Enhancing differential testing with llms for testing deep learning libraries. ACM Transactions on Software Engineering and Methodology, 35(4), 1-39.

Marculescu, B., Zhang, M., & Arcuri, A. (2022). On the faults found in REST APIs by automated test generation. ACM Transactions on Software Engineering and Methodology (TOSEM), 31(3), 1-43.

McKinsey, 2022. The state of AI in 2022—and a half decade in review. https://www.mckinsey.com/capabilities/quantumblack/our-insights/the-state-of-ai-in-2022-and-a-half-decade-in-review

Ouédraogo, W. C., Li, Y., Dang, X., Borsukiewicz, P., Xiao, L., Bao, L., ... & Bissyandé, T. F. (2026). Semantic Drift in Bug Resolution: How Behavioral Signals Propagate from Reports to Tests and Patches. arXiv preprint arXiv:2607.18550.

Pasumarthi, H. (2025). AI-Augmented API Gateways: Intelligent Traffic Management, Threat Detection, and Adaptive Policy Enforcement. International Journal of Engineering & Extended Technologies Research (IJEETR), 7(3), 1290-1294.

PM, V. P., & Soumya, S. (2024). Advancements in anomaly detection techniques in network traffic: The role of artificial intelligence and machine learning. Journal of Scientific Research and Technology, 38-48.

Romel, T. H., Amin, K. W., Mahmod, I. B., & Rahman, A. (2025). Contracts for Large Language Model APIs: A Comprehensive Taxonomy, Detection Framework, and Enforcement Strategies.

Selalsingh, V., Benson, J., Crowther, G., Emerson, C., Outa, H., Miles, J., ... & Hernandez, E. (2025). Integrating Explainable Artificial Intelligence (XAI) with Gradient-Boosted Decision Trees for Predicting Multi-Stage Attack Success in Cloud-Native Infrastructures.

Smela, B., Toumi, M., Świerk, K., Francois, C., Biernikiewicz, M., Clay, E., & Boyer, L. (2023). Rapid literature review: definition and methodology. Journal of market access & health policy, 11(1), 2241234.

Stanford Institute for Human-Centered Artificial Intelligence. (2021). Artificial Intelligence Index Report 2021. https://hai.stanford.edu/assets/files/2021-ai-index-report_master.pdf

Tong, Y., Tan, W., Guo, J., Shen, B., Qin, P., & Zhuo, S. (2022). Smart contract generation assisted by AI-based word segmentation. Applied Sciences, 12(9), 4773.

Tupe, V., & Thube, S. (2025). AI Agentic workflows and Enterprise APIs: Adapting API architectures for the age of AI agents. arXiv preprint arXiv:2502.17443.

Xu, J., Li, J., Liu, Z., Suryanarayanan, N. A. V., Zhou, G., Guo, J., ... & Tei, K. (2024). Large language models synergize with automated machine learning. arXiv preprint arXiv:2405.03727.

Downloads

Published

30.09.2024

How to Cite

Nithish Yadav Thotla. (2024). Intelligent API Contract Testing Using Large Language Models and Machine Learning Techniques. International Journal of Intelligent Systems and Applications in Engineering, 12(22s), 2546 –. Retrieved from https://ijisae.org/index.php/IJISAE/article/view/8555

Issue

Section

Research Article