Brex builds an embedded AI financial analyst for 35,000+ customers with Cube

Replaced 3,000+ lines of in-house prompts with Cube Cloud — answers in seconds, not days

Brex logo
Brex builds an embedded AI financial analyst for 35,000+ customers with Cube
IndustryTechnology
Employees1,001-5,000
HQSan Francisco, CA, United States
Use CasesEmbedded Analytics

Brex is an intelligent finance platform that combines corporate cards, spend management, expense tracking, business banking, and travel into a single product, serving over 35,000 companies globally. As Brex set out to redefine financial reporting for its customers, they needed a foundation that could power AI-native experiences with the accuracy, governance, and scale that finance teams demand.

The Challenge: Moving Beyond Static Dashboards

Brex saw that financial reporting across the industry hadn't fundamentally changed in two decades. When a CFO asks "Why is marketing 23% over budget this quarter?", the dashboard shows the what but never the why. Getting a real answer typically requires filing a ticket, waiting for an analyst to write SQL, validating the output, and pasting results into a slide — a two-second question turning into a two-day project. Brex set out to eliminate that gap for every finance team using their platform.

This created several compounding problems Brex needed to solve:

  • Rigid dashboards, inflexible answers: Pre-built dashboards are fast but only answer pre-defined questions. The moment a finance leader asks something new, the entire ad-hoc cycle restarts.
  • Bottlenecked data teams: Analysts spend significant time on repetitive reporting requests instead of strategic work, while business users wait days for answers they need in real time.
  • No interpretation layer: Charts present data but don't explain anomalies, surface historical context, or recommend what to look at next — the things a senior analyst would naturally do.
  • In-house AI prototype hit a wall: Brex initially built a lightweight in-house agent on top of self-hosted open-source Cube Core. Maintaining the agent required heavy infrastructure overhead — blue-green deployments, on-call rotations, and reliability work. Their prompt layer ballooned to over 3,000 lines across four files, creating a maintenance treadmill where every new capability risked breaking another.

Brex needed a way to give every customer the equivalent of an embedded AI financial analyst — one that understood Brex-specific concepts like card programs, expense policies, entity structures, and approval workflows — without rebuilding the underlying analytics infrastructure from scratch.

The Solution: An AI-Native Reporting Stack Powered by Cube

Brex built Spaces, an AI-powered workspace for finance teams that delivers insights in seconds rather than days. Underpinning Spaces is a deliberate architectural decision: invest in ontology and semantics before writing a single line of UI code.

After evaluating semantic layer providers including Cube, dbt Semantic Layer, and LookML against AI-readiness criteria, Brex chose Cube and ultimately migrated from their self-hosted open-source deployment to Cube Cloud. The decision came down to three factors: eliminating infrastructure overhead, replacing thousands of lines of brittle prompts with a managed agent, and — most importantly — evaluation results showing that Cube's cloud agent significantly outperformed their in-house agent on data consistency, tool usage, and answer quality.

Cube became the foundation of a three-layer context engineering approach:

  1. The proprietary semantic layer encodes Brex's financial domain — what "spend" means, how departments roll up, how entity structures map to accounting hierarchies, how compliance thresholds are defined. This is what turns a generic SQL agent into a Brex financial analyst, and what makes Spaces a Brex product rather than a generic BI tool.
  2. Certified Queries are pre-validated, analyst-approved SQL patterns the AI references for the most common financial questions. Cube's Certified Queries feature lets Brex curate gold-standard logic that the agent adapts from, rather than generating queries from scratch every time — dramatically reducing hallucinations and increasing trust.
  3. Agent Rules shape behavior at the system level — when to flag anomalies, how to contextualize against historical patterns, how to format insights. Cube's Agent Rules are declarative instructions configured directly in Cube Cloud (with both Always rules that apply to every interaction and Agent Requested rules the agent invokes contextually). By moving to Cube Cloud, Brex replaced 3,000+ lines of custom prompts with roughly 10 Agent Rules unique to their business, letting Cube handle orchestration, querying, and chart generation.

To ship AI-native reporting to customers with confidence, Brex also built a robust evaluation system on top of Cube. Online evaluators run lightweight, deterministic checks for production edge cases — like distinguishing "my travel spend" from "the account's travel spend," or ensuring the agent discovers exact enum values before running SQL filters. Offline evaluations use LLMs as judges to score replays across answer quality, chart appropriateness, data consistency, insight relevance, and semantic layer usage. This continuous loop helped Brex raise their insight relevance score from the high 50s to nearly 90%.

The future of reporting isn't a chart, it's an insight. Large language models are becoming a commodity — the LLM is the engine, but the semantic layer is the map. A well-modeled ontology is the difference between 'I don't understand that question' and a correct, contextualized answer with a chart and a clear explanation. Cube gives us the foundation to make that real for every customer.
Picture of Dan Meshkov - the Participant

Dan Meshkov

Staff Software Engineer, Brex

The Results: From Charts to Insights, From Days to Seconds

By building Spaces on Cube's semantic layer and AI-native infrastructure, Brex transformed financial reporting from a backward-looking artifact into a real-time analyst experience:

  • Two-day questions answered in two seconds: Finance teams using Spaces no longer wait for analyst tickets to understand budget variances, spend anomalies, or compliance flags — they get explanations instantly, with charts, context, and recommended follow-ups.
  • Insights, not just data: Spaces doesn't just visualize numbers — it surfaces anomalies, contextualizes results against history and benchmarks, and explains in natural language what happened, why it matters, and what to look at next.
  • Massive engineering simplification: By moving from a self-managed open-source deployment with 3,000+ lines of prompt code to Cube Cloud, Brex eliminated infrastructure on-call burden and reduced their custom guidance to roughly 10 Agent Rules configured natively in Cube.
  • Higher answer quality, measurably: Cube's managed agent outperformed Brex's in-house agent across data consistency, tool usage, and overall answer quality in head-to-head evaluations, while their evaluation system pushed insight relevance scores from the high 50s to nearly 90%.
  • A defensible, multi-tenant foundation: Brex's investment in proprietary semantics, Certified Queries, and continuous evals creates a product moat that compounds over time — one that scales across thousands of customers, each with isolated data but a shared, governed model.
  • Conversational, refinement-friendly UX: Internal user testing revealed customers don't want a single answer — they want to refine, filter by date, drill into segments, and compare periods. Cube's semantic layer supports this conversational pattern natively, making Spaces feel less like a dashboard and more like working with an analyst.

Brex's broader takeaway, applicable to any team building AI-native data products: ontology comes before UX, Certified Queries are how you earn trust, and evaluation systems are non-negotiable when customers make real financial decisions on your AI's output. As Brex puts it, the LLM is commodity — the context is the product.

Ready to upgrade your data stack?