Writing one SQL query with AI costs between 0.04¢ (GPT-6 Luna) and 5.5¢ (Claude Fable 5.1) in my data. The median across all 325 models I track is 0.23¢. List price is a poor guide, because reasoning tokens are billed as output and can outweigh the visible query several times over.
What one text-to-SQL task measures
The task is a single SQL query written from a plain-English request. The prompt is short, so almost all the cost sits in output tokens. For reasoning models, that includes hidden reasoning tokens, which are billed at the output rate.
I show cost per query and per 1,000 queries, which maps more easily to a monthly budget. Rows marked "measured" were run once through OpenRouter with default settings and output capped at 16,000 tokens. "Estimated" rows are modeled from the same task and are less certain. See the methodology for details.
Cost per query, ranked
| Model | Cost per query | Per 1,000 queries | LMArena Text | Basis |
|---|---|---|---|---|
| GPT-6 Luna | 0.04¢ | $0.40 | 1441 | Measured |
| MiMo-V2.6-Pro | 0.07¢ | $0.74 | 1480 | Estimated |
| Llama 4 Maverick | 0.08¢ | $0.80 | 1327 | Estimated |
| GLM 5.3 Flash | 0.08¢ | $0.82 | 1476 | Measured |
| Claude Haiku 5.5 | 0.08¢ | $0.84 | 1425 | Measured |
| GPT-6.1 Sol | 0.48¢ | $4.84 | 1481 | Measured |
| Claude Sonnet 5.5 | 1.1¢ | $10.93 | 1477 | Measured |
| Claude Opus 5.5 | 2.2¢ | $21.87 | 1509 | Estimated |
| Claude Fable 5.1 | 5.5¢ | $54.67 | 1504 | Estimated |
Live prices for popular models:
| # | Model | Cost per task | WebDev score | Tokens in / out | Basis | |
|---|---|---|---|---|---|---|
| 1 | GLM 5.3 FlashZ.ai | 0.01¢$0.13 / 1,000 | 1607 | 128 / 1,596 | measured best value | |
| 2 | GPT-6 LunaOpenAI | 0.04¢$0.40 / 1,000 | 1579 | 126 / 782 | measured | |
| 3 | DeepSeek V4.1 FlashDeepSeek | 0.04¢$0.43 / 1,000 | 1619 | 145 / 2,129 | measured best value | |
| 4 | MiMo-V2.6-ProXiaomi | 0.07¢$0.74 / 1,000 | 1625 | 274 / 708 | estimated best value | |
| 5 | Llama 4 MaverickMeta | 0.08¢$0.80 / 1,000 | 1327 | 274 / 708 | estimated | |
| 6 | Claude Haiku 5.5Anthropic | 0.08¢$0.84 / 1,000 | 1589 | 182 / 1,650 | measured | |
| 7 | MiniMax M3MiniMax | 0.09¢$0.92 / 1,000 | 1483 | 272 / 702 | measured | |
| 8 | GPT-5.4 NanoOpenAI | 0.10¢$1.00 / 1,000 | 1401 | 126 / 782 | estimated | |
| 9 | Command A+Cohere | 0.11¢$1.14 / 1,000 | - | 272 / 704 | estimated | |
| 10 | Qwen3.8 FlashAlibaba Qwen | 0.13¢$1.26 / 1,000 | - | 177 / 2,630 | measured | |
| 11 | Mistral Small 4Mistral | 0.19¢$1.91 / 1,000 | - | 121 / 3,158 | estimated | |
| 12 | GLM 5.3Z.ai | 0.22¢$2.24 / 1,000 | 1623 | 128 / 1,596 | estimated |
The most expensive models are frontier systems with high output prices. Claude Fable 5.1 lists output at $50.00 per 1M tokens and has the highest per-query cost for this task. See the SQL query task page for the full ranking.
Reasoning tokens inflate the bill
Output price is only part of the story. Several models generate far more hidden reasoning tokens than visible output:
- Qwen3.8 Flash: 2,225 reasoning tokens against 405 output tokens, for 0.13¢ per query despite a $0.47 output price.
- Mistral Small 4: 2,647 reasoning tokens against 511 output tokens, for 0.19¢ (estimated).
- Mistral Large 4: the same 2,647 reasoning tokens, and a measured 0.67¢.
- DeepSeek V4.1 Flash: 1,723 reasoning tokens against 406 output tokens, for 0.12¢.
- Gemini 3.1 Pro Preview: 1,983 reasoning tokens against 620 output tokens, for a measured 3.2¢.
- GLM 5.3 Flash: 1,123 reasoning tokens against 473 output tokens, still only 0.08¢ because its output price is low.
- GPT-6 Luna: 516 reasoning tokens against 266 output tokens, and the cheapest measured model at 0.04¢.
Reasoning volume is not the same as cost. GPT-6.1 Sol used 147 reasoning tokens and Claude Sonnet 5.5 used 218, yet both cost more than the heavy-reasoning small models because their output price is $10.00 per 1M tokens.
Tokenizers also differ. For the same English text, Anthropic models count 1.39 tokens against 1.00 for OpenAI, so the same prompt is larger on Claude before any reasoning starts.
When comparing models, check the reasoning token count as well as the price per million tokens.
Cheapest model per quality band
I grouped models by LMArena Text score. The bands are my own labels, not an official ranking. In each band I picked the lowest cost per query among models that have a score.
| Quality band (LMArena Text) | Cheapest model | Per 1,000 queries | LMArena Text | Basis |
|---|---|---|---|---|
| Top scores (MiMo-V2.6-Pro's 1480 and above) | MiMo-V2.6-Pro | $0.74 | 1480 | Estimated |
| Middle scores (GPT-6 Luna's 1441 up to just below 1480) | GPT-6 Luna | $0.40 | 1441 | Measured |
| Lower scores (below 1441) | Llama 4 Maverick | $0.80 | 1327 | Estimated |
- Top scores: MiMo-V2.6-Pro is cheapest, but its cost is estimated. The next option is GPT-6.1 Sol at $4.84 per 1,000 queries and a score of 1481, which is measured.
- Middle scores: GPT-6 Luna wins at $0.40 per 1,000 queries. GLM 5.3 Flash, at 1476 and measured, costs $0.82 per 1,000.
- Lower scores: Llama 4 Maverick is cheapest at $0.80 per 1,000 but is estimated. Claude Haiku 5.5 is $0.84 per 1,000 with a measured cost and a score of 1425. I would take Haiku if I wanted a measured number.
Command A+, Qwen3.8 Flash, Mistral Small 4, Gemini 3.1 Flash Lite, DeepSeek V4 Pro 0813 and Qwen3.8 Max Prime have no LMArena Text score in my data, so I left them out of the bands.
Limits of this comparison
Each measured model ran once with default settings, and reasoning output can vary between runs. Estimated figures may differ from real bills. For this task, no model is flagged as hitting the 16,000-token cap, but the cap did affect the code review task, so check your own prompts. The calculator lets you test your own token counts.
FAQ
How much does one AI-generated SQL query cost?
In my measurements, from 0.04¢ with GPT-6 Luna to 5.5¢ with Claude Fable 5.1. The median across 325 models is 0.23¢.
Do reasoning models cost more for SQL?
Often, but not always. Reasoning tokens are billed as output, so heavy reasoning raises the bill. A low output price can still keep a reasoning model cheap, as GLM 5.3 Flash shows at 0.08¢.
Which model is cheapest for SQL at a given quality?
GPT-6 Luna at $0.40 per 1,000 queries is the cheapest measured option and has a score of 1441. For higher scores, MiMo-V2.6-Pro is cheapest but estimated, and GPT-6.1 Sol is the measured alternative.