🤖 AI Summary
This work addresses the significant token redundancy in existing OpenAPI specifications when used in large language model (LLM) contexts, which hampers inference efficiency. To mitigate this, the authors propose LAPIS—a lightweight, LLM-optimized API specification that substantially reduces context length while preserving essential semantics. LAPIS achieves this through domain-specific constructs such as centralized error definitions, webhook trigger conditions, structured rate-limiting policies, and declarative operation workflows. Designed as a domain-specific language, LAPIS supports automatic conversion from OpenAPI 3.x without requiring a custom parser and remains compatible with the cl100k_base tokenizer. Experiments on five real-world APIs—including GitHub and Twilio—demonstrate that LAPIS reduces token consumption by 85.5% and 88.6% on average compared to OpenAPI YAML and JSON representations, respectively.
📝 Abstract
Large Language Models (LLMs) increasingly serve as consumers of API specifications, whether for code generation, autonomous agent interaction, or API-assisted reasoning. The de facto standard for API description, OpenAPI, was designed for documentation tools and code generators, resulting in substantial token overhead when used as LLM context.
We present LAPIS (Lightweight API Specification for Intelligent Systems), a domain-specific format optimized for LLM consumption that preserves the semantic information necessary for API reasoning while minimizing token usage. Through empirical evaluation against five real-world production API specifications including GitHub (1,080 endpoints), Twilio (197 endpoints), DigitalOcean (545 endpoints), Petstore, and HTTPBin we demonstrate an average token reduction of 85.5% compared to OpenAPI YAML and 88.6% compared to OpenAPI JSON, measured with the cl100k_base tokenizer. LAPIS introduces domain-specific structural innovations, including centralized error definitions, webhook trigger conditions, structured rate limit descriptions, and operation flow declarations information that OpenAPI either duplicates redundantly or cannot represent at all.
The format is fully convertible from OpenAPI 3.x via an automated converter, requires no special parser for LLM consumption, and is released as an open specification under CC BY 4.0.