mirror of
https://github.com/browser-use/browser-use
synced 2026-05-06 17:52:15 +02:00
30 lines
641 B
Plaintext
30 lines
641 B
Plaintext
---
|
|
title: "Costs"
|
|
description: "Track token usage and API costs for your browser automation tasks"
|
|
icon: "dollar-sign"
|
|
mode: "wide"
|
|
---
|
|
|
|
## Cost Tracking
|
|
|
|
To track token usage and costs, enable cost calculation:
|
|
|
|
```python
|
|
from browser_use import Agent, ChatBrowserUse
|
|
|
|
agent = Agent(
|
|
task="Search for latest news about AI",
|
|
llm=ChatBrowserUse(),
|
|
calculate_cost=True # Enable cost tracking
|
|
)
|
|
|
|
history = await agent.run()
|
|
|
|
# Get usage from history
|
|
print(f"Token usage: {history.usage}")
|
|
|
|
# Or get from usage summary
|
|
usage_summary = await agent.token_cost_service.get_usage_summary()
|
|
print(f"Usage summary: {usage_summary}")
|
|
```
|