Skip to content

Quickstart

Get from zero to your first AI-generated SQL query in under 2 minutes.


Step 1: Start the Server

uvicorn main:app --reload

Expected output:

INFO:     Will watch for changes in these directories: ['.']
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [29872]
INFO:     Application startup complete.

Step 2: Ask a Question

Send your first natural language query using curl:

curl -X POST "http://127.0.0.1:8000/api/v1/chat/ask" \
  -H "Content-Type: application/json" \
  -d '{"question": "What is the average loan amount by sector?"}'
import httpx

response = httpx.post(
    "http://127.0.0.1:8000/api/v1/chat/ask",
    json={"question": "What is the average loan amount by sector?"}
)
print(response.json())
const res = await fetch("http://127.0.0.1:8000/api/v1/chat/ask", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ question: "What is the average loan amount by sector?" })
});
console.log(await res.json());

Step 3: Inspect the Response

{
  "sql": "SELECT Sector, AVG(AmountGranted) AS avg_loan\nFROM msmeloans\nGROUP BY Sector\nORDER BY avg_loan DESC;",
  "data": [
    { "Sector": "Agriculture", "avg_loan": 5750000.0 },
    { "Sector": "Trade and Commerce", "avg_loan": 3200000.0 },
    { "Sector": "Manufacturing", "avg_loan": 2800000.0 }
  ],
  "plotly_code": "import plotly.express as px\nfig = px.bar(df, x='Sector', y='avg_loan', title='Average Loan by Sector')\nfig.show()"
}

Step 4: Explore with Swagger UI

Open the interactive API documentation in your browser:

🔗 http://127.0.0.1:8000/api/docs

URL structure

The MkDocs documentation site is served at / (root).
The Swagger UI lives at /api/docs and ReDoc at /api/redoc.


Sample Questions to Try

Question What it tests
Which sector has the highest average predicted default probability? Aggregation + ordering
Show the top 10 borrowers with the highest predicted default risk. TOP-N query
What percentage of loans are classified as high-risk (probability > 0.5)? Filtered percentage
Which states have the largest number of startup borrowers? Boolean column filtering
Show the average loan-to-turnover ratio by number of employees bucket. Ratio + grouping