# Vanna

> Turn plain-English questions into SQL and live data insights

- Category: Retrieval & Knowledge (RAG) / RAG Frameworks & Platforms
- Language: Python
- Licence: MIT
- Repository: https://github.com/vanna-ai/vanna
- Website: https://vanna.ai/docs/
- Canonical page: https://ai-tldr.dev/tools/vanna/

## In short

Vanna is an open-source Python framework for building natural-language-to-SQL applications. A user asks a question in plain English, and Vanna's agent generates SQL, runs it against your database, and streams back an interactive table, Plotly charts, and a written summary. It sits in the RAG Frameworks & Platforms category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Python and licensed MIT.

## Overview

Vanna is an open-source Python framework for building natural-language-to-SQL applications. A user asks a question in plain English, and Vanna's agent generates SQL, runs it against your database, and streams back an interactive table, Plotly charts, and a written summary.

Vanna 2.0 is built around user-aware agents for production use. Identity from your own auth system (cookies, JWTs, or OAuth) flows through the system prompt, tool execution, and SQL filtering, so each user only sees the rows their permissions allow. It ships with a pre-built `<vanna-chat>` web component and integrates with FastAPI or Flask.

## What it does

- Generates SQL from plain-English questions and returns tables, charts, and natural-language summaries
- User-aware at every layer: identity flows through prompts, tools, and row-level SQL filtering
- Pre-built `<vanna-chat>` web component that drops into React, Vue, or plain HTML and uses your existing cookies or JWTs
- Streaming responses deliver real-time progress, tables, and Plotly charts to the frontend
- Works with many LLMs (OpenAI, Anthropic, Ollama, Azure, Gemini, Bedrock, Mistral) and databases (PostgreSQL, MySQL, Snowflake, BigQuery, SQLite, and more)
- Extensible with custom tools, lifecycle hooks for quotas and logging, LLM middlewares, and built-in observability

## Getting started

Vanna integrates into an existing FastAPI app. You define how to resolve a user from a request, register the agent and its tools, then add the chat routes. The pre-built web component connects to the streaming endpoint.

1. Set up an agent and register routes

   In your FastAPI app, define a user resolver that extracts identity from your auth system, build an agent with an LLM service and a SQL tool, then register the chat routes.

```python
from fastapi import FastAPI
from vanna import Agent
from vanna.servers.fastapi.routes import register_chat_routes
from vanna.servers.base import ChatHandler
from vanna.integrations.anthropic import AnthropicLlmService
from vanna.tools import RunSqlTool
from vanna.integrations.sqlite import SqliteRunner
from vanna.core.registry import ToolRegistry

app = FastAPI()

llm = AnthropicLlmService(model="claude-sonnet-4-5")
tools = ToolRegistry()
tools.register(RunSqlTool(sql_runner=SqliteRunner("./data.db")))

agent = Agent(llm_service=llm, tool_registry=tools, user_resolver=MyUserResolver())
chat_handler = ChatHandler(agent)
register_chat_routes(app, chat_handler)
```

2. Drop the chat component into your page

   Add the Vanna component script and the `<vanna-chat>` element, pointing it at your streaming endpoint. It uses your existing cookies or JWTs.

```html
<script src="https://img.vanna.ai/vanna-components.js"></script>
<vanna-chat sse-endpoint="/api/vanna/v2/chat_sse"></vanna-chat>
```

## When to use it

- Adding a natural-language data-analytics interface to an application so non-technical users can query a database without writing SQL
- Building multi-tenant SaaS dashboards where queries must be automatically filtered per user permissions with row-level security
- Giving teams a pre-built chat UI plus backend that streams tables and charts, integrated with their existing authentication system
- Enterprise reporting that needs audit logs, per-user rate limits, and compliance tracking on every query
