Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
fixxxx
mertunsall5c370974d8e3
diff --git a/browser_use/llm/openai/chat.py b/browser_use/llm/openai/chat.pyindex 68ab2da47..e91b662c7 100644--- a/browser_use/llm/openai/chat.py+++ b/browser_use/llm/openai/chat.py@@ -96,12 +96,15 @@ class ChatOpenAI(BaseChatModel):return str(self.model)def _get_usage(self, response: ChatCompletion) -> ChatInvokeUsage | None:- completion_tokens = response.usage.completion_tokens- if response.usage.completion_tokens_details is not None:- completion_tokens += response.usage.completion_tokens_details.reasoning_tokens-- usage = (- ChatInvokeUsage(+ if response.usage is not None:+ completion_tokens = response.usage.completion_tokens+ completion_token_details = response.usage.completion_tokens_details+ if completion_token_details is not None:+ reasoning_tokens = completion_token_details.reasoning_tokens+ if reasoning_tokens is not None:+ completion_tokens += reasoning_tokens++ usage = ChatInvokeUsage(prompt_tokens=response.usage.prompt_tokens,prompt_cached_tokens=response.usage.prompt_tokens_details.cached_tokensif response.usage.prompt_tokens_details is not None@@ -109,15 +112,11 @@ class ChatOpenAI(BaseChatModel):prompt_cache_creation_tokens=None,prompt_image_tokens=None,# Completion- completion_tokens=response.usage.completion_tokens- + (response.usage.completion_tokens_details.reasoning_tokens or 0),+ completion_tokens=completion_tokens,total_tokens=response.usage.total_tokens,)- if response.usage is not None- else None- )- if response.usage is not None and response.usage.completion_tokens_details is not None:- usage.completion_tokens += response.usage.completion_tokens_details.reasoning_tokens or 0+ else:+ usage = Nonereturn usage