Build with AI: SQL Agents with Large Language Models
51mBeginner2025-10-16
Authors

Rami Krispin
Course details
In this course, learn how AI SQL agents work and how to build an agent from scratch. Get started with the general architecture of an SQL agent and then delve into its various components. Instructor Rami Krispin shows you how to design a prompt engine and work with different LLM frameworks, such as OpenAI GPT 4.1, Google Gemini Flash 2.0, and Anthropic Cloud 4, using the Python client. Last but not least, Rami guides you through the essentials of building your own AI agent component from scratch using Python.
Learning objectives
Describe the core components of an AI agent that converts natural language into SQL, including prompt engineering, schema context, and query generation.
Build and implement a basic AI agent using large language models APIs and Python to generate SQL queries from user questions.
List the principles of prompt engineering and how different prompt formats influence the quality and accuracy of SQL generated by large language models.
Learning objectives
Describe the core components of an AI agent that converts natural language into SQL, including prompt engineering, schema context, and query generation.
Build and implement a basic AI agent using large language models APIs and Python to generate SQL queries from user questions.
List the principles of prompt engineering and how different prompt formats influence the quality and accuracy of SQL generated by large language models.
Concepts
Introduction - SQL AI Agent Fundamentals and Architecture
- Build SQL AI agents with large language models (LLMs)
Python Environment and Database Setup for SQL Agents
- SQL agent architecture - LLM database integration design patterns
- Red30 sales dataset
LLM API Integration
- Storing API keys as environment variables
- Chat completion models
- Working with LLM APIs
- Working with LLMs locally
Prompt Engineering for SQL Generation and Query Optimization
- Optimizing SQL prompts through context engineering for better query results
- Improve LLM results with context engineering
- Building SQL prompt templates with reusable LLM query patterns
- Making prompts work across different LLMs
Build Production SQL AI Agents with Validation and Error Handling
- Modularizing an agent
- Building a prompt handler
- Building LLM API handlers for multiprovider SQL agent architecture
- SQL AI agent best practices
Conclusion - Deploying and Scaling SQL AI Agents in Production
- Next steps with SQL AI agents for production deployment and scaling