If you have multiple projects on Neon (neon.tech) under one organization, then it is a good idea to get a costs/spend report by project and keep tabs on for better operations/planning.
Neon bills compute by CU-hours, but its dashboard doesn't give you a simple monthly cost breakdown per project. I wrote a small Node.js script that pulls Neon's per-project consumption history and turns it into a CSV rollup: one row per project, total CU-seconds, CU-hours, and cost in dollars — plus an org-wide TOTAL row.
THE PROBLEM
Neon's usage API returns raw metrics per project per day (CU-seconds, storage bytes, network transfer, etc.), but you have to stitch together several steps to get a usable cost figure:
- Fetch consumption history for a calendar month
- Handle pagination (the API uses a cursor)
- Convert CU-seconds to CU-hours, then multiply by your plan's rate
- Flatten nested metrics into CSV columns
- Build a cost rollup per project
The script takes a month argument (e.g. oct-2026), fetches the org's consumption history from Neon's API, and writes three files:
-
neon-usage-oct2026.json— raw API response, so you can re-slice later without re-fetching -
neon-usage-oct2026.csv— one row per project per day, every metric as its own column -
neon-usage-oct2026-total.csv— one row per project: total CU-seconds, CU-hours, andcost_usd, plus aTOTALrow across the org
The rollup CSV is the file that actually gets used each month.
Neon bills compute as CU-hours — 1 CU is "1 vCPU + 4 GB RAM." The API reports compute_unit_seconds pre-multiplied (a 2-CU endpoint running for one wall-clock second shows up as 2 compute_unit_seconds). So the cost math is:
const hours = compute_unit_seconds / 3600;
const cost = hours * RATE_USD_PER_CU_HOUR;
USAGE
node scripts/org-neon-usage-report.mjs oct-2026
Requires NEON_API_KEY (set in environment or .env.local; create one at https://neon.com/docs/manage/api-keys). NEON_ORG_ID defaults to your org but can be overridden via env.
TLDR: Neon's per-project usage isn't in the dashboard, but it's a few fetch calls away once you know the endpoint and pagination shape.
References
- Neon usage calculations docs — https://neon.com/docs/introduction/usage-calculations
- Neon API keys — https://neon.com/docs/manage/api-keys
Top comments (2)
the script is in this public gist:
gist.github.com/akaak/4ab7a3e3327d...
Great work! I like how you turned raw usage metrics into an actionable, project-level cost report. Cost visibility becomes increasingly important when managing multiple projects and scaling AI applications.
As I learn to build AI agents with LangChain and FastAPI, I’m also thinking about monitoring infrastructure costs, tracking resource consumption, and making deployments more efficient. This kind of automated reporting could be especially useful for managing LLM API usage and backend infrastructure expenses.
One question: have you considered extending the script to track historical spending trends or send alerts when a project exceeds a predefined budget?
Thanks for sharing this practical solution!