# Ask AI (NEW!)

![](https://2006615411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ltuu0c63_YY4iXfi5vJ%2Fuploads%2FkhvmEvyv0gSd8K1STQlG%2Flogo-small.png?alt=media\&token=7352607b-3f16-4939-a040-50470482ef7f)

Ask AI is a new feature in UXWizz that allows you to get insights of your stored data with the help of an AI chatbot (LLM).<br>

{% hint style="warning" %}
To use this feature you currently need an [OpenAI API key](https://platform.openai.com/api-keys) or [OpenRouter API key](https://openrouter.ai/settings/keys).\
You also need to have enough credits in your API provider account (e.g. $10).\
**Note: The AI model can and will make mistakes or provide incorrect queries.**&#x20;
{% endhint %}

<figure><img src="https://2006615411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ltuu0c63_YY4iXfi5vJ%2Fuploads%2F8QbSojwVbvEUwzMP4bAC%2Fask_ai_checkout_complete.gif?alt=media&#x26;token=c2fa8da8-1545-4c8c-8eaa-af7d0a723e5e" alt=""><figcaption><p>Basic UXWizz Ask AI ChatGPT query demo</p></figcaption></figure>

## How does it work?

1. You type your question.\
   e.g. "*How many visitors came from Google versus directly?"*
2. The question, together with the database schema and some instructions (system prompt) are sent to ChatGPT.
3. The AI generates a MySQL query that answers your question.
4. The MySQL query is displayed to you. You can then send the query for execution to your local database to get the results.
5. The output is displayed as JSON in the chat.
6. The AI can also generate a Chart.js chart from this query.

Soon, there will be additional ways to display the results (graphs, exportable csv, files, images, etc.)

### Example query

<figure><img src="https://2006615411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ltuu0c63_YY4iXfi5vJ%2Fuploads%2FqQJzbedt1b9vKN8mPkiX%2Fimage.png?alt=media&#x26;token=9d75892b-4c6d-4d61-88a3-1828a3b018dc" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
TIP: You can simply press Enter with an empty input to get some question/prompt ideas.
{% endhint %}

### Selecting AI model

You can change the model from the top-right Settings → GPT Model menu.\
Currently, only OpenAI ChatGPT API and models are supported.&#x20;

<figure><img src="https://2006615411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ltuu0c63_YY4iXfi5vJ%2Fuploads%2FlCAkbwF12c17G4Jpngk1%2Fimage.png?alt=media&#x26;token=ad00cf67-ba95-4976-a09f-1c84f54e714f" alt=""><figcaption></figcaption></figure>

### Generating charts

{% hint style="info" %}
Ask AI Charts was introduced in version 7.0.0.
{% endhint %}

You can simply ask the AI to generate a chart. \
The AI will create a MySQL query that returns the data and a Chart.js configuration. \
This data + config are then used in your dashboard to display the chart.

Here is a quick demo video:

{% embed url="<https://youtu.be/PchemV0LDE0?si=wYTDT_MYlpsFajyk>" %}

{% hint style="warning" %}
Coming soon!\
\* Ollama local AI support (ChatGPT alternative)\
\* ChatGPT completion summary (time spent, tokens consumed, estimate cost).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.uxwizz.com/guides/ask-ai.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
