π Call web agent through APIs!
A very simple web agent server using excellent Browser-use tool.
- π Integrate into any app with our API
- π Multiple LLM compatibility
- π Host on your infrastructure
- π½ Store and retrieve results in database
- πͺ Get notified of results with webhooks
- Make sure you have Python 3.12+ installed.
- Install the dependencies:
pip install -r requirements.txt
- Configure your
.env
file with the necessary environment variables (API keys, etc.) Add your API keys for the provider you want to use to your .env file.
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
AZURE_ENDPOINT=
AZURE_OPENAI_API_KEY=
GEMINI_API_KEY=
DEEPSEEK_API_KEY=
GROK_API_KEY=
NOVITA_API_KEY=
- Build the Docker image:
docker build -t webagent .
- Run the container:
docker run -p 8080:8080 --env-file .env webagent
The Docker image includes all necessary dependencies, including Playwright for browser automation.
-
Configure your environment variables in the
docker-compose.yml
file or in a.env
file. -
Start the service:
docker-compose up
python server.py
# Using Docker
docker run -p 8080:8080 --env-file .env webagent
# Using Docker Compose
docker-compose up
The server will start at http://localhost:8080
Once the server is started, you can access the interactive API documentation at:
- http://localhost:8080/docs (Swagger UI)
- http://localhost:8080/redoc (ReDoc)
Endpoint: POST /run
Request body:
{
"task": "go to this site https://example.com and retrieve the page title",
"provider": "openai",
"model": "gpt-4o"
}
Response:
{
"history": [
{
"is_done": true,
"success": true,
"extracted_content": "Example Domain",
"error": null,
"include_in_memory": false
}
],
"result": "Example Domain",
"is_done": true,
"is_successful": true,
"status": "success",
"screenshots": [
"data:image/png;base64,..."
]
}
# Execute a task
curl -X 'POST' \
'http://localhost:8080/run' \
-H 'Content-Type: application/json' \
-d '{
"task": "go to this site https://example.com and retrieve the page title",
"model": "gpt-4o",
"provider": "openai"
}'
import requests
# Base URL of the API
base_url = "http://localhost:8080"
# Execute a task
response = requests.post(
f"{base_url}/run",
json={
"task": "go to this site https://example.com and retrieve the page title",
"model": "gpt-4o",
"provider": "openai"
}
)
# Print the response
print(f"Response: {response.json()}")