To track token usage and costs, enable cost calculation:
Copy
Ask AI
from browser_use import Agent, ChatBrowserUseagent = Agent( task="Search for latest news about AI", llm=ChatBrowserUse(), calculate_cost=True # Enable cost tracking)history = await agent.run()# Get usage from historyprint(f"Token usage: {history.usage}")# Or get from usage summaryusage_summary = await agent.token_cost_service.get_usage_summary()print(f"Usage summary: {usage_summary}")