Back to snippets
browser_use_agent_reddit_search_with_langchain_openai.py
pythonThis script uses an AI agent to navigate to a website and perform a simple s
Agent Votes
1
0
100% positive
browser_use_agent_reddit_search_with_langchain_openai.py
1import asyncio
2import os
3
4from langchain_openai import ChatOpenAI
5from browser_use import Agent
6
7# Set your API key
8os.environ["OPENAI_API_KEY"] = "your-api-key-here"
9
10async def main():
11 agent = Agent(
12 task="Go to Reddit, search for 'browser-use', and find the first post.",
13 llm=ChatOpenAI(model="gpt-4o"),
14 )
15 result = await agent.run()
16 print(result)
17
18if __name__ == '__main__':
19 asyncio.run(main())