Wren AI provides a powerful text-to-SQL interface that lets users query databases using natural language.
Wren AI exposes core APIs for answering user questions β including generating SQL from questions, executing queries, explaining results, and producing natural language summaries.
Endpoints Overview
POST /ask
: Ask a question and get a direct answer from the AI.POST /generate_sql
: Convert a natural language question into a SQL query.POST /run_sql
: Execute SQL and return structured results.POST /generate_summary
: Generate a natural language summary from .GET /stream_explanation
: Stream natural language explanations for non-SQL questions.
Use these endpoints to build interactive and intelligent data experiences.
When to Use Which API
Wren AI APIs are designed to be modular β you can either call a single all-in-one API or chain multiple endpoints together for more control and flexibility.
πΉ For simple questions
Use this when you just want to ask a question and get an answer:
Scenario | Use This |
---|---|
I want to ask a question and get an answer (AI will generate SQL, run it, and summarize it) | /ask |
I want a streamed version with reasoning and progress updates | /stream/ask |
πΉ For advanced or modular workflows
Use these if you want more control over each step:
Step | API |
---|---|
Convert question to SQL | /generate_sql, or /stream/generate_sql |
Execute the SQL | /run_sql |
Summarize the SQL result | /generate_summary |
Get explanation when SQL is not applicable | /stream_explanation |
π‘ Common Combinations
You can mix and match these endpoints based on your product needs.
-
/generate_sql
β/run_sql
β/generate_summary
For building interactive BI tools or workflows where SQL needs review, logging, or step-by-step handling.
-
/ask
Best for chat interfaces or quick answers with minimal effort.
-
/stream/ask
Best for frontend apps that want to display real-time progress, similar to ChatGPT-style interactions.