SShortSingh.
Back to feed

Token Ledger Blocks AI Calls Once a Free Daily Budget Runs Out

0
·1 views

A developer describes a zero-cost AI feature that stops making model calls once its daily token allowance is used up. The main risk, they argue, is not repeat traffic but estimation error, where one long prompt or a retry loop can exhaust the whole day's budget in a single call. The approach uses a small standard-library Python ledger that reserves an estimated token count before each request and then settles it against actual usage. When the budget is exhausted, the code returns a zero-token fallback rather than calling the model. Character counts divided by four serve as a rough estimate for English text, with the guard calibrating against real usage because code, CJK text, and JSON tend to run higher.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Old Laptop SSDs Can Be Reused as Fast USB-C External Drives

Millions of retired laptops still contain working solid-state drives that often end up discarded with the rest of the machine. A removable SSD placed in a USB-C enclosure can keep delivering read speeds around 500 MB/s or more, extending its useful life. The article notes that such enclosures, like a Sabrent model supporting USB 3.2 Gen 2x2, can reach roughly 2.5 GB/s on a compatible host and are relatively inexpensive compared with pre-built external drives. It outlines a workflow covering checking whether the drive is removable, backing up data, assessing drive health, formatting, and installing the SSD into the enclosure. Soldered SSDs, such as those in some Apple ultra-thin laptops, cannot be removed and so cannot be repurposed this way.

0
ProgrammingDEV Community ·

Free open-source AI website builder can now search the web mid-generation

openconstructor, a free open-source AI interface builder that runs in the browser, now lets its model look up live information online. Instead of relying on a dedicated tool-calling API, which its small free models handle unreliably, the builder uses the same one-line JSON protocol to request searches. A Cloudflare Worker performs the lookups via DuckDuckGo with a Wikipedia fallback, reads the top results, caches them for an hour, and blocks private addresses. The model searches only when it needs time-sensitive facts, and each user message is counted as a single generation regardless of how many calls it makes. The interface also now shows a progress timeline and status text while the AI works.

0
ProgrammingDEV Community ·

Guide Explains Building, Scaling and Securing Cloud Infrastructure with AWS EC2

A DEV Community article offers a practical introduction to Infrastructure as a Service (IaaS), a cloud model where providers supply virtualized computing resources over the internet. It explains how teams can provision virtual servers, storage and networking on demand instead of buying and maintaining physical hardware. The piece contrasts IaaS with Platform as a Service and Software as a Service, highlighting how much control the customer keeps in each model. It also outlines when IaaS is the right choice, such as when full control over operating systems is needed. Amazon Web Services EC2 is used as the main case study for implementation, pricing and security considerations.

0
ProgrammingDEV Community ·

Staged Retrieval Design for Tracing Node.js Changelog Citations

A developer shares an architecture for a changelog tracker that answers questions about Node.js releases with traceable citations. The design uses a retrieval contract returning a claim, source identifier, context window, and confidence signal. Searches are scoped by per-stream collections and metadata filters before semantic ranking, with a two-stage process that demotes results lacking recorded headings, release tags, or canonical URLs. Four configurable budgets (ingestion work, query fan-out, context tokens, and retry time) bound resource use, and a retry-aware query boundary handles timeouts and rate limits. Content hashes on chunks let ingestion upsert only changed material and remove records for deleted sources.