""" verify.py — the smallest possible proof that browser-use works end to end. It confirms three things are wired up correctly: 1. The browser launches and is driven by browser-use. 2. Your OpenAI key (from .env) reaches the LLM. 3. The agent can read a real page and report back. This does NOT log into anything or apply to any job — it's a hello-world. Run: source venv/bin/activate python verify.py """ import asyncio import os from dotenv import load_dotenv from browser_use import Agent, ChatOpenAI load_dotenv() # pulls OPENAI_API_KEY out of the .env file next to this script # HEADLESS=0 in the env -> you SEE a Chrome window open and the agent drive it. # Default here is headless (no window) so it runs cleanly in any terminal. HEADLESS = os.environ.get("HEADLESS", "1") != "0" async def main(): agent = Agent( task="Go to https://example.com and tell me the main heading (the big H1 text) on the page.", llm=ChatOpenAI(model="gpt-4o-mini"), # cheap model — this is just a smoke test ) history = await agent.run(max_steps=6) print("\n========== RESULT ==========") print(history.final_result()) print("============================") if __name__ == "__main__": asyncio.run(main())