StableToolBench-MirrorAPI: Modeling Tool Environments as Mirrors of 7, 000+ Real-World APIs

Zhicheng Guo, Sijie Cheng, Yuchen Niu, Hao Wang, Sicheng Zhou, Wenbing Huang, Yang Liu

Abstract

The rapid advancement of large language models (LLMs) has spurred significant interest in tool learning, where LLMs are augmented with external tools to tackle complex tasks. However, existing tool environments face challenges in balancing stability, scale, and realism, particularly for benchmarking purposes. To address this, we propose MirrorAPI, a novel framework that trains specialized LLMs to accurately simulate real API responses, effectively acting as “mirrors” to tool environments. Using a comprehensive dataset of request-response pairs from 7,000+ APIs, we employ supervised fine-tuning and chain-of-thought reasoning to enhance simulation fidelity. MirrorAPI achieves superior accuracy and stability compared to state-of-the-art methods, as demonstrated by its performance on the newly constructed MirrorAPI-Bench and its integration into StableToolBench.

Introduction: The Environment Trilemma

Evaluating LLMs in tool-augmented scenarios is critical but hampered by the "Environment Trilemma." Real-world APIs are often unstable due to network issues, developer updates, and rate limits. Conversely, manually mocked environments lack scalability, while general-purpose LLM simulations often fail to capture the "realness"—the structured and nuanced behavior—of actual software responses.

The Environment Trilemma: MirrorAPI aims to balance Stability, Scalability, and Realness in tool learning environments.

MirrorAPI addresses these challenges by providing a simulated environment that is as stable as a local script but as realistic as the live web, scaling across thousands of diverse APIs.

Methodology

MirrorAPI utilizes a specialized simulator model based on Qwen-2.5-7B, trained to understand the underlying mechanisms of API processing rather than simply predicting outputs.

Data Collection and Reasoning Augmentation

The framework leverages a dataset of over 7,000 APIs crawled from RapidAPI. To ensure high fidelity, the authors used OpenAI’s o1-preview to generate "rationales"—Chain-of-Thought (CoT) explanations of how an API processes a specific request. The model is trained in two modes:

  • SFT Mode: Direct generation of the JSON response.
  • CoT Mode: Generation of internal logic reasoning before the final response, which is crucial for generalizing to unseen (Out-of-Distribution) APIs.

Experimental Results

MirrorAPI-Bench was used to evaluate the simulator's performance on both In-Distribution (ID) and Out-of-Distribution (OOD) sets. On OOD tasks, MirrorAPI achieved a BLEU score of 89.9 and a Cosine Similarity of 94.1% relative to real API responses, vastly outperforming general models like GPT-4o (which scored 10.7 and 36.0, respectively).

Comparison of tool-use performance scores across different environments. MirrorAPI (Ours) closely tracks the performance of the Real environment, unlike general-purpose LLM simulators.

When integrated into StableToolBench, MirrorAPI demonstrated that it could serve as a reliable proxy for real-world environments. As shown in the results, the performance of various tool-using models (e.g., GPT-4o mini, ToolLLaMA) when evaluated in the MirrorAPI environment ("Ours") is nearly identical to their performance in the "Real" environment, providing a stable and reproducible benchmark.

Conclusion and Future Work

MirrorAPI successfully bridges the gap between simulated and real-world tool environments. By specializing a 7B model with reasoning-augmented training, it provides a high-fidelity, scalable, and stable sandbox for tool learning. Future work will focus on addressing current limitations, such as occasional hallucinations and the neglect of specific parameter constraints, and extending the framework to simulate complex failure modes and ethical vulnerabilities.

Summary updated

BibTeX
@inproceedings{guo2025stabletoolbench,
  author = {Zhicheng Guo and Sijie Cheng and Yuchen Niu and Hao Wang and Sicheng Zhou and Wenbing Huang and Yang Liu},
  title = {{StableToolBench-MirrorAPI: Modeling Tool Environments as Mirrors of 7, 000+ Real-World APIs}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=htq5IwokLR},
}
Figure