Conversational Natural Large Language Models allow ad-hoc questions to be asked, without the learning curve of understanding the [[Internal Analytics]] design structure. The agents that are using these LLMs typicaly act as an on-demand business analyst. Whenever more depth, color and details are required, more advanced analytics options should be consulted.
## Development
The analytics agent demo shown below is built on top of the ABD Iowa demonstration dataset which is visualised in [Looker Studio](https://lookerstudio.google.com/u/0/reporting/86bd9839-3788-4b62-a1d9-4ce312bbff3e/page/p_etg6w1911c). The data model that guides the large language model is codified in the [data model repository](https://github.com/maxq-analytics/abd_cube) on [[GitHub]] and the core transformations are done using [[dbt]], also stored in its own [repository](https://github.com/maxq-analytics/abd-iowa-analytics) and hosted on [[Bigquery]] under its own [Project](https://console.cloud.google.com/bigquery?ws=!1m5!1m4!4m3!1seternal-ship-306122!2sabd_dbt!3sext_invoices&inv=1&invt=Abr05g&project=nifty-vault-331112). This demonstration setup is under continuous development by MAXQ Analytics and will improve over time.
## Demonstration
We have built a simple Python-Django proof-of-concept that showcases the response from the [[Cube]] AI API. The inserted text under *Question* is transformed by cube's AI API into a query that can be provided to the [[Semantics API]]. Since the data model inside cube knows which measures and properties are available (the data catalog), the chance of the AI-response to contain hallucinations are minimal.
> [!NOTE]
> When you ask your first question to the Analytics Agent, chances are it is hybernating, so you likely get no answer. Wait for 30 seconds and ask your question again.
>
> When the Agent is active, responses usually take 10 seconds.
### Try-out questions
**Input: 1 metric | 1 date range**
- *How many bottles were sold in 2021?*
- *What was the average bottle size sold in Week 35 of 2015?*
- *What was the total retail value sold in August 2024?*
**Input: 1 metric | 1 date range | 1 dimension | 1 filter | 1 order:**
- *What stores sold the most Jack Daniels in June 2023?*
- *Which 5 products sold by Crown Royal in 2023 have the highest average price per liter?*
- *Which cities bought the largest bottles in Q4 '22?*
**Input: 4 metrics | 1 date range | 3 filters | 1 aggregation:**
- *Between 2015 and 2022, what was the annual growth rate of Captain Morgan per year? Add to that the total retail value sold, the numbers of bottles sold and the average bottle price? Only look at Waterloo, Iowa City, Cedar Falls and narrow down your search on Hy-Vee stores only.*
- *Can you give me the Kirkland price averages per bottles, average liter per bottle and price per liter. Also give me the numbers of bottles sold. Look it up for the Costco in Davenport in H2'19 per quarter.*
- *What are the trailing twelve month amounts for the bottles sold, volume sold, invoices sent and retail value sold for the first 6 months of 2021 on a monthly basis for the Proximo Whiskies in the Sam's Club stores?*
<br>
## Embedded agent
<iframe src="https://eternal-ship-306122.ew.r.appspot.com"
frameborder="0"
style="width: 100%; height: 1000px; border: none;"/>
## Back-end logic
We created a 5 min. walkthrough on the back-end side of the Analytics Agent demonstration setup. It showcases the two-step flow, where we first send the question-string to the AI API and then take the response-JSON query and insert it into the REST-API.
<iframe width="100%" height="400" src="https://www.youtube.com/embed/k2CVH7wnDzU?si=QMHU5d1Zay8vCBAB" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
*Back-end logic walkthrough of the Analytics Agent*
## Limitations
In the current version of the AI API provided by Cube we encountered two limitations:
- **Multi-step questions cannot be handled**, because the current design provides singular-query answers and therefore a second question cannot yet be processed by the Agent. For example this question will fail at the second step: *What are the top 10 stores in number of bottles sold in Q1 2022. And of those 10 stores, what is the average sales price per bottle for Jack Daniels in that same period?*
- **Wrong dimensional filter selection** due to dimensions being to similar, which requires checking of the query generated by the Agent, and if the query generated selected the wrong property to filter on, the question needs to be stated more explicit.
## Integrations
### Slack
In March 2025 Cube enabled Cloud users to set up their own Analytics Agent [Slack App](https://cube.dev/blog/make-your-ai-smarter-turbocharging-cubes-ai-api-with-value-search-byollm-and) . The application interacts with the AI API similar to the demonstration showcased here. The generated output is then provided to an LLM to generate a summary based on the REST-API response data.
<br>
![[Analytics Agent Slack App.png]]
*Conversation with the Analytics Agent Slack application*
<br>
## Pricing
### CCU's
In march 2025 Cube revised the pricing for its AI API to make it more cost-effective for users. Initially, the AI API was priced at one Cube Consumption Unit (CCU) per request. However, due to a significant reduction in the cost per token of using large language models (LLMs), Cube has updated its pricing to five requests per CCU.
The cost of one CCU depends on the selected pricing tier:
- **Starter: $0.15 per CCU**
- **Premium: $0.30 per CCU**
- **Enterprise and Enterprise Premier: Custom pricing**
### Cost per request
Since one CCU now covers five requests, the cost per API request is:
- **Starter Plan**: **$0.15 / 5 = $0.03 per request**
- **Premium Plan**: **$0.30 / 5 = $0.06 per request**
Additionally, Cube offers the option for committed Cube Cloud customers to bring their own LLM (Bring Your Own Large Language Model - BYOLLM). This allows customers to use the AI API with their preferred LLMs, potentially optimizing costs and aligning with specific security requirements.
## Use cases
Building an analytics agent on top of Cube’s Semantic API opens up a variety of commercial use cases where real-time, AI-powered analytics can add value. Here are some opportunities we have identified:
### Embedded Analytics
- **Use Case**: Embed the agent into SaaS products as part of their analytics section. Make sure that the responses by the agent integrates well with the rest of the system.
- **Who Benefits?**: SaaS companies, software vendors, startups.
- **Value**: Enhances customer engagement, increases product stickiness, and provides a new revenue stream.
### Analyst support
- **Use Case**: Integrate the agent inside the default toolset provided to a financial or business analist. During ad-hoc insights request by product managers or executives the first exploratory phase can be supported by the analytics agent.
- **Who Benefits?**: Financial and Business Analysts, Business executives
- **Value**: Faster delivery time on business questions, Less workload towards SQL and Python practioners, richer pallet of options to analyse the issue at hand.
%% Owner: Philip Boontje %%