DEV Community

Shreyas
Shreyas

Posted on AI-assisted

Cred_Pred (A Credit Burn Analyzer)

Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission 💸

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle

What I Built

Cred_Pred tells startups and solo developers when their cloud credits will run out, before they do.

Founders on AWS Activate and similar programs get thousands of dollars in credits and then never track the burn. The credits vanish months early, or they expire half unused. cred_pred reads your Terraform (a file, a folder, or terraform show -json plan output) or a plain-English description. It prices the resources live through the Infracost API and reports monthly burn, runway in months, the run-out date, and how many credits will expire unused. A local open model writes a one-line cost saving tip.

A GitHub Action runs it on every pull request and comments with how the PR changes your burn and runway. For example, a PR that moved a t3.large to a t3.xlarge and added a load balancer got this comment:
burn $279.03 to $356.19 (+$77.16/mo), runway 17.9 to 14.0 months.

Who pays: the CLI and the Action are free and open source. The side hustle is a hosted or scheduled version (weekly runway emails, Slack alerts, live spend tracking) as the paid tier.

Demo

Github Actions Comment
Github Actions Comment

Report Generated for the startup's terraform files

Report Generated for the startup's terraform files

Code

GitHub logo kilqwe / hacktober-week-2

Credit burn predictor for startups and solo devs: feed it your Terraform, get live-priced monthly costs, how many months your cloud credits will last, and a cost-saving tip from a local open-source AI model. Runs in CI and comments on PRs. Hacktoberfest Week 2: Side Hustle.

Cred_Pred (A Credit Burn Analyzer)

Know when your cloud credits will run out before they do.

cred_pred reads your Terraform (or a plain-English description), prices the resources live through the Infracost API, and tells you your monthly burn, your runway in months, the date the credits run out, and how many credits will expire unused. A local open model (Ollama) writes a one-line cost-saving tip. A GitHub Action runs it on every pull request and comments with how the PR changes your burn and runway.

Built for startups and solo developers with cloud credits (for example AWS Activate) who never track the burn. Hacktoberfest Week 2, theme: Side Hustle.

Quick start

git clone <this repo>
cd <this repo>
pip install -r requirements.txt
# a free key from https://www.infracost.io
$env:INFRACOST_API_KEY = "your-key"      # or put it in a .env file

# local
…
Enter fullscreen mode Exit fullscreen mode

How I Built It

The rule behind the design: the model never does arithmetic and never prices anything. Every dollar figure comes from live Infracost pricing, a local cache, or a flat estimate labelled as one. Local open models (via Ollama) have two jobs only:

  1. Turn plain English into a resource inventory. Python validates every entry (allowed kinds, instance-type pattern, sane quantity) before trusting it.
  2. Write the advisor tip, behind a guard. The guard rejects a tip that contains a dollar or percentage figure that was not in the facts it was given, or that names an instance type the user doesn't have. The model gets one retry, then the tool falls back to a rule-based tip.
  3. Models: Gemma 3 (gemma3:4b) is the default everywhere: the CLI, and the GitHub Action on the Actions runner. Swapping models takes one flag (--model) or one GitHub variable (CRED_MODEL). Temperature 0 and a fixed seed make runs repeatable.

I benchmarked three models on 8 plain-English descriptions with known answers, and 3 advisor tips each, with prices fixed so every model saw identical facts:

Model Inventories exactly right Item F1 Extraction errors Avg extract time Tip passed 1st try Tip needed retry Tip fell back to rules Avg tip time
gemma3:4b 5/8 91% 0 failed, 3 dropped 3.4s 3/3 0/3 0/3 3.0s
qwen2.5:3b 8/8 100% 0 failed, 0 dropped 2.9s 2/3 0/3 1/3 3.6s
llama3.2:3b 4/8 86% 0 failed, 2 dropped 3.0s 0/3 3/3 0/3 6.0s

What I learned:

  • Same numbers, different tips. Costs were identical to the cent across models, because the model never touches the math.
  • The guard caught real hallucinations. Earlier in development, one model invented an instance size that doesn't exist (db.r5.xsmall), and another claimed a made-up size gives more power for the same cost. That is how the instance-name guard got added. In the final run, the guard rejected llama3.2:3b's first attempt on all three tips.
  • The guard doesn't catch bad advice. One tip said to upgrade to a more powerful instance to reduce costs. It had no invented figure or name, so it passed. A Gemma tip said shrinking database storage would "significantly lower" a bill where storage was $2.30 of $279. Guards check facts, not judgment.
  • Model size didn't predict quality. qwen2.5:3b was the most accurate at extraction. llama3.2:3b, also 3B, was the weakest and the slowest at tips, and its tips ran to two or three sentences when I asked for one line.
  • Where Gemma did well: gemma3:4b was the only model whose tips all passed the guard on the first try. It was second on extraction, and extraction is the weak spot: it got 5 of 8 inventories exactly right.
  • Limitations: flat us-east-1 estimates (labelled in the report) for EBS, RDS storage, NAT, load balancers, Elastic IPs, EKS and Fargate. Usage-based costs (data transfer, load balancer capacity, CloudFront and S3 traffic) are invisible to Terraform, so real burn is higher. Lambda, S3, CloudFront and ECR aren't priced, and the report names them. The .tf parser can't expand modules or for_each, so plan JSON is the exact route.

Why Does Open Innovation Matter?

  • Privacy. Infrastructure files describe your network, databases and account layout. With a local model, they never leave your machine or CI runner. With a hosted API, every pull request would send them to a third party.
  • Cost. Inference is free, so the tool can run on every PR instead of once a month. A per-call fee would push you to run it less.
  • Swappable models. Changing models is one variable, which made the bake-off possible and let me see that the model with the best extraction (qwen) wasn't the one with the safest tips (gemma3).

My First User

A friend who works at a startup let me run the tool on a real Terraform project: 11 files covering an ECS Fargate service, an ALB, an EC2 instance, RDS Postgres, and CloudFront and S3. It's an older project, so I can't compare against a real bill.

cred_pred priced the stack at $81.37/mo, about 61 months of runway on $5,000 in credits. It named the four resource types it couldn't price (CloudFront, S3 and two ECR types), so the report flags the runway as an upper bound. The EC2 and RDS lines came back from live Infracost pricing. The biggest line, Fargate at 35% of the total, is a labelled flat estimate, and the report notes that Spot would make it cheaper.

Prize Categories

Best Use of Gemma: Gemma runs the advisor tip and plain-English parsing locally through Ollama. gemma3:4b is the default model in the CLI and in the GitHub Action on the runner. It was the only model whose tips all passed the guard on the first try in the bake-off.

Top comments (0)