mirror of
https://github.com/browser-use/browser-use
synced 2026-05-06 17:52:15 +02:00
FastAPI Browser Agent Example
This example demonstrates how to create a web interface for controlling a Browser Agent using FastAPI.
Requirements
uv pip install fastapi uvicorn sse-starlette langchain-openai
Running the Example
- Navigate to the fastapi example directory:
cd examples/fastapi
- Run the FastAPI application:
python main.py
- Open your web browser and navigate to
http://localhost:8000
API Endpoints
GET /- Serves the web interfacePOST /agent/run- Creates and runs an agent with the specified taskPOST /agent/pause- Pauses the current agentPOST /agent/resume- Resumes the paused agentPOST /agent/stop- Stops the current agentGET /agent/status- Gets the current status of the agentGET /logs- Server-sent events endpoint for real-time logs