Track Your API Limits in Real-Time with a Browser Extension

FreeGeminiTierAPI · Updated 2026-11-24 · 12 min read

Browser extension popup showing usage progress
A visual representation of your API usage within the extension popup.

Tracking API usage is essential when you are working with free tiers that have strict daily limits. Without a dashboard, it is easy to hit your quota unexpectedly, leaving your scripts or bots hanging mid-request. A custom browser extension solves this by giving you a persistent view of your consumption directly in your toolbar. This is particularly important for services like the free-ai model, which is not affiliated with Google, ensuring you know exactly who you are paying or relying on.

This guide walks you through building a lightweight extension that monitors your requests to the FreeGeminiTierAPI. You will learn how to track token counts, monitor reset cycles, and visualize your remaining quota without leaving your current tab. This approach works for any OpenAI-compatible endpoint, allowing you to maintain control over your workflow regardless of the provider. By intercepting network calls, you gain immediate insight into your consumption patterns.

Unlike third-party dashboards, a custom extension gives you full control over what data you collect and how it is displayed. You can set custom thresholds, trigger alerts before you hit the limit, and see exactly how much of your 10,000 daily requests you have used. This transparency helps you optimize your workflow and avoid wasted API calls during peak hours. For more on optimizing your setup, see Gemini API vs Google AI Studio: Which Fits Your Workflow? and Migrate Your Gemini CLI Skills to Antigravity.

Frequently asked questions

What is an API quota monitor?

An API quota monitor is a tool that tracks your usage of an API service. It counts requests and tokens, helping you stay within your daily or monthly limits. For free-tier services, this prevents unexpected cutoffs when you exceed your allocated resources. It provides real-time visibility into your consumption.

How does a browser extension monitor API calls?

A browser extension can intercept network requests made by your scripts or tools. By logging each request’s token count and status, it aggregates the data to show your total usage. This happens in real-time, giving you immediate feedback on your consumption without needing a separate dashboard or external service.

Which is better: manual tracking or an extension?

Manual tracking is error-prone and time-consuming. An extension automates the process, providing accurate counts and visual indicators. It reduces the cognitive load of remembering when your quota resets and ensures you do not waste requests on failed attempts. It also works seamlessly in the background.

What is the difference between request count and token count?

Request count measures how many times you call the API. Token count measures the volume of data processed. Both are important: requests are limited by per-second rates, while tokens are limited by daily quotas. An extension should track both to give a complete picture of your usage and prevent rate limiting.

How do I know when my quota resets?

Most free-tier APIs reset at a specific time, such as 00:00 UTC. Your extension can store the last reset time and calculate when the next one occurs. This allows you to plan your heavy usage around the reset window, ensuring you maximize your daily allowance without interruption.

Can I use this extension for multiple API providers?

Yes, if you design it to support multiple base URLs. You can configure the extension to track usage for different providers simultaneously. This is useful if you switch between free-tier models and paid services, keeping all your usage data in one place for easy comparison.

What are the benefits of using a custom extension?

Custom extensions are private, fast, and tailored to your needs. You do not rely on third-party services that might go offline or change their pricing. You control the data, the alerts, and the interface. This is especially important for developers who value privacy and reliability in their development workflow.

How does this relate to free-ai usage?

The free-ai model has specific limits, such as 10,000 requests per day. An extension can help you track these limits precisely. By monitoring your usage, you can avoid hitting the 429 rate limit or running out of tokens, ensuring your scripts run smoothly throughout the day.

Step by step

  1. Create Manifest — Define your extension’s permissions and background script in the manifest.json file. Ensure you include the necessary permissions for network requests and local storage to allow full monitoring capabilities.
  2. Write Background Script — Create a background script that intercepts API requests. Use the webRequest API to capture each request and extract the token count from the response, ensuring accurate tracking of all interactions.
  3. Build Popup UI — Design a popup interface that displays your usage statistics. Use a progress bar or pie chart to visualize your quota usage and remaining requests, making it easy to see your status at a glance.
  4. Implement Reset Logic — Add logic to reset your usage counts at 00:00 UTC. Store the last reset time and update your counts accordingly to ensure accurate tracking and prevent data accumulation across days.
  5. Test and Debug — Test your extension with various API requests. Use the browser’s developer tools to inspect logs and network requests, ensuring your token counting is accurate and your extension performs well under load.

Why Monitor API Usage?

