
- Reading
- 5 min
Using OpenCode, I built an open-source Chrome extension that shows how many tokens a selected piece of text will consume across different AI models.
Originally published on TekZoom on YouTube, on November 15, 2026.
The biggest fear for anyone using AI is the familiar question: "how much will this cost in tokens?" To solve that in practice, I decided to build a Google Chrome extension that calculates a prompt's cost before you send it. With it, you can see how many tokens a piece of text would cost, comparing different AI models. It's a simple, open-source extension that anyone can use and improve.
The entire build was done with OpenCode running in the terminal. If you follow along, you know OpenCode has two working modes: build mode, for actually writing code, and plan mode (turned on with Shift+Tab), where the AI only plans what will be done, without writing any code yet.
Setting up the project with agents.md
The first step was creating a folder called extensão-tokens and, inside it, an agents.md file. This file is what tells the AI everything it can and can't do in the project, it's like an instruction manual that sits alongside the code.
Expert views
What people are saying about it.
Tether AI Research released VisionPsy2 on December 3, 2026, a family of vision-language models with fewer than 1 billion parameters that promises the quality of much larger models while running locally on smartphones.
Back in Las Vegas, I'm following an AI agenda that spreads across AWS programming and gatherings around the city. On a short trip, making the most of this concentration of people requires knowing which questions to bring.
In the content of that agents.md, I made it clear the extension should follow Chrome's Manifest V3 standard, be written in plain JavaScript, HTML and CSS, with no frameworks and no build process. I also made it explicit that it couldn't use AI or make any network calls: everything had to run fully offline, directly in the browser. The extension's only job is to calculate tokens, nothing more.
For this project, I swapped the default free model for a free DeepSeek model, which I found a bit faster for this kind of task.
After creating the folder and the file, I asked OpenCode to read the agents.md before anything else, just to confirm the instructions had been understood correctly. With that settled, it was time to plan.
Planning before coding
I switched to plan mode and pasted a prompt describing exactly what the extension should do: use Manifest V3, estimate the tokens and cost of a text selected on the page, with no AI and no network calls. The flow would be simple: you select some text on any page, click the extension's icon, and the popup instantly shows how many characters, words and estimated tokens that text represents.
Using plan mode before jumping into code is a step that makes a big difference. It seems like you'll spend more time and more tokens planning before coding, but in practice the opposite happens: with the plan ready, the development process goes a lot more smoothly, and the AI makes far fewer mistakes. That extra care pays off quickly.
With the plan defined, I went back to build mode and asked OpenCode to execute everything: create all the extension's files and also a test page, with a paragraph of exactly 3,500 characters generated by a script that repeats a sentence until it reaches that length. I also asked it to explain, at the end, how to load the extension in Chrome.
The result: comparing tokens across models
OpenCode generated everything on its own, including an estimate of how many characters equal one token. In a test with 599 words, the result came out to around 1,000 tokens, and that's where the interesting differences between models start: the same amount of text can represent almost twice as many tokens in one model and more than triple in another, depending on how each AI processes language. That comparison is exactly the point of the extension: to give you a clear idea of how much a prompt might cost before you decide where to send it.
Testing the extension in the browser
To test it, I went into Chrome settings, then Extensions, then Manage extensions. Anyone who's never used this feature first needs to enable Developer mode, it's what lets you load local extensions without publishing them to the Chrome store.
I clicked "Load unpacked" and selected the project folder. The extension showed up immediately, already with automatically generated icons. I went to the test page, selected the giant block of text created by the script, and clicked the extension's icon: the result showed around 1,000 tokens for that piece of text.
I also tested it with a shorter, more realistic prompt, the kind you'd normally write to ask for an extension to be built, in that case, the calculation came out to around 21 tokens. Of course, in practice, the actual token consumption during development is much higher, because the AI will generate code, review it, adjust it. But the point here is precisely to give you a sense of your prompt's weight beforehand, before you send it.
This is a simple extension: it runs a calculation based on public cost-per-token information for different models and returns an estimate. There's a lot of room to grow this project, for example, by calculating in real time as you type inside an AI chat, showing the accumulated cost so far. You could also add other models beyond the ones already configured, making the extension even more complete.
For anyone who wants to take this base and expand it, the suggestion stands: the code is open for any adjustment. It's an example of how a small, well-planned project can turn into a useful everyday tool for anyone working with AI who wants to keep control over what they're spending in tokens before even hitting send.
Column written by the editorial team based on Reinaldo Silotto's video on YouTube, with the author's permission.
Translated from the Brazilian Portuguese original · Read the original
VisionPsy2 runs sub-1B computer vision directly on phones, no cloud
Tether AI Research released VisionPsy2 on December 3, 2026, a family of vision-language models with fewer than 1 billion parameters that promises the quality of much larger models while running locally on smartphones.





