Knowledge Base
Curated table metadata, business rules, and query patterns give the LLM the context it needs to write accurate SQL.
Raw LLMs writing SQL hit a wall fast — schemas lack meaning, types are misleading, tribal knowledge is missing, and the same errors repeat endlessly. The root cause is missing context and missing memory.
Knowledge Base
Curated table metadata, business rules, and query patterns give the LLM the context it needs to write accurate SQL.
Self-Learning
When a query fails and the agent recovers, it saves that learning. Next time, it knows.
Multi-LLM Support
Any provider supported by Prism PHP — OpenAI, Anthropic, Ollama, Gemini, Mistral, xAI, and more.
SQL Safety
Configurable guardrails prevent destructive operations with statement restrictions and row limits.
See the Introduction for a detailed architecture overview.
composer require knobik/sql-agentphp artisan sql-agent:installThen configure your LLM provider in .env and start asking questions:
use Knobik\SqlAgent\Facades\SqlAgent;
$response = SqlAgent::run('How many users signed up this month?');echo $response->answer;See the Installation guide for full setup instructions.