The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
docs - one-shot sql gen (#69766)
Jeff Bruemmer5f66a26a53c6
diff --git a/docs/README.md b/docs/README.mdindex 140efb6e46f..0853496f127 100644--- a/docs/README.md+++ b/docs/README.md@@ -150,6 +150,7 @@ Metabase's reference documentation.- [AI overview](./ai/start.md)- [Metabot](./ai/metabot.md)- [Setting up Metabot](./ai/settings.md)+- [SQL generation](./ai/sql-generation.md)### Exploration and organizationdiff --git a/docs/ai/images/accept-or-reject.png b/docs/ai/images/accept-or-reject.pngnew file mode 100644index 00000000000..848fa8a15c9Binary files /dev/null and b/docs/ai/images/accept-or-reject.png differdiff --git a/docs/ai/images/sql-generation-admin.png b/docs/ai/images/sql-generation-admin.pngnew file mode 100644index 00000000000..8c1015d26e5Binary files /dev/null and b/docs/ai/images/sql-generation-admin.png differdiff --git a/docs/ai/images/sql-generation.png b/docs/ai/images/sql-generation.pngnew file mode 100644index 00000000000..06e8d30b56cBinary files /dev/null and b/docs/ai/images/sql-generation.png differdiff --git a/docs/ai/metabot.md b/docs/ai/metabot.mdindex 2a0d8418445..9255b39c423 100644--- a/docs/ai/metabot.md+++ b/docs/ai/metabot.md@@ -124,7 +124,6 @@ Open it from **+ New → AI exploration**, then ask a question or pick one of thWhen answering questions in AI exploration, Metabot searches a limited set of content instead of your entire Metabase. Admins can set a **Collection for natural language querying** to scope AI exploration to a specific collection and its subcollections. You can still refer to content outside that scope by explicitly @-mentioning it in your prompt. See [Metabot AI settings](../ai/settings.md) for more details.-## Giving feedback on Metabot responsesWhen you hover over Metabot's responses, you'll see options to give feedback.diff --git a/docs/ai/sql-generation.md b/docs/ai/sql-generation.mdnew file mode 100644index 00000000000..332eb52eb37--- /dev/null+++ b/docs/ai/sql-generation.md@@ -0,0 +1,55 @@+---+title: SQL generation on self-hosted Metabases+summary: Bring your own API key to generate SQL from natural language in your self-hosted Metabase.+---++# SQL generation on self-hosted Metabases++> One-shot SQL generation with your own API key is only available on self-hosted Metabases. For Metabase Cloud, check out [Metabot](./metabot.md).++Bring your own API key to generate SQL from natural language in the [native editor](../questions/native-editor/writing-sql.md).++## Setting up one-shot SQL generation++To enable SQL generation on a self-hosted Metabase:++1. Go to **Admin settings > AI**.+2. Enter your **Anthropic API key**.+3. Select the AI model you'd like to use for SQL generation. (Opus models typically give the best results.)++++You'll need an API key from [Anthropic](https://www.anthropic.com/learn/build-with-claude). Once you've entered the key, anyone in your Metabase can use SQL generation in the native editor.++Currently, only Anthropic is supported.++## Generate SQL from natural language++++To generate SQL from a natural language prompt:++1. Open the [native editor](../questions/native-editor/writing-sql.md).++2. Press **Cmd+Shift+I** (Mac) or **Ctrl+Shift+I** (Windows).++3. Enter one or more tables.++4. Type a prompt describing the query you want to write.++5. Click **Generate** to create the SQL.++6. Review the generated SQL before running it.++You can also edit existing SQL. Place your cursor in the query, trigger the prompt, and describe the change you want to make (like "add a filter for orders from this year"). Metabase will suggest edits that you can accept or reject. You must select at least one table for both new queries and edits.++++Each prompt is independent — the AI doesn't retain context from previous generations.++Like with all generative AI, always double-check the output.++## Further reading++- [The native/SQL editor](../questions/native-editor/writing-sql.md)+- [Metabot](./metabot.md)diff --git a/docs/ai/start.md b/docs/ai/start.mdindex d889ed5262b..dbeabf360c9 100644--- a/docs/ai/start.md+++ b/docs/ai/start.md@@ -14,6 +14,10 @@ Metabot is an AI assistant that helps you explore and analyze your data.Admins can configure Metabot to focus on specific collections and manage example prompts.+## [SQL generation](./sql-generation.md)++Use your own API key to generate SQL from natural language on self-hosted Metabases.+## [Agent API](./agent-api.md)A REST API for building headless, agentic BI applications on top of Metabase's semantic layer.