--- title: Text To Sql Agent Api emoji: 🐨 colorFrom: indigo colorTo: indigo sdk: docker pinned: false short_description: SQL agent to converse with structured databases --- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference # Text-to-SQL Agent API A FastAPI backend service that converts natural language queries into SQL and provides intelligent data insights using LangGraph agents. ## Overview This API service enables natural language querying of SQL databases through an AI-powered agent that: - Converts text queries to SQL statements - Executes queries safely on SQLite databases - Provides intelligent data analysis and insights - Offers conversational interface for data exploration Built with FastAPI, LangGraph, and SQLAlchemy for high-performance data querying. ## Quick Start ### Prerequisites - Python 3.8+ - OpenAI API key ### Installation 1. **Clone and setup:** ```bash git clone https://github.com/arthikrangan/text-to-sql-agent-api.git cd text-to-sql-agent-api python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate ``` 2. **Install dependencies:** ```bash pip install -r requirements.txt ``` 3. **Configure environment:** ```bash cp .env.example .env # Edit .env and add your OPENAI_API_KEY ``` 4. **Run the server:** ```bash uvicorn app.main:app --reload ``` ### Docker ```bash # Build and run docker build -t text-to-sql-api . docker run -p 8000:8000 --env-file .env text-to-sql-api ```