modelgrep

Best OpenAI Models for SQL & Data Analysis

Match · Updated July 2026

The best OpenAI model for SQL and data analysis is GPT-5.6 Sol, with a 77.4 Coding Index and structured-output support for valid, parseable queries. GPT-5.6 Terra (76.7) and GPT-5.5 (74.9) round out the top three.

77.4Coding
58.9Intelligence
74 t/sSpeed
$5.00Input /M
1.1MContext

The best AI models for writing SQL, analyzing data and powering analytics workflows — ranked by the Artificial Analysis Coding Index among models with structured-output support, so query generation comes back as valid, parseable SQL and JSON.

  1. 1openai logo
    gpt-5.6-sol
    ReasoningToolsJSON+158.9 intel · $5.00/M · 74 t/s
    77.4
    Coding
  2. 2openai logo
    gpt-5.6-terra
    ReasoningToolsJSON+155.0 intel · $2.50/M · 96 t/s
    76.7
    Coding
  3. 3openai logo
    gpt-5.5
    ReasoningToolsJSON+154.8 intel · $5.00/M · 100 t/s
    74.9
    Coding
  4. 4openai logo
    gpt-5.6-luna
    ReasoningToolsJSON+151.2 intel · $1.00/M · 97 t/s
    71.4
    Coding
  5. 5openai logo
    gpt-5.4
    ReasoningToolsJSON+151.4 intel · $2.50/M · 79 t/s
    71.1
    Coding
  6. 6openai logo
    gpt-5.4-nano
    ReasoningToolsJSON+138.2 intel · $0.200/M · 50 t/s
    56.1
    Coding
  7. 7openai logo
    gpt-5.4-mini
    ReasoningToolsJSON+140.0 intel · $0.750/M · 124 t/s
    56.1
    Coding
  8. 8openai logo
    gpt-5.1
    ReasoningToolsJSON+136.9 intel · $1.25/M · 78 t/s
    49.4
    Coding
  9. 9openai logo
    o1
    ReasoningToolsJSON+123.4 intel · $15.00/M · 200K ctx
    39.7
    Coding
  10. 10openai logo
    gpt-5
    ReasoningToolsJSON+134.7 intel · $1.25/M · 400K ctx
    37.8
    Coding
  11. 11openai logo
    gpt-oss-120b
    ReasoningToolsJSON23.8 intel · $0.037/M · 131K ctx
    30.4
    Coding
  12. 12openai logo
    gpt-4o-2024-05-13
    ToolsJSONVision8.6 intel · $5.00/M · 128K ctx
    24.2
    Coding
  13. 13openai logo
    gpt-4-turbo
    ToolsJSONVision7.9 intel · $10.00/M · 128K ctx
    21.5
    Coding
  14. 14openai logo
    gpt-oss-20b
    ReasoningToolsJSON14.9 intel · $0.029/M · 131K ctx
    20.7
    Coding
  15. 15openai logo
    gpt-oss-20b:free
    ReasoningToolsJSON14.9 intel · Free/M · 131K ctx
    20.7
    Coding
  16. 16openai logo
    gpt-4.1-mini
    ToolsJSONVision14.8 intel · $0.400/M · 112 t/s
    20.2
    Coding
  17. 17openai logo
    o3-mini-high
    ReasoningToolsJSON15.6 intel · $1.10/M · 200K ctx
    16.3
    Coding
  18. 18openai logo
    gpt-5-mini
    ReasoningToolsJSON+125.3 intel · $0.250/M · 107 t/s
    15.6
    Coding
  19. 19openai logo
    gpt-4
    ToolsJSON7.0 intel · $30.00/M · 8K ctx
    13.1
    Coding
  20. 20openai logo
    gpt-4o-mini
    ToolsJSONVision6.9 intel · $0.150/M · 128K ctx
    11.4
    Coding
  21. 21openai logo
    gpt-4o-mini-2024-07-18
    ToolsJSONVision6.9 intel · $0.150/M · 128K ctx
    11.4
    Coding
  22. 22openai logo
    gpt-4.1-nano
    ToolsJSONVision9.6 intel · $0.100/M · 3 t/s
    11.1
    Coding
  23. 23openai logo
    gpt-3.5-turbo
    ToolsJSON3.6 intel · $0.500/M · 16K ctx
    10.7
    Coding

Frequently asked

Which OpenAI model writes the best SQL?

The best OpenAI model for SQL and data analysis is GPT-5.6 Sol, with a 77.4 Coding Index and structured-output support for valid, parseable queries. GPT-5.6 Terra (76.7) and GPT-5.5 (74.9) round out the top three.

What's a good alternative to GPT-5.6 Sol?

GPT-5.6 Terra (76.7) is the closest alternative on this metric, followed by GPT-5.5 (74.9). See the full ranking above for the tradeoffs.

How many OpenAI models are there?

modelgrep tracks 67 OpenAI models with live benchmarks, speed, latency and per-provider pricing, led on intelligence by GPT-5.6 Sol. 23 of them qualify for this ranking.

More OpenAI rankings

All rankings