Overview

Vanna AI provides a system for generating SQL queries from natural language inputs. The platform focuses on enabling developers and data professionals to create AI models that understand specific database schemas and historical data interactions. This process involves training a Vanna AI model by providing it with Data Definition Language (DDL) statements and example SQL queries, which it then embeds to build a contextual understanding of the database Vanna AI's operational principles. The goal is to produce accurate and relevant SQL outputs, reducing the need for manual SQL writing.

The system is designed for scenarios where users need to query complex databases without extensive SQL knowledge. Vanna AI supports both local execution via its Python library and a cloud-based service, offering flexibility in deployment. Its methodology emphasizes a "train once, query forever" approach, where the embedded knowledge base allows the AI to consistently generate SQL Vanna AI's 'train once, query forever' philosophy. This can be particularly beneficial for organizations looking to scale data access across various departments or integrate natural language querying into existing business intelligence (BI) tools.

Vanna AI is suitable for use cases such as automating report generation, enabling self-service analytics for non-technical users, and streamlining data exploration. Its ability to fine-tune on custom databases allows for adaptation to unique data structures and business logic. The platform aims to provide a reliable method for converting user questions into executable SQL, thereby bridging the gap between natural language and structured query languages. For example, a user might ask "Show me the total sales for Q1 2024," and Vanna AI would convert this into the appropriate SELECT SUM(...) statement based on the trained model's understanding of the sales table and date columns.

Key features

  • Natural Language to SQL Generation: Converts user questions in plain English into SQL queries, facilitating data access for users without SQL expertise.
  • Database Schema Embedding: Learns and embeds database DDL (Data Definition Language) to understand table structures, column names, and relationships, providing context for SQL generation.
  • SQL Query Embedding: Incorporates historical SQL queries as training data, enabling the model to learn common query patterns and improve accuracy over time.
  • Local Model Execution: Offers a Python library for running AI models locally, providing control over data privacy and potentially reducing latency.
  • Cloud Service: Provides a managed cloud service for hosting and scaling Vanna AI models, simplifying deployment and maintenance.
  • Integration with BI Tools: Designed to integrate with existing business intelligence platforms, allowing natural language querying within familiar analytics environments.
  • Fine-tuning on Custom Databases: Allows developers to train models on specific database schemas and data, optimizing performance for unique data environments.
  • SOC 2 Type II Compliance: Adheres to security and availability standards, indicating an operational commitment to data protection Vanna AI SOC 2 Type II compliance announcement.

Pricing

Vanna AI offers a tiered pricing structure that includes a free option for local use and progressively scales for cloud-based deployments. The pricing model is designed to accommodate individual developers, small teams, and enterprise-level organizations.

Tier Description Monthly Cost (as of 2026-05-27)
Free Local usage and small cloud instances $0
Pro Advanced features for individuals and small teams $100
Business Features for larger teams and organizations $500
Enterprise Custom solutions and support for large-scale deployments Custom pricing

For detailed pricing information and specific feature breakdowns for each tier, refer to the official Vanna AI pricing page.

Common integrations

Alternatives

  • MindsDB: An open-source AI layer for databases that allows users to ask questions in natural language and get answers from their data.
  • SQLAI: A tool focused on converting natural language to SQL, often used for quick data insights and query generation.
  • ai2sql: Provides a service for translating natural language into SQL queries, aiming to simplify database interactions.

Getting started

To begin using Vanna AI, you typically install the Python library, train a model with your database schema and example queries, and then use it to generate SQL. The following Python example demonstrates a basic setup, training, and query generation process.


import vanna as vn

# Initialize Vanna with a model and an LLM (e.g., OpenAI)
vn.set_api_key('YOUR_VANNA_API_KEY') # Replace with your actual API key
vn.set_model('my-database-model') # Choose a name for your model

# Connect to your database (example for SQLite)
vn.run_sql_ddl("CREATE TABLE my_table (id INTEGER, name TEXT, value REAL)")

# Train Vanna on DDL
vn.train(ddl="CREATE TABLE employees (id INT, name TEXT, salary REAL, department TEXT)")
vn.train(ddl="CREATE TABLE sales (order_id INT, product_name TEXT, quantity INT, price REAL, order_date DATE)")

# Train Vanna on example SQL queries
vn.train(sql="SELECT name, salary FROM employees WHERE department = 'Sales'")
vn.train(sql="SELECT product_name, SUM(quantity * price) AS total_sales FROM sales GROUP BY product_name ORDER BY total_sales DESC LIMIT 5")

# Generate a SQL query from natural language
question = "Show me the average salary of employees in the 'Marketing' department."
sql_query = vn.generate_sql(question=question)

print(f"Generated SQL: {sql_query}")

# You can also run the query directly if connected to a database
# results = vn.run_sql(sql_query)
# print(f"Query Results: {results}")

This example initializes Vanna, connects to a hypothetical database (represented by DDL and example SQL), trains the model with schema information and sample queries, and then generates a SQL query based on a natural language question. For more detailed instructions and advanced configurations, consult the Vanna AI official documentation.