Skip to main content
← BlogCOST REPORTING / HEX TEMPLATE
LiteLLMHex

AI spend.Cost reporting, now in Hex.

Connect Hex to your LiteLLM Postgres data.
Set budgets and routing in LiteLLM.

View live Hex demo
TEAMS / MODELS / BUDGETSOPEN TEMPLATE · V2.0.0
THE HEX BOARDSYNTHETIC DEMO DATA

Explore the live Hex dashboard.

Open the working demo ↗ · Synthetic data · No sign-in

Hex board showing project spend, request volume, unit costs and daily trends with synthetic data

See a model change raise unit cost.

Zoomed Hex demo alternating between project model mix and the cost-change table, where document-review shows an 80 percent unit-cost increase
Model mix and seven-day cost changes in Hex. Synthetic demo data.

The public demo includes synthetic timing metrics. The daily team template reports recorded costs, requests and usage; daily rows do not include latency.

LiteLLM records AI costs in Postgres and maintains daily spend totals. Hex connects to that database and reads the totals. Use the dashboard to find a cost increase, then open LiteLLM to change routing or set a budget.

1. Connect Hex to your LiteLLM Postgres database​

In Hex, open Settings → Data sources → + Connection → Postgres. Add a read-only connection to the database your LiteLLM gateway uses.

READ-ONLY DATA FLOWEXISTING DAILY AGGREGATES
01 / YOUR POSTGRESDaily spendLiteLLM_DailyTeamSpend
date + team_id
Day and team
model + spend
Recorded costs
api_requests
Daily requests
prompt_tokens + completion_tokens
Token usage
02 / HEX SOURCE QUERYTeam namesLiteLLM_TeamTable

Join daily totals to team display names.
Keep ownership by stable team ID.

SQL included in the templateNo database objects created
03 / YOUR HEX APPCost reporting

Team costs. Model mix.
Daily trends. Cost changes.

Refresh with a scheduled run
LiteLLM writes the daily totals in Postgres. Hex reads reporting columns from these two existing tables. You change budgets and routing in LiteLLM; Hex does not write to the gateway.

The template reads two existing tables: LiteLLM_DailyTeamSpend for costs and usage, and LiteLLM_TeamTable for team display names. It groups the results by day, team and model. Give the reader access to those reporting fields. It does not need your key table, prompts or responses.

Connection details and SQL permissions.

2. Add the template and inspect your costs​

Open the live Hex demo first. You can filter it without signing in. Its records are synthetic.

To use your own data, download the Postgres template below. In Hex Home, click + → Upload project, then click Upload in the dialog and choose the .hex.yaml file. Select your Postgres connection on the Source SQL cell and Run all.

Hex dialog for uploading a YAML project

Filter by team. Compare recorded spend, request volume and cost per thousand requests, then open Models and cost changes. In the demo, the Legal team's document-review workload switches models and unit cost rises 80%.

3. Take an action in LiteLLM​

Use Hex to investigate the increase. Apply the change through your LiteLLM gateway.

Your decisionIn the LiteLLM UI
Try a cheaper modelOpen Teams → your team → Settings → Edit Settings → Model Aliases. Change the model behind an alias your application already calls, then save. Evaluate the candidate on your workload first.
Route by request complexityOpen Models + Endpoints → Auto Router → Add Auto Router. Choose the models for each tier, test routing and connections, then save. Configure your application or team alias to call that router.
Set a spending limitOpen Teams → your team → Settings → Edit Settings. Set Max Budget (USD) and Reset Budget, then save.

For example, select Legal in LiteLLM and set Max Budget (USD) to 1000 and Reset Budget to monthly (30 days). This limits new spend; it does not change recorded costs.

Set Legal’s budget in the LiteLLM team settings

Current LiteLLM UI with synthetic local gateway data.

After saving, check the team's budget status. Then refresh Hex after LiteLLM updates its daily totals to compare the next complete period. Set a Hex scheduled run if you want the report to refresh on a schedule.

Legal’s budget status after saving

Auto Router setup · Team budgets