API quotas are not just numbers; they dictate your workflow. When you are running automated scripts or interacting with a model in real-time, hitting a limit can break your application. A monitor gives you visibility into these limits, allowing you to adjust your behavior before a failure occurs. This is particularly important for free-tier services, which often have stricter limits than paid plans.

Without monitoring, you might waste requests on retries or failed attempts. By tracking your usage, you can identify patterns in your consumption and optimize your code. For example, you might discover that certain prompts consume more tokens than expected, allowing you to refine them. This optimization saves you requests and ensures you have enough quota for critical tasks. See Shard Memory vs Dumping Context in Gemini for more on managing context efficiently.

Preventing Unexpected Cutoffs

An unexpected cutoff can disrupt your workflow, especially if you are running long-running processes. A monitor alerts you before you hit the limit, giving you time to pause or switch to a different model. This proactive approach ensures continuity and reduces the risk of data loss or incomplete responses.

Optimizing Token Usage

Tokens are the currency of API usage. By tracking token consumption, you can identify inefficient prompts or redundant requests. This insight allows you to refine your inputs, reducing the number of tokens needed per response. Over time, this optimization can significantly extend your daily quota, allowing you to do more with less.

Understanding the free-ai Limits

The free-ai model, available via the FreeGeminiTierAPI, has specific limits that you need to track. It allows 10,000 requests or 10,000,000 tokens per day, resetting at 00:00 UTC. Each request leaves a technical log, which you can use to verify your usage. Understanding these limits is crucial for building an effective monitor. Note that this model is not affiliated with Google, so its limits are independent of Google’s infrastructure.

These limits are designed to prevent abuse while allowing reasonable usage. For developers, this means you need to be mindful of your request rate, which is capped at 1 request per second with bursts of 3. A monitor can help you stay within these bounds, ensuring you do not trigger a 429 error and lose valuable requests. You can also check Why Does My Free Gemini Quota Reset Every 46 Minutes? for insights on reset behaviors.

Request Rate Limits

The 1 request per second limit is strict. If you send too many requests too quickly, you will receive a 429 error. A monitor can track your request rate and alert you if you are approaching this limit, allowing you to pace your requests appropriately and avoid service interruptions.

Token Consumption

Tokens are consumed by both the input and the output. The free-ai model allows up to 16,000 tokens in the answer. By tracking token usage, you can ensure you do not exceed the 10,000,000 daily token limit. This is especially important for long conversations or large data processing tasks where token counts can accumulate rapidly.

Mobile API usage dashboard
Monitoring your API usage on a mobile device.

Building the Extension Structure

Building a browser extension requires a specific structure. You need a manifest file, a background script, and a popup interface. The manifest defines the extension’s permissions and behavior. The background script handles the logic for intercepting requests and tracking usage. The popup provides the user interface for displaying the data to the user.

This structure is modular, allowing you to easily update or extend the extension’s features. You can add new tracking metrics, change the UI, or integrate with other services. The key is to keep the code clean and well-documented, making it easy to maintain and debug. For more on coding tools, see Gemini CLI vs Claude Code: Which Wins for Devs?.

Manifest Configuration

The manifest file defines the extension’s permissions, such as access to the clipboard or network requests. It also specifies the version and the background script. This file is crucial for the extension to function correctly, as it tells the browser what resources the extension needs to operate effectively.

Background Script Logic

The background script is the heart of the extension. It listens for network requests, extracts token counts, and updates the usage statistics. This script runs in the background, continuously monitoring your API usage without interfering with your browsing experience or consuming significant system resources.

Intercepting API Requests

To monitor API usage, you need to intercept requests made to the API endpoint. This can be done using the browser’s webRequest API or by injecting a script into the page. The goal is to capture each request, extract the token count, and log it for later analysis. This ensures that every call is accounted for.

Intercepting requests allows you to track both successful and failed requests. This is important for calculating your true usage, as failed requests still consume tokens. By logging all requests, you get a complete picture of your consumption, helping you make more informed decisions about your API usage and resource allocation.

Using webRequest API

The webRequest API allows you to intercept requests at the network level. This is a powerful tool for monitoring API usage, as it captures all requests, regardless of how they are made. You can filter requests by URL, method, or status code, giving you fine-grained control over what is tracked and analyzed.

Injecting Page Scripts

