OpenRouter:数据说明令文本转SQL准确率达99%
OpenRouter以六个模型、22个已知答案问题和一个合成商店数据库测试文本转SQL智能体。仅提供数据库结构时,完成运行的准确率为95%;加入五行数据异常说明后升至99%,且五个模型从未生成失败查询。结果仅基于一个合成数据库,Gemini还有24次请求失败,使其完成运行数较少。
测试表明,单位、不一致国家代码等数据特征说明,可能比生成有效SQL更影响结果,为智能体提示设计和数据库只读访问提供实用参考。
Text-to-SQL Agent: How It Works and What Makes It Accurate
OpenRouter ·12/3/2026


When you connect an LLM to a SQL database so people can ask questions in plain English, writing valid SQL is the easy part. Wrong answers often come from the data itself, such as a column that stores cents instead of dollars, or a country column that mixes names with ISO codes. On October 22, 2026, we ran a text-to-SQL agent on six current models through OpenRouter, using a synthetic shop database and 22 questions with known answers. Across completed runs, it answered 95% correctly from the schema alone (244 of 256) and 99% with a five-line note about the data (246 of 248; 93.2% of all 264 attempts including provider errors).
#OpenRouter#GPT-6 Luna#Claude Sonnet 5.5#Claude Haiku 5.5#DeepSeek V4.1 Flash#MiniMax M3.1 Flash#Gemini 3.8 Flash