arXiv:2610.13273cs.SEOct 2026

Manuscript Offprint

arXiv:2610.13273

Agent4Spec: An LLM-based Agentic System to Optimize API Specifications through Automated Validation and Market Analysis

Yongjian Tang, Costel Moraru, Doruk Tuncel, Hanya Elhashemy, Steffen Klepke, Thomas Runkler

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Yongjian Tang ∗^{*} †^{\dagger}, Costel Moraru ∗^{*}, Doruk Tuncel ∗^{*}, Hanya Elhashemy ∗^{*}, Steffen Klepke ∗^{*}, Thomas Runkler ∗^{*} †^{\dagger}

∗^{*}Siemens Research (RPD), Munich, Germany

†^{\dagger}Technical University of Munich, Munich, Germany

Abstract—API specifications serve as critical documentation for modern software development, directly impacting integration efficiency and client code generation. While recent advancements have leveraged Large Language Models (LLMs) to generate initial specifications from source code, existing approaches treat this process as a one-time event – overlooking the needs for continuous validation, long-term maintenance, and market-driven evolution of these artifacts. To address this issue, we present Agent4Spec, an autonomous multi-agent framework featuring two distinct pipelines: (1) a validation pipeline that detects and self-corrects OpenAPI syntax errors, and (2) a market analysis pipeline that conducts competitive research, identifies functional gaps against industry leaders, and automatically generates missing API-spec functionalities. We evaluate Agent4Spec on two curated datasets of API specifications spanning both general-purpose and industrial scenarios. Among 9 SOTA LLMs, the top-performer achieves 100% syntax error detection rates and over 95% implementation success for proposed corrections, while securing over 50% adoption rates for suggested endpoint improvements, representing a practical tool for API development.

Index Terms—LLMs, agents, software engineering, APIs

I. INTRODUCTION

API specifications define the operational contract between service providers and consumers. For REST services, OpenAPI Specification (OAS) documents describe endpoints, parameters, schemas, and error cases in a machine-readable form. Such specifications support client integration, API testing, and long-term maintenance, while inaccurate or incomplete specifications can mislead developers and propagate failures across downstream tools. As software ecosystems evolve, maintaining both the syntactic validity and practical relevance of these specifications becomes increasingly difficult.

Recent work has made substantial progress in generating API specifications from source code [5], [8], [9], [28] and online documentation [6], [7]. Other studies have examined LLMs for API documentation understanding and updates [2]–[4], [29]. However, these efforts mainly target initial specification construction or document-level maintenance. They provide limited support for the post-generation stage, where developers must validate full OAS files, implement repairs safely, and decide whether the API should evolve to match current market expectations.

To address this gap, we present Agent4Spec, a multi-agent system for post-stage API specification validation and enhancement. As shown in Figure 1, Agent4Spec uses an orchestrator agent to route developer requests into two task-specific pipelines. The validation pipeline detects OAS syntax errors and proposes corrections through tool-assisted checking. The market analysis pipeline identifies the API domain, searches for competing services and current trends, analyzes functional gaps, and suggests endpoint-level improvements. A revision agent can then apply approved changes to the original specification, with optional human review before market-driven changes are implemented.

We evaluate Agent4Spec on two curated datasets, Guru-Spec and Industry-Spec, covering both general-purpose and industrial API scenarios. The experiments include nine LLMs across proprietary frontier and compact open-weight tiers, allowing us to study both effectiveness and resource tradeoffs. Our main contributions can be summarized as follows:

(i) We formulate API specification enhancement as a post-generation workflow that jointly considers syntax validation, market analysis, and specification revision.

(ii) We propose Agent4Spec, a multi-agent framework that coordinates specialized agents for validation, competitive analysis, endpoint suggestion, and optional human-approved revision.

(iii) We construct two evaluation datasets, Guru-Spec and Industry-Spec, to measure Agent4Spec across general-purpose and industrial API specifications.

(iv) We conduct an extensive evaluation across 9 LLMs. The strongest frontier models achieve 100% syntax-error detection, over 95% correct implementation for proposed corrections, and up to 1.82 human-approved endpoint suggestions out of three, while the same evaluation also exposes practical limitations of compact models in tool use, full-file revision, and market-oriented analysis.

References (29)