Talk2Database โ Agentic Text-to-SQL Platform
Inspiration
Data is the lifeblood of modern decision-making, yet retrieving actionable insights from complex relational databases remains locked behind technical SQL expertise or tedious dashboard requests. Existing AI text-to-SQL solutions suffer from two major flaws:
- Massive Context Bloat & High Token Costs: Autonomous SQL agents iterate through multiple tool calls (fetching schemas, inspecting tables, verifying queries), rapidly blowing up context length and LLM API costs.
- Fragile Single-Prompt Generation: Basic LLM text-to-SQL prompts lack verification, safety guardrails, and execution plan visibility, often hallucinating column names or returning runtime errors.
We built Talk2Database to solve both problems: creating a state-of-the-art, autonomous agentic SQL assistant that seamlessly converts natural language into verified SQL queries.
What it does
Talk2Database is an end-to-end, enterprise-grade AI Text-to-SQL agentic web application.
Key features include:
- ๐ฌ Natural Language to SQL Agent: Converts natural language queries into precise, execute-ready SQL statements using an autonomous, tool-calling LangGraph agent.
- โก Integrated Paritok Context Compression: Intercepts agent trajectories and database schema payloads in real time, compressing context before forwarding to upstream LLMs (Groq / OpenAI) to cut token bills and prefill latency.
- โ๏ธ Dual Compression Deployment (Hosted GPU & Self-Hosted): Supports both Paritok's hosted cloud GPU server (
use_gpu_server: true) and local self-hosted compression via Ollama (paritok/paritok-4b-v1). - ๐ Interactive Query Plan Execution (
EXPLAINVisualizer): Inspects query execution paths across PostgreSQL, MySQL, and SQLite, visualizing cost estimates, index usage, and scan steps. - ๐ก๏ธ Strict Read-Only Guardrails & Prompt Injection Protection: Enforces strict execution safety rules that allow only
SELECTqueries while intercepting and blocking schema modification (DROP,ALTER) or data tampering (UPDATE,DELETE). - ๐ Paritok Compression Inspector UI: A dedicated real-time dashboard displaying token reduction percentages, total tokens saved, estimated cost savings ($), and side-by-side original vs. compressed context segment traces.
How we built it
Backend & AI Architecture
- Python 3.13 &
uv: Managed high-performance dependency isolation and virtual environment setup usinguv. - FastAPI: Built clean, async RESTful APIs for database connections (
/setup-connection), natural language query execution (/query), query plan explanations (/query/explain), and Paritok statistics (/paritok/stats). - LangGraph & LangChain: Engineered a resilient state machine agent that dynamically navigates tool selection (
list_tables,get_schema,execute_query) with memory checkpointers. - Paritok Context Compression Proxy: Deployed the
paritokmiddleware gateway (paritok proxy) sitting transparently between the agent and upstream LLMs (Groqopenai/gpt-oss-120b).
Frontend & User Experience
- React 18, Vite & TypeScript: Developed a fast, modern single-page web application with responsive layout and real-time state management.
- Tailwind CSS & Glassmorphism Design: Designed a dark-mode, futuristic glassmorphic UI using curated color palettes, micro-animations, and dynamic status indicators.
- React Markdown & GFM: Formatted SQL responses into syntax-highlighted code blocks with copy-to-clipboard functionality and collapsible query plan trees.
Challenges we ran into
Paritok Cloud GPU Server Availability & Fail-Safe Pass-Through:
During integration, we encountered moments when Paritokโs hosted cloud GPU returnedgpu_available: false. We learned how Paritokโs proxy architecture handles this gracefully: when cloud GPUs are offline, requests pass through uncompressed so the userโs queries never fail. To guarantee continuous, 100% active compression regardless of cloud status, we configured local self-hosting with Ollama (ollama pull paritok/paritok-4b-v1), giving us full offline compression control on local hardware.Upstream API Key Passthrough vs. Compressor Authentication:
Configuring the Paritok proxy required carefully decoupling the Paritok GPU server authentication key (pk_live_...) from the upstream LLM provider key (Groqgsk_...). The proxy forwards the upstream Authorization header directly to Groq, so ensuring the correct provider key was passed prevented401 Unauthorizederrors.LangGraph Trajectory Recursion & Infinite Loops:
Early iterations of the supervisor agent fell into infinite loops callinglist_tablesrepeatedly. We resolved this by refining system prompts to inspect previous conversation history before selecting tools and enforcing strict graph recursion limits (recursion_limit: 15).Database Driver Validation & Compatibility:
Handling connection strings across diverse database engines (PostgreSQL, MySQL, and SQLite URIs without network hosts) required building adaptive connection validation routines.
Accomplishments that we're proud of
- ๐ Seamless Paritok Middleware Integration: Successfully routed multi-step agent trajectories through Paritok context compression, achieving up to 74%+ token reductions on heavy schema payloads.
- ๐ก๏ธ Robust Read-Only Security Guardrails: Built a resilient security policy layer that guarantees safe database exploration without risk of data destruction.
- ๐จ State-of-the-Art UX: Built a clean UI complete with syntax highlighting,
EXPLAINquery execution plan visualizations, and a live Paritok token savings inspector. - โก Zero-Downtime Fallback Architecture: Engineered our setup to handle hosted GPU offline states without breaking backend query execution.
What we learned
- Context is the bottleneck for agentic systems: Agentic workflows spend up to 80%+ of their token budget re-sending previous tool outputs and schemas. Context compression model gateways like Paritok are essential for production-grade agent scalability.
- Fail-Safe Gateway Design: A non-destructive compression gateway that passes uncompressed traffic when GPU nodes are offline ensures 100% application uptime.
- Structured Prompts vs. Graph Routing: Clear, guardrailed system prompts inside state machines prevent agent loop stalls far more effectively than basic prompt chains.
What's next for Talk2Database
- ๐ Automated Data Visualizations: Auto-generating interactive charts (bar charts, line graphs, pie charts) directly from SQL query results.
- ๐ Native MCP (Model Context Protocol) Server: Packaging Talk2Database as an MCP server so developer tools like Claude Code and Cursor can query connected databases securely.
- ๐ง Schema Indexing & Vector Search: Embedding large database schemas with
bge-small-enfor semantic table/column filtering before sending queries. - ๐ Multi-Database Federated Queries: Allowing users to join data across different databases (e.g., SQLite + PostgreSQL) in a single natural language prompt.

Log in or sign up for Devpost to join the conversation.