AI Assistant
Use AI to generate MongoDB queries, build aggregation pipelines, translate SQL to MongoDB, and analyze your database schema. Describe what you need in plain English and let AI write the MongoDB code for you. VisuaLeaf ships with pluggable providers (OpenAI, Anthropic, Google Vertex AI, and Ollama for fully local inference), so you can pick the model that best matches your accuracy, cost, and privacy requirements.
Generate your first AI-powered query:
The AI Assistant is built on Spring AI 1.0.0, giving you a single, consistent UI across four provider families. All four ship in every VisuaLeaf install — you only enable the ones you want to use.
| Provider | Models | Best For | Credentials |
|---|---|---|---|
| OpenAI | gpt-4, gpt-4o, gpt-4o-mini, o1 |
Broadly reliable query generation, cost-effective with gpt-4o-mini |
OpenAI API key |
| Anthropic | claude-opus-4, claude-sonnet-4, claude-haiku-4 |
Long-context schema analysis, precise pipeline reasoning | Anthropic API key |
| Google Vertex AI | Gemini 2.0 & Gemini 2.5 series | Enterprise Google Cloud deployments, multimodal use cases | GCP project + service account JSON |
| Ollama | llama3, mistral, phi3, any Ollama-compatible model |
Fully local / air-gapped environments; zero data leaves your machine | Local Ollama endpoint (e.g., http://localhost:11434) |
Bring your own key. All API keys are stored per user and used to talk directly to the chosen provider — VisuaLeaf servers never proxy or see your prompts, completions, or keys. For teams that require complete network isolation, run Ollama locally and select it as the provider.
Generate MongoDB find queries from natural language descriptions. Perfect for complex filters, date ranges, and multi-condition queries.
| Natural Language | Generated Query |
|---|---|
| "Find users with verified email" | { emailVerified: true } |
| "Get orders over $100 from last week" | { total: { $gt: 100 }, createdAt: { $gte: ISODate("...") } } |
| "Find products with stock less than 10" | { stock: { $lt: 10 } } |
| "Show customers from New York or California" | { state: { $in: ["NY", "CA"] } } |
Migrating from PostgreSQL, MySQL, or SQL Server? Paste a SQL statement and the AI Assistant rewrites it as an equivalent MongoDB find() call or aggregation pipeline. Great for developers still building MongoDB muscle memory.
-- Input (SQL)
SELECT country, COUNT(*) AS orders
FROM orders
WHERE created_at >= NOW() - INTERVAL '30 days'
GROUP BY country
ORDER BY orders DESC
LIMIT 10;
// Output (MongoDB aggregation)
db.orders.aggregate([
{ $match: { created_at: { $gte: ISODate("...") } } },
{ $group: { _id: "$country", orders: { $sum: 1 } } },
{ $sort: { orders: -1 } },
{ $limit: 10 }
]);
Build complex aggregation pipelines by describing your data transformation in plain English.
| Natural Language | Generated Pipeline |
|---|---|
| "Total sales by category" | $group by category, $sum sales |
| "Top 10 customers by order count" | $group by customer, $count, $sort desc, $limit 10 |
| "Average order value per month" | $group by month, $avg orderValue |
| "Join orders with customer details" | $lookup from customers |
Given the prompt "Show me the top 5 customers by revenue in the last quarter, including their name from the customers collection", the AI Assistant produces:
db.orders.aggregate([
{ $match: {
createdAt: { $gte: ISODate("2026-04-01"), $lt: ISODate("2026-07-01") },
status: "completed"
}},
{ $group: {
_id: "$customerId",
revenue: { $sum: "$total" },
orders: { $sum: 1 }
}},
{ $sort: { revenue: -1 } },
{ $limit: 5 },
{ $lookup: {
from: "customers",
localField: "_id",
foreignField: "_id",
as: "customer"
}},
{ $unwind: "$customer" },
{ $project: {
_id: 0,
customer: "$customer.name",
revenue: 1,
orders: 1
}}
]);
Each stage arrives with a short natural-language explanation so you can learn (and audit) the pipeline before applying it.
Get AI-powered insights into your database schema, including field types, data patterns, and optimization recommendations.
| Insight Type | Description |
|---|---|
Field Summary |
Human-readable summary of each field's purpose and content |
Data Quality |
Percentage of documents with null/missing fields |
Relationships |
Detected foreign key relationships to other collections |
Optimization Tips |
Suggestions for improving schema design |
The AI Assistant maintains conversation context, allowing you to refine queries through follow-up requests.
Apply AI-generated queries directly to VisuaLeaf's query tools.
Configure the active provider, model, and how much context the AI Assistant is allowed to see.
| Setting | Description | Default |
|---|---|---|
Provider |
Which AI backend to use: OpenAI, Anthropic, Google Vertex AI, or Ollama | OpenAI |
Model |
Specific model within the selected provider (e.g., claude-sonnet-4, gpt-4o, llama3) |
Provider-recommended |
API Key / Endpoint |
Your provider credentials (or the Ollama base URL for local inference) | Empty |
Schema Context |
Include collection schema in AI requests for better accuracy | Enabled |
Sample Documents |
Number of sample documents to include for context (per connection) | 5 |
Explain Output |
Include explanations with generated code | Enabled |
Auto-Execute |
Automatically run generated queries (with confirmation) | Disabled |
The AI Assistant is designed so you decide, per connection, exactly what leaves your machine.
ollama pull llama3 or ollama pull mistral.http://localhost:11434).Download and start managing your MongoDB databases with ease.
Download Free Trial