
Five things that fought back: building ClaimBack on AWS in four days
A hackathon build that checks Indian health insurance claim deductions against the policy wording and IRDAI rules. The interesting part wasn't the AI - it was a superseded circular, a Bedrock endpoint that 404s in Mumbai, and a GitHub OIDC token that silently broke every deploy.
Indian families get hospital claims cut all the time: "non-payable consumables", "proportionate deduction", "reasonable and customary charges". Most people pay the difference, because checking means reading a 40-page policy wording against IRDAI's regulations.
So I built ClaimBack over the WeMakeDevs "First Commit" weekend. You upload the hospital bill, the insurer's letter and your policy schedule; it checks every deduction, tells you what you can challenge and quotes the exact clause, then drafts the complaint letter.
The AI part was the easy bit. Here's what actually fought back.
1. The rule everyone cites was repealed in 2024
Every "non-payable items" article online cites IRDAI's 2020 standardization circular, with its famous List I-IV of 146 items (gloves, admission kits, documentation charges).
That circular was superseded on 29 May 2024 - it's item 1 of Annexure-6 of the new Master Circular on Health Insurance Business. No 2024+ regulation carries the lists forward.
They still bind you, but as a contract term: they're printed as Annexure-A inside your policy wording. So ClaimBack cites your policy, not IRDAI, for those.
A related surprise: the "standard" Arogya Sanjeevani product isn't worded identically by every insurer. One insurer applies the room-rent proportionate cut only to room, nursing, doctors' fees and OT charges. Another applies it to everything except medicines. On one sample bill that's ₹22,800 challengeable under one wording, ₹14,400 under the other. Same bill.
If you build anything on regulations: check what's still in force, and read the contract.
2. Bedrock's Messages API endpoint doesn't exist in Mumbai
I wanted ap-south-1 so medical documents stay in India. The Anthropic SDK's Bedrock client gave me:
NotFoundError 404 - {'type': 'not_found_error', 'message': 'not found'}The same call in us-east-1 returned a normal 403 for a model I didn't have access to. That contrast was the clue: the endpoint itself (
bedrock-mantle.<region>.api.aws ) isn't in Mumbai yet.The fix is the classic
bedrock-runtime InvokeModel path with an inference-profile model id ( global.anthropic.claude-opus-5 ). Note apac.anthropic.claude-opus-5 doesn't exist; global. does.3. A new AWS account is "under verification" for Bedrock
Fresh account, credits applied, and every model call returned:
Your account is currently being verified. Verification normally takes less than 2 hours.
Even Titan embeddings, which broke Knowledge Base ingestion. Worth knowing before you plan a demo an hour before a deadline. Separately, Anthropic models need a one-time use-case form per account - mine didn't clear in time, which led to...
4. Swapping Claude for a 14B model, and the ₹5,00,000 bug
I switched to Ministral 3 14B on Bedrock: available immediately, and about 20x cheaper (~$0.24/1M tokens vs $5 for Opus). Three things had to change:
It can't take PDFs. Converse rejects documents for this model, so I render pages to PNGs with
pypdfium2 and send images.One big schema confused it. Asking for the whole claim in a single tool call failed validation repeatedly. Splitting extraction into three small calls - policy + admission, bill lines, insurer decision - each seeing only the relevant pages, made it reliable.
Indian digit grouping. This one is nasty:
5,00,000read as 5000000
Five lakh became five million. Sum insured drives room-rent limits, so every downstream number would have been wrong. Prompting alone didn't fix it. What did: make the model copy the printed text, and parse the digits myself.
class PolicyAndAdmission(BaseModel):
sum_insured_as_printed: str # "5,00,000" - copied, not computed
policy: PolicyInfo
admission: Admission
def rupees(printed: str) -> float | None:
cleaned = re.sub(r"[^0-9.]", "", printed or "")
return float(cleaned) if cleaned else NoneIf you take one thing from this post: when a number matters, have the model transcribe and let code parse.
Does the cheap model actually work? I measured it instead of guessing. An eval scores extraction against five claims whose correct answers are known. Ministral 3 14B got:
- Fields (dates, amounts, policy history): 78 / 80
- Bill lines: 60 / 60
- Deduction rows: exact on all 5
- Same challengeable amount as the known answer: 5 / 5
- From a creased phone photo of the bill: same result
About $0.02 per claim. The reason a 14B model is enough: it only reads and explains. A deterministic rule engine makes every verdict, and each one cites a policy clause, an IRDAI rule or a list item with its page number.
5. GitHub's OIDC token quietly broke every deploy
I set up GitHub Actions to deploy with OIDC, so no AWS keys live in the repo. Every run failed with:
Could not assume role with OIDC: Not authorized to perform sts:AssumeRoleWithWebIdentityNo detail. Role ARN right, audience right, trust policy looked textbook. So I printed the token's claims in the workflow:
{
"sub": "repo:HitanshGithub@167395477/claimback@1375710113:ref:refs/heads/main",
"aud": "sts.amazonaws.com"
}GitHub now issues subjects with immutable numeric ids. Every
repo:owner/repo:* trust policy (i.e. every tutorial) matches nothing. The fix accepts both forms:StringLike:
token.actions.githubusercontent.com:sub:
- repo:owner/repo:*
- repo:owner@*/repo@*:*Bonus Lambda gotcha from the same day: I stripped
*.dist-info folders to slim the bundle, and httpx2 - which reads its own version from installed metadata at import - crashed with PackageNotFoundError . Keep the metadata.The architecture
- Amplify Hosting - React frontend
- API Gateway (HTTP API) + Lambda - FastAPI via Mangum
- Step Functions - 7-step analysis pipeline, with a catch so a claim never sticks on "processing"
- DynamoDB + S3 - claims and documents, with a 30-day expiry rule on medical files
- Bedrock - Ministral 3 reads documents, reviews what the rules can't settle, polishes letters
- Bedrock Knowledge Base on S3 Vectors - IRDAI regulations, policy wordings and 40 real Ombudsman and court decisions. S3 Vectors rather than OpenSearch Serverless, which starts around $175/month
- SAM + GitHub Actions (OIDC) - push to main runs tests, deploys, and smoke-tests production
Idle cost is a dollar or two a month, because nothing runs between claims.
What I'd tell myself on Thursday
- Check whether the regulation you're building on is still in force. Half my dataset work was redone after finding that circular was repealed.
- Deploy on day one. Every problem above was environmental, not code.
- Measure the model, don't trust it. The eval is what let me swap a $5/1M model for a $0.24/1M one and know the answers stayed right.
Built with Claude Code (Claude Opus 5) as the coding assistant. ClaimBack gives information, not legal advice, and all sample documents are fictional.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article