# Debug Pricing

## Understanding How the Debug Agent Works

The [**Debug Agent** ](https://docs.emobiq.com/emobiq-ai/readme/debug-agent)is an AI-powered tool designed to help you identify and fix issues in your app quickly and efficiently. It allows you to:

* Inspect HTML, JavaScript, and API logic
* Identify bugs or misconfigurations
* Apply temporary or permanent fixes directly within the code using natural language
* Test changes in real time

When you interact with the Debug Agent, it processes your request and does it's best to complete your request.

{% hint style="info" %}
*Do note that AI still makes mistakes and it might take a few prompts to fix the issue. For more information on prompting you can refer to the* [*Debug Agent page*](https://docs.emobiq.com/emobiq-ai/readme/debug-agent)
{% endhint %}

***

### How Is Usage Measured?

Each interaction with the Debug Agent consumes **tokens**, which represent the amount of data processed with each prompt.

#### Example Session:

12 Tokens: 40866 (prompt: 39415, completion: 1451) **Cost: 0.41** **Credits**

This means that during this debug session:

* The user provided a **prompt** of \~39,415 tokens (describing the issue and providing context)
* The agent generated a **response** of \~1,451 tokens (proposing or applying a fix)
* Total cost is calculated based on these tokens processed

{% hint style="info" %}
***Note:** Token usage depends on how much content is sent and generated during the session — including source code, error messages, and explanations.*
{% endhint %}

***

### Why Is There A Charge?

You are charged credits based on **token usage** during each debug session. Here's why:

* **AI processing requires resources**: Each debug task involves analysing code, understanding context, and generating accurate responses
* **Token-based billing ensures fairness**: You only pay for what you use — not for idle time or fixed hours
* **Efficient sessions = lower costs**: The more specific and clear your prompt, the fewer tokens needed to resolve the issue

You're not charged for:

* Previewing changes in UI-only mode
* Viewing documentation or sample guides
* Running tests that don’t involve AI reasoning

***

### Real-World Debugging Example

#### Issue:

After reviewing `service_orders.html` and `service_order_details.html`, the Debug Agent identified that the service order details page was failing due to an authentication error when making an API call.

#### Fix Applied:

The Debug Agent made the following corrections in `service_order_details.html`:

* Fixed incorrect usage of `btoa()` in the `getAuthToken()` function
* Updated the request body format from JSON object to URL-encoded form data
* Standardised the `Authorization` header capitalisation

These changes resolved the authentication failure and allowed the page to load correctly.

#### Result:

* Service order details now display properly
* User redirected correctly instead of being sent back to the main menu
* API calls now authenticate successfully
