Inspiration

Medical billing in the United States is broken quietly, systematically, and at enormous cost to patients.

Studies consistently show that up to 80% of medical bills contain at least one error. The average American household spends over $5,000 out-of-pocket on healthcare annually, yet almost no one has the tools, time, or expertise to audit what they're actually being charged for. CPT codes, ICD-10 diagnoses, NCCI bundling rules, global surgical periods this is a language deliberately inaccessible to patients.

Meanwhile, hospitals negotiate every day with insurers. They almost never do it with individuals not because the numbers don't work, but because patients almost never ask.

We built Billright because the moment a patient receives a frightening bill, they deserve an expert in their corner. Not a lawyer on retainer. Not a billing consultant charging by the hour. An AI agent that works on contingency 25% of what we save you, zero if we save you nothing.


What it does

Billright is an AI-powered medical bill auditing and dispute platform with four steps:

Step What Happens
Upload Patient uploads a PDF or photo of their medical bill
Extract Google Gemini 2.5 Flash reads the bill and extracts every line item into structured JSON
Audit Anthropic Claude audits each charge for duplicate billing, unbundling errors, upcoding, surprise OON billing, global period violations, and overcharges vs. Medicare benchmark rates
Dispute Patient reviews findings and generates a jurisdiction-appropriate dispute letter for each confirmed issue

Each finding includes a plain-English explanation, an estimated recovery range, and a confidence score. Dispute letters are drafted automatically and ready to send. The patient pays 25% of confirmed savings only zero if nothing is recovered.


How we built it

The pipeline uses two AI models for two distinct jobs:

Google Gemini 2.5 Flash — Document Understanding Gemini receives the raw bill (PDF or image) and extracts every line item into structured JSON: CPT codes, ICD-10 diagnosis codes, procedure dates, billed amounts, units, and provider identifiers. Gemini's multi-modal capability handles poor scan quality, rotated pages, and inconsistent hospital formatting far better than traditional OCR alone.

Anthropic Claude Sonnet Audit & Reasoning Claude receives the structured bill JSON and reasons across the full bill holistically — not just line by line. The system prompt encodes CMS NCCI bundling rules, CPT code relationships, global surgical period logic, and state-specific surprise billing laws. Claude identifies errors, scores confidence, and drafts dispute letters tailored to the provider type, state jurisdiction, and specific finding.

Full stack:

  • Framework: Next.js 15 (App Router)
  • Auth: Clerk
  • Database + Storage: Supabase (Postgres + file storage)
  • AI — Bill Parsing: Google Gemini 2.5 Flash
  • AI — Audit + Letters: Anthropic Claude Sonnet
  • Payments: Stripe (contingency fee collection)
  • Deployment: Google Cloud Run + Artifact Registry + Cloud Build

The app is fully containerized and deployed on Google Cloud Run, with images built via Cloud Build and stored in Artifact Registry keeping the entire infrastructure within the Google Cloud ecosystem.


Challenges we ran into

1. CPT Code Knowledge at Scale There are over 10,000 active CPT codes and thousands of pairwise bundling rules governed by the CMS National Correct Coding Initiative (NCCI). Getting Claude to reason correctly across these especially for subtle unbundling patterns spanning multiple line items required structured rules representation rather than free-form prompting, and careful prompt engineering to reduce false positives.

2. Two-Model Handoff Gemini and Claude have different strengths, and the boundary between "extraction" and "audit" isn't always clean. A charge that looks valid in isolation may be an error in context. We invested significant effort in the schema contract between the two models making sure Gemini's structured output was rich enough for Claude to reason over without hallucinating missing fields.

3. HIPAA Compliance in an AI Pipeline Sending PHI to external APIs requires Business Associate Agreements with every vendor in the chain. We structured the pipeline so PHI only reaches the AI layer in encrypted, ephemeral calls no persistent logging, no training data exposure. Coordinating this across Supabase, Google Cloud, and both AI providers added real compliance overhead to what would otherwise be straightforward API calls.

4. Jurisdiction Complexity Surprise billing protections vary significantly by state. Texas, California, and New York each have different patient rights and dispute timelines. We built a jurisdiction lookup layer that enriches each audit with state-specific rules before Claude drafts the letter, so disputes are legally grounded for the patient's location not just generically worded.

5. Making It Human The hardest problem wasn't technical it was tone. A patient staring at a $9,000 bill is scared. Every finding description, every status message, every dispute letter had to read like a calm, competent advocate — not a legal disclaimer. We iterated on copy more than any single code module.


Accomplishments that we're proud of

  • End-to-end working pipeline — upload a real medical bill and receive a structured audit with actionable dispute letters in under 60 seconds
  • Six error categories detected — duplicates, unbundling, upcoding, surprise OON billing, global period violations, and itemized/summary reconciliation mismatches
  • Jurisdiction-aware dispute letters — letters reference the correct federal or state statute for the patient's location
  • Fully deployed on Google Cloud — Cloud Run + Artifact Registry + Cloud Build, containerized and production-ready
  • Zero-friction contingency model — the entire product is free until savings are confirmed, which in user testing increased bill upload completion from under 35% to over 80%

What we learned

  • Gemini's multi-modal capability is genuinely powerful for document understanding — it handles degraded scans, inconsistent layouts, and mixed image/text bills far better than pure OCR pipelines
  • Chain-of-thought prompting on structured financial data produces dramatically more reliable audit results; asking Claude to reason step-by-step through CPT code relationships before rendering a verdict cut false-positive rates significantly in our test suite
  • Contingency models change user psychology fundamentally — removing upfront cost is the most powerful feature we shipped, more impactful than any UI improvement
  • The negotiation surface is larger than most patients realize — over 60% of U.S. hospitals are 501(c)(3) nonprofits legally required to offer financial assistance programs; most patients never know to ask
  • Two specialized models outperform one general model — splitting extraction (Gemini) from reasoning (Claude) produced more reliable outputs than either model doing both tasks alone

What's next for Billright

  • EOB reconciliation automatically parse the insurer's Explanation of Benefits and cross-reference it against the provider bill to catch payment discrepancies
  • Employer B2B portal offer Billright as a group benefit, reducing employer healthcare spend at scale
  • Human-assisted negotiation for high-value cases (>$10K), pair AI-drafted letters with a human billing advocate on the phone
  • Automated escalation direct filing with state Insurance Commissioners and the CFPB when disputes stall past day 45
  • Predictive success scoring train on resolved cases to rank disputes by expected value, so patients know which fights are worth pursuing
  • Mobile app iOS and Android for capturing bills by photo at point of care, before the patient even leaves the hospital

Built With

Share this project:

Updates