> For the complete documentation index, see [llms.txt](https://docs.uxwizz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uxwizz.com/guides/ask-ai.md).

# Ask AI

Ask questions about your analytics data in plain English. UXWizz sends the question and database structure to your selected AI provider, then lets you review and run the generated query on your server.

You need an account with **Ask AI** access and a configured OpenAI or OpenRouter API key. Provider usage may require separate billing or credits. A ChatGPT subscription does not supply an API key for UXWizz.

{% hint style="warning" %}
AI can generate incorrect queries or misleading results. Check the selected domain, date range, filters, and returned values before using an answer in a report. Do not include passwords, API keys, or customer personal data in a prompt.
{% endhint %}

## How does it work?

1. Select a website and open **Ask AI**.
2. Start a **New chat**, or open an existing conversation.
3. Enter a specific question and select **Send**.
4. Review the generated SQL, then select **Run query**. UXWizz validates it and runs permitted read-only queries against the selected data scope.
5. Inspect the result. Ask a follow-up question or generate a chart if that helps explain it.

With **Include chat history** enabled, earlier messages from the current conversation provide follow-up context. Query result rows stay on your server; they are not automatically sent to the provider. Text you type into a prompt is sent, so do not paste sensitive results back into the conversation.

### Example query

Try: “How many visitors came from Google versus directly in the last 7 days?” State the period and what you want to count. Sessions, pageviews, and purchase events are different measures.

Use the suggested questions in a new conversation if you need a starting point.

### Selecting AI model

Open the **Settings** gear in **Ask AI**:

1. Choose **LLM provider**: **OpenAI** or **OpenRouter**.
2. Set the provider's **API key**.
3. Choose **Model**, using a model available to that provider account.
4. Choose whether to **Include chat history**.

Provider and API-key settings require root access. Changing the model requires administrator access. OpenRouter provides access to models from multiple vendors; it is a separate provider account from OpenAI.

### Generating charts

Ask for a chart type, measure, and date range. For example: “Create a line chart of daily purchases for the last 14 days.” Check that your purchase tag or success-page definition matches the query.

You can also select **Generate chart** for a suitable query. UXWizz combines its query result with a Chart.js configuration to display the chart.

![Ask AI showing a reviewed SQL query and a daily purchase chart](https://2006615411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ltuu0c63_YY4iXfi5vJ%2Fuploads%2Fgit-blob-0e2f1f03cee27a1be40f05dbc065574827eb223c%2Fuxwizz-ask-ai-v10.webp?alt=media)

Where your license supports custom dashboards, use **Add to dashboard** to reuse the result. Review its date and segment behavior before saving it.

### Troubleshooting

* **API key not set or rejected:** ask the root administrator to check the selected provider and its key.
* **Provider request fails:** check provider availability, billing, and access to the selected model. Network restrictions on the UXWizz server require server access to resolve.
* **Query rejected:** check the error and make the question more specific. Do not bypass query validation.
* **Empty or unexpected result:** confirm the domain, date range, filters, and underlying tracking data.
* **Disabled by administrator:** check the [AI environment flag](/guides/environment-settings.md#disable-ai-chat) with the server administrator.
