
Teaching an AI agent to read Indian electricity bills, and keeping the maths out of the model
How I built Groundwork, a serverless household energy and waste agent for India on AWS: a vision model reads the bill, tested code does every calculation, and a Strands Agents copilot answers in Hindi, Marathi or English.
A typical city household in India pays ₹3,000 or more a month for electricity, and rooftop solar offers keep arriving. The government's PM Surya Ghar scheme will pay up to ₹78,000 of a system and aims to reach one crore homes. Yet the question every family asks, "does solar actually pay for us?", is surprisingly hard to answer. The answer hides in four places at once: the power company's slab tariff, the sanctioned load printed on the bill, the roof, and the subsidy rules.
So I built Groundwork: photograph your electricity bill, and it tells you whether solar pays, with every rupee shown. It does the same for waste (a photo sorts a pile into the streams India's 2026 rules require and books a local recycler) and for water (two meter readings catch an overnight leak). This post is about the one design decision that made it trustworthy, and how the agent on top of it works.
The tempting mistake
The obvious build is "send the bill photo to a big model and ask whether solar is worth it." You get a confident paragraph with a payback period in it. Ask again and you get a different payback period. Neither one comes from the regulator's actual tariff order.
For a money decision that's the wrong tool. Language models are very good at reading messy photos and at talking to people. They are not a calculator, and they don't know this year's tariff slabs.
AI reads, code calculates
Groundwork splits the job in two.
1. The model only reads. The bill photo goes to a vision model with a forced tool call: it must fill a fixed schema (power company, units, billing period, amount, sanctioned load, supply phase) and, for each field, quote the exact text it read. Temperature 0. No arithmetic.
2. Code checks what it read. Dates must parse; the billing period must be 25 to 65 days; units must be in range. Then the code recalculates the bill from the regulator's tariff. If the amount on the bill is more than 40% off what the tariff says, both fields get flagged. The user sees a confirm screen where every value says "Read as …", and anything doubtful is marked.
3. Code does every calculation, and shows its working. Sizing, generation (NASA POWER sunlight for the exact roof), the subsidy, slab-by-slab savings and month-by-month payback are plain Python functions. Each returns its result and its working: the formula, the inputs and the source. The app shows that in a "How we calculated this" drawer beside every number.
The model never produces a number the user is asked to trust.
The agent on top: Strands Agents
People don't want to navigate screens; they want to ask "should we put solar on the roof?" in Hindi or Marathi. So the front door is a multi-agent copilot built with Strands Agents, AWS's open-source agent SDK.
- An orchestrator agent decides which specialist should answer: solar, water or waste. Each specialist is itself a Strands agent, handed to the orchestrator as a tool, which took only a few lines.
- The specialists work through 11 tools: the household's bills and solar report, water and waste summaries, a material guide, the local recycler list, and readers for a bill, meter or waste photo attached to the chat.
- Every tool is bound to the signed-in user (their Cognito identity), never to anything the model says. The agent can only ever see that household's data.
- The agents never do arithmetic either. They quote numbers the calculation code produced, and code checks every reply for numbers that didn't come from a tool.
Ask "who can collect my dry waste?" and the waste specialist calls the recycler tool and answers with the listed collector in your city. Ask in Hindi and it answers in Hindi.
What fought back
- Water meters. Meter wheels get photographed half-way between two digits, and my first reader was confidently wrong about the decimals. The fix wasn't a better prompt: the model now only transcribes digits, two different models read each photo, and code reconciles them. If they disagree, the reading is flagged for the user instead of guessed. On 20 public meter photos, 17 were within one cubic metre.
- Free-tier quotas. Small daily limits per model mean a demo can die mid-conversation. The provider layer falls through a chain of models and providers, identical photos are answered from a cache in DynamoDB, and if every model is down the copilot still answers from rules.
- Bedrock access. I built every model call to go through one provider layer in Bedrock's Converse format, with Bedrock (Nova Lite) as the default. My access request was declined for now because the AWS account was new with little usage history. Because of the provider layer, the same requests run on another provider today, and switching to Bedrock later is one deploy parameter.
- Language. The copilot first answered Hindi questions in English, because it followed the page language. Now it answers in the language you write in.
The stack
Everything is serverless on AWS in ap-south-1 (Mumbai):
- AWS Amplify hosts the Next.js app; Amazon Cognito signs people in.
- A FastAPI app runs on AWS Lambda, unchanged, thanks to the open-source Lambda Web Adapter, with response streaming so answers appear token by token.
- Strands Agents runs the copilot.
- Amazon DynamoDB holds everything in one table, with TTL for chat history and the AI cache.
- Amazon S3 takes photo uploads by presigned POST and deletes them after a week.
- Amazon EventBridge Scheduler holds a daily leak-check reminder job.
- AWS SAM defines all of it in one template.
Try it
- Live app (click "Try the demo", no sign-up): https://sample-bill.dj7ciboa1zoj1.amplifyapp.com
- Video: https://youtu.be/elE1k2Ifn9U
If you build anything that makes a money decision for people, keep the maths out of the model. Let it read, let it talk, let an agent find the right tool, and let tested code do the sums where everyone can see them.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article