import asyncio, time, sys, os, json from browser_use import Agent, ChatOpenAI, Browser async def main(): llm = ChatOpenAI(model=sys.argv[1], base_url="https://api.x.ai/v1", api_key=os.environ["XAI_API_KEY"], frequency_penalty=None) # xAI rejects frequency_penalty (Browser Use default 0.3) browser = Browser(executable_path="/usr/bin/google-chrome", headless=True) agent = Agent(task="Go to https://www.gov.uk/vat-rates and report the UK standard VAT rate and the reduced rate, exactly as stated on the page. Then finish.", llm=llm, browser=browser, use_vision=False) s=time.time(); h = await agent.run(max_steps=8) print("\n=====FINAL=====\n", h.final_result(), "\nSUCCESS:", h.is_successful(), "STEPS:", len(h.history), f"ELAPSED {time.time()-s:.1f}s") u=h.usage; print("USAGE", u.model_dump_json() if u else None) asyncio.run(main())