Injecting a script into the page allows you to monitor requests made by JavaScript. This is useful for tracking usage in single-page applications or tools that make API calls directly from the browser. This method is less intrusive than using the webRequest API, but may require more setup to ensure accurate data capture.

Data center server racks
The backend infrastructure handling your API requests.

Tracking Tokens and Requests

Tracking tokens and requests requires parsing the API response. The response usually includes a field that indicates the number of tokens used. By extracting this value and adding it to your total, you can keep a running count of your usage. This count should be stored locally, so it persists across browser sessions and refreshes.

It is important to track both input and output tokens. Some APIs charge differently for each, so understanding the breakdown can help you optimize your usage. By tracking both, you get a complete picture of your consumption, allowing you to identify areas where you can save tokens and improve efficiency in your prompts.

Parsing Response Data

The API response typically includes a usage field that details the token count. You need to parse this field and extract the relevant values. This process requires understanding the API’s response format, which can vary between providers. Accurate parsing is essential for reliable tracking and avoiding data discrepancies.

Storing Usage Data

Usage data should be stored locally, using the browser’s storage API. This ensures that your usage statistics persist even if you close the browser. You can also use this data to display historical trends, helping you understand your usage patterns over time and adjust your strategy accordingly.

Visualizing Usage in the Popup

The popup interface is where you see your usage statistics. It should display your current request count, token usage, and remaining quota. This information should be easy to read and understand, allowing you to quickly assess your status without opening a separate dashboard or navigating away from your work.

A clear visual representation, such as a progress bar or a pie chart, can help you understand your usage at a glance. You can also add alerts or notifications to warn you when you are approaching your limit. This proactive approach ensures you do not hit your quota unexpectedly and can plan your usage accordingly.

Designing the Interface

The interface should be clean and uncluttered, displaying only the most important information. Use color coding to indicate your status, such as green for safe, yellow for caution, and red for near-limit. This visual cue allows you to quickly assess your situation without reading detailed numbers or performing calculations.

Adding Alerts and Notifications

Alerts can be triggered when you reach a certain threshold, such as 80% of your quota. These alerts can be visual, such as a badge on the extension icon, or auditory, such as a sound notification. This ensures you are aware of your usage even if you are not actively looking at the popup or your screen.

Hand-drawn API usage charts
Planning your API usage strategy with visual charts.

Handling Resets and Quotas

API quotas reset at a specific time, such as 00:00 UTC. Your extension needs to track this reset time and update your usage counts accordingly. This ensures that your usage statistics are accurate and reflect the current quota period. You can also use this reset time to plan your heavy usage and maximize your daily allowance.

Handling resets correctly is crucial for maintaining accurate usage data. If you do not reset your counts at the correct time, your usage statistics will be incorrect, leading to confusion and potential quota exhaustion. By automating this process, you ensure your data is always up-to-date and reliable for decision-making.

Calculating Reset Time

The reset time is usually fixed, such as midnight UTC. Your extension should calculate the time until the next reset and display this information to the user. This helps you plan your usage, ensuring you maximize your quota before it resets and avoid wasting requests in the final minutes of the day.

Updating Usage Counts

When the reset time is reached, your extension should reset the usage counts to zero. This ensures that your usage statistics reflect the new quota period. You can also log the reset event, providing a historical record of your usage cycles and helping you identify patterns over time.

Testing and Debugging

Testing your extension is crucial to ensure it works correctly. You should test it with different types of requests, such as short and long prompts, to verify that the token counting is accurate. You should also test the reset functionality to ensure your usage counts are updated correctly and your data remains consistent.

Debugging can be challenging, especially if you are new to browser extension development. Use the browser’s developer tools to inspect the extension’s console logs and network requests. This will help you identify any issues with your code and ensure your extension is functioning as expected. For more on debugging, see Is My Gemini CLI Broken or Just Updating?.

Running Unit Tests

Unit tests can help you verify the logic of your extension, such as the token counting algorithm. By writing tests for each function, you can ensure that your code behaves as expected. This is especially useful when adding new features or fixing bugs, as it prevents regression and ensures stability.

Using Developer Tools

The browser’s developer tools provide a wealth of information about your extension. You can inspect the console logs, network requests, and storage data. This allows you to debug issues quickly and efficiently, ensuring your extension is reliable and performant under various conditions and loads.

Laptop with API documentation tabs
Referencing API documentation while building your extension.
Try the free API

Test the keyless endpoint with a quick coding question to see the speed and quality firsthand.

Read also