### Start Bytebot Docker Compose Services
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/quickstart.mdx
This command initiates the Bytebot agent stack using Docker Compose. It brings up four essential services: Bytebot Desktop, AI Agent, Chat UI, and Database. Ensure Docker and Docker Compose are installed and the .env file is configured.
```bash
docker-compose -f docker/docker-compose.yml up -d
```
--------------------------------
### Direct Desktop Control via Bytebot API
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/quickstart.mdx
Examples of controlling the desktop environment directly using the Bytebot Desktop API via cURL. Shows how to take a screenshot and type text into the desktop interface.
```bash
# Take a screenshot
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "screenshot"}'
# Type text
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "type_text", "text": "Hello, Bytebot!"}'
```
--------------------------------
### Create Tasks via Bytebot Agent API
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/quickstart.mdx
Examples of creating tasks programmatically using the Bytebot Agent API via cURL. Demonstrates creating a simple task with a description and priority, and a task that includes file upload.
```bash
# Simple task
curl -X POST http://localhost:9991/tasks \
-H "Content-Type: application/json" \
-d '{
"description": "Search for flights from NYC to London next month",
"priority": "MEDIUM"
}'
# Task with file upload
curl -X POST http://localhost:9991/tasks \
-F "description=Read this contract and summarize the key terms" \
-F "priority=HIGH" \
-F "files=@contract.pdf"
```
--------------------------------
### Deploy Bytebot with Docker Compose
Source: https://context7.com/bytebot-ai/bytebot/llms.txt
Quick start guide to deploy Bytebot using Docker Compose. This involves cloning the repository, configuring API keys in a .env file, and starting the agent stack. It outlines the access URLs for the UI, Agent API, and Desktop API.
```bash
# Clone and configure
git clone https://github.com/bytebot-ai/bytebot.git
cd bytebot
# Configure your AI provider (choose one)
echo "ANTHROPIC_API_KEY=sk-ant-your-key-here" > docker/.env
# Or: echo "OPENAI_API_KEY=sk-your-key-here" > docker/.env
# Or: echo "GEMINI_API_KEY=your-key-here" > docker/.env
# Start the agent stack
docker-compose -f docker/docker-compose.yml up -d
# Access the UI at http://localhost:9992
# Agent API at http://localhost:9991
# Desktop API at http://localhost:9990
```
--------------------------------
### POST /computer-use - Open Application and Navigate
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/rest-api/examples.mdx
Examples demonstrating how to open applications, navigate web pages, and interact with the computer using cURL.
```APIDOC
## POST /computer-use
### Description
This endpoint allows for various computer automation actions, including mouse movements, clicks, typing text, and pressing keys.
### Method
POST
### Endpoint
http://localhost:9990/computer-use
### Parameters
#### Request Body
- **action** (string) - Required - The action to perform (e.g., "move_mouse", "click_mouse", "type_text", "press_keys", "wait", "screenshot").
- **coordinates** (object) - Optional - Used with "move_mouse" to specify x and y coordinates.
- **x** (integer) - Required - The x-coordinate.
- **y** (integer) - Required - The y-coordinate.
- **button** (string) - Optional - Used with "click_mouse" to specify the mouse button (e.g., "left").
- **clickCount** (integer) - Optional - Used with "click_mouse" to specify the number of clicks.
- **duration** (integer) - Optional - Used with "wait" to specify the duration in milliseconds.
- **text** (string) - Optional - Used with "type_text" to specify the text to type.
- **keys** (array of strings) - Optional - Used with "type_keys" or "press_keys" to specify the keys to press (e.g., ["enter"], ["ctrl", "c"]).
- **press** (string) - Optional - Used with "press_keys" to specify the key press state ("down" or "up").
### Request Example
```json
{
"action": "move_mouse",
"coordinates": {
"x": 100,
"y": 950
}
}
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
- **data** (object) - Contains additional data, such as image data for screenshots.
- **image** (string) - Base64 encoded image data for "screenshot" action.
#### Response Example
```json
{
"status": "success",
"data": {}
}
```
```
--------------------------------
### Usage Examples API
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/rest-api/introduction.mdx
Provides code examples and snippets for common automation scenarios.
```APIDOC
## Usage Examples API
### Description
This endpoint provides access to code examples and snippets for various automation scenarios using the Bytebot API.
### Method
GET
### Endpoint
`/examples`
### Parameters
#### Query Parameters
- **scenario** (string) - Optional - Filters examples for a specific automation scenario.
### Response
#### Success Response (200)
- **success** (boolean) - Indicates if the examples were retrieved successfully.
- **data** (array) - A list of code examples, each with details like language, description, and the code snippet.
#### Response Example
```json
{
"success": true,
"data": [
{
"language": "python",
"description": "Example of taking a screenshot.",
"code": "import requests\nresponse = requests.post('http://localhost:9990/computer-use', json={'action': 'screenshot'})\nprint(response.json())"
}
],
"error": null
}
```
```
--------------------------------
### POST /computer-use - Take and Save Screenshot
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/rest-api/examples.mdx
Example demonstrating how to take a screenshot and save it to a file using cURL and jq.
```APIDOC
## POST /computer-use (Screenshot)
### Description
This example shows how to capture a screenshot of the computer screen and save the image data to a file using cURL and the `jq` utility.
### Method
POST
### Endpoint
http://localhost:9990/computer-use
### Parameters
#### Request Body
- **action** (string) - Required - Must be "screenshot".
### Request Example
```bash
curl -s -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "screenshot"}'
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
- **data** (object) - Contains the screenshot data.
- **image** (string) - Base64 encoded string of the screenshot image.
#### Response Example
```json
{
"status": "success",
"data": {
"image": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="
}
}
```
### Usage Notes
After receiving the response, you can use `jq` and `base64` to decode and save the image:
```bash
echo $response | jq -r '.data.image' | base64 -d > screenshot.png
echo "Screenshot saved to screenshot.png"
```
```
--------------------------------
### Troubleshoot Container Startup Issues
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/quickstart.mdx
Steps to troubleshoot issues when Docker containers won't start. This involves checking if Docker is running and examining the Docker Compose logs for error messages.
```bash
docker info
docker-compose -f docker/docker-compose.yml logs
```
--------------------------------
### Code Examples
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/rest-api/computer-use.mdx
Provides example implementations for interacting with the API using cURL, Python, and JavaScript.
```APIDOC
## Code Examples
### cURL
```bash
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "move_mouse", "coordinates": {"x": 100, "y": 200}}'
```
### Python
```python
import requests
def control_computer(action, **params):
url = "http://localhost:9990/computer-use"
data = {"action": action, **params}
response = requests.post(url, json=data)
return response.json()
# Move the mouse example
result = control_computer("move_mouse", coordinates={"x": 100, "y": 100})
print(result)
```
### JavaScript
```javascript
const axios = require("axios");
async function controlComputer(action, params = {}) {
const url = "http://localhost:9990/computer-use";
const data = { action, ...params };
const response = await axios.post(url, data);
return response.data;
}
// Move mouse example
controlComputer("move_mouse", { coordinates: { x: 100, y: 100 } })
.then((result) => console.log(result))
.catch((error) => console.error("Error:", error));
```
```
--------------------------------
### POST /computer-use - Basic Automation Examples
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/api-reference/computer-use/examples.mdx
Demonstrates how to perform basic computer automation tasks such as moving the mouse, clicking, typing text, and executing keyboard shortcuts using cURL and Python.
```APIDOC
## POST /computer-use
### Description
This endpoint allows for various computer automation actions, including mouse control, keyboard input, and browser interactions.
### Method
POST
### Endpoint
http://localhost:9990/computer-use
### Parameters
#### Request Body
- **action** (string) - Required - The action to perform (e.g., "move_mouse", "click_mouse", "type_text", "press_keys").
- **coordinates** (object) - Optional - Used with "move_mouse" action. Contains 'x' and 'y' coordinates.
- **x** (integer) - Required - The x-coordinate.
- **y** (integer) - Required - The y-coordinate.
- **button** (string) - Optional - Used with "click_mouse" action. The mouse button to click (e.g., "left", "right").
- **clickCount** (integer) - Optional - Used with "click_mouse" action. The number of clicks.
- **text** (string) - Optional - Used with "type_text" action. The text to type.
- **delay** (integer) - Optional - Used with "type_text" action. Delay in milliseconds between typing characters.
- **key** (string) - Optional - Used with "press_keys" action. The key to press (e.g., "s", "enter", "tab").
- **modifiers** (array of strings) - Optional - Used with "press_keys" action. Keyboard modifiers to hold (e.g., ["control"], ["shift", "alt"]).
### Request Example (cURL - Moving Mouse)
```bash
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "move_mouse", "coordinates": {"x": 100, "y": 960}}'
```
### Request Example (Python - Moving Mouse)
```python
import requests
def control_computer(action, **params):
url = "http://localhost:9990/computer-use"
data = {"action": action, **params}
response = requests.post(url, json=data)
return response.json()
control_computer("move_mouse", coordinates={"x": 100, "y": 960})
```
### Response
#### Success Response (200)
- **success** (boolean) - Indicates if the action was successful.
- **message** (string) - A message describing the result of the action.
- **data** (object) - Contains additional data related to the action (e.g., image data for screenshots).
#### Response Example
```json
{
"success": true,
"message": "Mouse moved successfully.",
"data": {}
}
```
```
--------------------------------
### Helm Deployment for Bytebot on Kubernetes
Source: https://context7.com/bytebot-ai/bytebot/llms.txt
These bash commands demonstrate how to deploy Bytebot on Kubernetes using Helm charts. It covers cloning the repository, basic installation, installation with custom values, and using a values file for configuration.
```bash
# Clone the repository
git clone https://github.com/bytebot-ai/bytebot.git
cd bytebot
# Install with Helm (basic)
helm install bytebot ./helm \
--set agent.env.ANTHROPIC_API_KEY=sk-ant-your-key-here
# Install with custom values
helm install bytebot ./helm \
--set agent.env.ANTHROPIC_API_KEY=sk-ant-your-key-here \
--set agent.env.ANTHROPIC_MODEL=claude-3-5-sonnet-20241022 \
--set bytebot-ui.ingress.enabled=true \
--set bytebot-ui.ingress.hosts[0].host=bytebot.example.com
# Using values file
cat > my-values.yaml << EOF
agent:
env:
ANTHROPIC_API_KEY: sk-ant-your-key-here
bytebot-ui:
ingress:
enabled: true
hosts:
- host: bytebot.example.com
paths:
- path: /
pathType: Prefix
EOF
helm install bytebot ./helm -f my-values.yaml
```
--------------------------------
### Configure Bytebot API Keys (Full Example)
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/deployment/helm.mdx
Provides a comprehensive example of configuring API keys for multiple AI providers (Anthropic, OpenAI, Gemini) in the `values.yaml` file.
```yaml
bytebot-agent:
apiKeys:
anthropic:
value: "sk-ant-your-key-here"
openai:
value: "sk-your-key-here"
gemini:
value: "your-key-here"
```
--------------------------------
### Desktop API - Control Computer
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/quickstart.mdx
Interact with the desktop environment programmatically using the low-level Desktop API.
```APIDOC
## POST /computer-use
### Description
Executes actions on the computer, such as taking screenshots or typing text.
### Method
POST
### Endpoint
http://localhost:9990/computer-use
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **action** (string) - Required - The action to perform (e.g., "screenshot", "type_text").
- **text** (string) - Optional - The text to type if the action is "type_text".
### Request Example
**Take Screenshot:**
```bash
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "screenshot"}'
```
**Type Text:**
```bash
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "type_text", "text": "Hello, Bytebot!"}'
```
### Response
#### Success Response (200)
- **status** (string) - The status of the action (e.g., "success").
- **message** (string) - A message providing details about the action's outcome.
#### Response Example
```json
{
"status": "success",
"message": "Screenshot saved to /path/to/screenshot.png"
}
```
```
--------------------------------
### Write Files with JavaScript/Node.js
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/api-reference/computer-use/examples.mdx
Shows how to write files to the computer using Node.js and the Bytebot API. This example utilizes the 'axios' library and base64 encoding for file content. It supports writing to absolute paths or creating files on the desktop.
```javascript
const axios = require('axios');
async function writeFile(path, content) {
const url = "http://localhost:9990/computer-use";
// Encode content to base64
const encodedContent = Buffer.from(content, 'utf-8').toString('base64');
const data = {
action: "write_file",
path: path,
data: encodedContent
};
const response = await axios.post(url, data);
return response.data;
}
// Write a text file
writeFile("/home/user/notes.txt", "Meeting notes...")
.then(result => console.log(result))
.catch(error => console.error(error));
// Write HTML file to desktop
const htmlContent = '
Hello
';
writeFile("index.html", htmlContent)
.then(result => console.log("HTML file created"));
```
--------------------------------
### Move Mouse Action - cURL Example
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/rest-api/computer-use.mdx
Example using cURL to send a POST request to the computer-use endpoint to move the mouse to specific coordinates.
```bash
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "move_mouse", "coordinates": {"x": 100, "y": 200}}'
```
--------------------------------
### Install Bytebot Helm Chart
Source: https://github.com/bytebot-ai/bytebot/blob/main/helm/README.md
This snippet demonstrates the commands to clone the Bytebot repository, create a values.yaml file with API keys, install the Helm chart, and set up port forwarding to access the Bytebot UI.
```bash
# Clone repository
git clone https://github.com/bytebot-ai/bytebot.git
cd bytebot
# Create values.yaml with your API key(s)
cat > values.yaml < screenshot.png
```
```bash
# Type text in a text editor
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "type_text", "text": "Hello, this is an automated test!", "delay": 30}'
# Press Ctrl+S to save
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "press_keys", "key": "s", "modifiers": ["control"]}'
```
--------------------------------
### Troubleshoot Bytebot Pods Not Starting
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/deployment/helm.mdx
Provides commands to diagnose issues when Bytebot pods fail to start. Includes checking pod descriptions for errors and verifying node resources.
```bash
kubectl describe pod -n bytebot
kubectl top nodes
```
--------------------------------
### Compare Screenshots with JavaScript/Node.js
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/api-reference/computer-use/examples.mdx
Captures two screenshots of the computer screen and saves them for comparison. This example uses Node.js, 'axios', 'fs', 'canvas', and 'pixelmatch'. It demonstrates taking screenshots and preparing them for visual diffing.
```javascript
const axios = require('axios');
const fs = require('fs');
const { createCanvas, loadImage } = require('canvas');
const pixelmatch = require('pixelmatch');
async function controlComputer(action, params = {}) {
const url = "http://localhost:9990/computer-use";
const data = { action, ...params };
try {
const response = await axios.post(url, data);
return response.data;
} catch (error) {
console.error('Error:', error.message);
return { success: false, error: error.message };
}
}
async function compareScreenshots() {
try {
// Take first screenshot
const screenshot1 = await controlComputer("screenshot");
// Do some actions
await controlComputer("move_mouse", { coordinates: { x: 500, y: 500 } });
await controlComputer("click_mouse", { button: "left" });
await controlComputer("wait", { duration: 1000 });
// Take second screenshot
const screenshot2 = await controlComputer("screenshot");
// Compare screenshots
if (screenshot1.success && screenshot2.success) {
const img1Data = Buffer.from(screenshot1.data.image, 'base64');
const img2Data = Buffer.from(screenshot2.data.image, 'base64');
fs.writeFileSync('screenshot1.png', img1Data);
fs.writeFileSync('screenshot2.png', img2Data);
// Now you could load and compare these images
// This requires additional image comparison libraries
console.log('Screenshots saved for comparison');
}
} catch (error) {
console.error("Screenshot comparison failed:", error);
}
}
compareScreenshots();
```
--------------------------------
### Python - Web Form Automation
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/rest-api/examples.mdx
Python example demonstrating how to automate filling web forms using the Bytebot REST API.
```APIDOC
## Python - Web Form Automation
### Description
This Python script utilizes the `requests` library to interact with the Bytebot REST API for automating web form submissions. It includes functions to control the computer and a specific example for filling out a login form.
### Method
POST
### Endpoint
http://localhost:9990/computer-use
### Parameters
#### Request Body (for `control_computer` function)
- **action** (string) - Required - The action to perform (e.g., "move_mouse", "click_mouse", "type_text", "type_keys", "wait").
- **params** (object) - Optional - Additional parameters specific to the action (e.g., `coordinates`, `button`, `clickCount`, `text`, `keys`, `duration`).
### Request Example (Python Script)
```python
import requests
import time
def control_computer(action, **params):
url = "http://localhost:9990/computer-use"
data = {"action": action, **params}
response = requests.post(url, json=data)
return response.json()
def fill_web_form(): # Navigate to a form (e.g., login form)
# Move mouse and click to focus on the username field
control_computer("move_mouse", coordinates={"x": 500, "y": 300})
control_computer("click_mouse", button="left")
# Type username
control_computer("type_text", text="user@example.com")
# Tab to password field
control_computer("type_keys", keys=["tab"])
# Type password
control_computer("type_text", text="secure_password")
# Tab to login button
control_computer("type_keys", keys=["tab"])
# Press Enter to submit
control_computer("type_keys", keys=["enter"])
# Wait for page to load
control_computer("wait", duration=2000)
print("Form submitted successfully")
# Example usage:
# fill_web_form()
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
- **data** (object) - Contains additional data, if any.
#### Response Example
```json
{
"status": "success",
"data": {}
}
```
```
--------------------------------
### Form Filling Workflow (JavaScript)
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/rest-api/examples.mdx
This JavaScript example demonstrates a form-filling workflow using the `axios` library for HTTP requests. It navigates to a form page, fills in text fields using mouse movements and typing, and submits the form. It also captures a screenshot of the confirmation page.
```javascript
const axios = require("axios");
async function controlComputer(action, params = {}) {
const url = "http://localhost:9990/computer-use";
const data = { action, ...params };
const response = await axios.post(url, data);
return response.data;
}
async function fillForm() {
// Navigate to form page
await controlComputer("move_mouse", { coordinates: { x: 100, y: 960 } });
await controlComputer("click_mouse", { button: "left" });
await controlComputer("wait", { duration: 3000 });
await controlComputer("type_text", { text: "https://example.com/form" });
await controlComputer("press_keys", { key: "enter" });
await controlComputer("wait", { duration: 2000 });
// Fill form
// Name field
await controlComputer("move_mouse", { coordinates: { x: 400, y: 250 } });
await controlComputer("click_mouse", { button: "left" });
// Type the value
await controlComputer("type_text", { text: "John Doe" });
// Email field (tab to next field)
await controlComputer("press_keys", { keys: ["tab"], press: "down" });
await controlComputer("press_keys", { keys: ["tab"], press: "up" });
await controlComputer("type_text", { text: "john@example.com" });
// Message field (tab to next field)
await controlComputer("press_keys", { keys: ["tab"], press: "down" });
await controlComputer("press_keys", { keys: ["tab"], press: "up" });
await controlComputer("type_text", {
text: "This is an automated message sent using Bytebot's Computer Use API",
delay: 30,
});
// Submit form
await controlComputer("press_keys", { keys: ["tab"], press: "down" });
await controlComputer("press_keys", { keys: ["tab"], press: "up" });
await controlComputer("press_keys", { key: "enter" });
// Take screenshot of confirmation page
await controlComputer("wait", { duration: 2000 });
const screenshot = await controlComputer("screenshot");
console.log("Form submitted successfully");
}
fillForm().catch(console.error);
```
--------------------------------
### Enable LiteLLM Proxy for Multi-Provider Support (Bash)
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/quickstart.mdx
Deploy the LiteLLM proxy using Docker Compose to enable the use of multiple LLM providers simultaneously. This command starts the proxy in detached mode.
```bash
# To use multiple LLM providers, use the proxy setup:
docker-compose -f docker/docker-compose.proxy.yml up -d
# This includes a pre-configured LiteLLM proxy
```
--------------------------------
### Control Computer Function - JavaScript Example
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/rest-api/computer-use.mdx
An asynchronous JavaScript function using 'axios' to control computer actions via the API. It includes an example of moving the mouse and handling potential errors.
```javascript
const axios = require("axios");
async function controlComputer(action, params = {}) {
const url = "http://localhost:9990/computer-use";
const data = { action, ...params };
const response = await axios.post(url, data);
return response.data;
}
// Move mouse example
controlComputer("move_mouse", { coordinates: { x: 100, y: 100 } })
.then((result) => console.log(result))
.catch((error) => console.error("Error:", error));
```
--------------------------------
### Start Bytebot with LiteLLM Proxy using Docker Compose
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/deployment/litellm.mdx
This snippet demonstrates how to clone the Bytebot repository, set up API keys in a .env file, and start Bytebot with its built-in LiteLLM proxy enabled using Docker Compose. It configures the proxy service to run on port 4000 and sets the agent to use this proxy.
```bash
git clone https://github.com/bytebot-ai/bytebot.git
cd bytebot
cat > docker/.env << EOF
# Add any combination of these keys
ANTHROPIC_API_KEY=sk-ant-your-key-here
OPENAI_API_KEY=sk-your-key-here
GEMINI_API_KEY=your-key-here
EOF
docker-compose -f docker/docker-compose.proxy.yml up -d
```
--------------------------------
### Agent API - Create Task
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/quickstart.mdx
Programmatically create tasks for the Bytebot agent via the REST API. Supports simple descriptions and file uploads.
```APIDOC
## POST /tasks
### Description
Creates a new task for the Bytebot agent.
### Method
POST
### Endpoint
http://localhost:9991/tasks
### Parameters
#### Query Parameters
None
#### Request Body
**Option 1: Simple Task**
- **description** (string) - Required - A description of the task to be performed.
- **priority** (string) - Optional - The priority of the task (e.g., "MEDIUM", "HIGH").
**Option 2: Task with File Upload**
- **description** (string) - Required - A description of the task.
- **priority** (string) - Optional - The priority of the task.
- **files** (file) - Optional - Files to be processed by the task (e.g., a contract PDF).
### Request Example
**Simple Task:**
```bash
curl -X POST http://localhost:9991/tasks \
-H "Content-Type: application/json" \
-d '{ "description": "Search for flights from NYC to London next month", "priority": "MEDIUM" }'
```
**Task with File Upload:**
```bash
curl -X POST http://localhost:9991/tasks \
-F "description=Read this contract and summarize the key terms" \
-F "priority=HIGH" \
-F "files=@contract.pdf"
```
### Response
#### Success Response (200)
- **taskId** (string) - The unique identifier for the created task.
#### Response Example
```json
{
"taskId": "task_abc123"
}
```
```
--------------------------------
### POST /computer-use - Screenshot and Analysis
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/api-reference/computer-use/examples.mdx
Shows how to capture a screenshot of the computer screen and save it, as well as process the image data using Python libraries.
```APIDOC
## POST /computer-use - Screenshot
### Description
This endpoint captures a screenshot of the current screen and returns the image data, typically in base64 format. It also includes examples of how to process this image data using Python.
### Method
POST
### Endpoint
http://localhost:9990/computer-use
### Parameters
#### Request Body
- **action** (string) - Required - Must be set to "screenshot".
### Request Example (cURL)
```bash
# Take a screenshot
response=$(curl -s -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "screenshot"}')
# Extract the base64 image data and save to a file
echo $response | jq -r '.data.image' | base64 -d > screenshot.png
```
### Request Example (Python)
```python
import requests
import json
import base64
import cv2
import numpy as np
from PIL import Image
from io import BytesIO
def take_screenshot():
url = "http://localhost:9990/computer-use"
data = {"action": "screenshot"}
response = requests.post(url, json=data)
if response.json()["success"]:
img_data = base64.b64decode(response.json()["data"]["image"])
image = Image.open(BytesIO(img_data))
return np.array(image)
return None
# Take a screenshot
img = take_screenshot()
# Convert to grayscale for analysis
if img is not None:
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Save the screenshot
cv2.imwrite("screenshot.png", img)
# Perform image analysis (example: find edges)
edges = cv2.Canny(gray, 100, 200)
cv2.imwrite("edges.png", edges)
```
### Response
#### Success Response (200)
- **success** (boolean) - Indicates if the screenshot was captured successfully.
- **message** (string) - A message describing the result.
- **data** (object) - Contains the screenshot image data.
- **image** (string) - Base64 encoded string of the screenshot image.
#### Response Example
```json
{
"success": true,
"message": "Screenshot captured successfully.",
"data": {
"image": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="
}
}
```
```
--------------------------------
### Automate Form Filling using JavaScript
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/api-reference/computer-use/examples.mdx
This JavaScript example demonstrates automating form submissions in a web application. It uses the Computer Use API to simulate mouse movements, typing text, and pressing keys to navigate and submit form fields. Requires a local server on port 9990.
```javascript
const axios = require("axios");
async function controlComputer(action, params = {}) {
const url = "http://localhost:9990/computer-use";
const data = { action, ...params };
const response = await axios.post(url, data);
return response.data;
}
async function fillForm() {
// Click first input field
await controlComputer("move_mouse", { coordinates: { x: 400, y: 300 } });
await controlComputer("click_mouse", { button: "left" });
// Type name
await controlComputer("type_text", { text: "John Doe" });
// Tab to next field
await controlComputer("press_keys", { key: "tab" });
// Type email
await controlComputer("type_text", { text: "john@example.com" });
// Tab to next field
await controlComputer("press_keys", { key: "tab" });
// Type message
await controlComputer("type_text", {
text: "This is an automated message sent using Bytebot's Computer Use API",
delay: 30,
});
// Tab to submit button
await controlComputer("press_keys", { key: "tab" });
// Press Enter to submit
await controlComputer("press_keys", { key: "enter" });
}
fillForm().catch(console.error);
```
--------------------------------
### POST /computer-use - Browser Automation
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/api-reference/computer-use/examples.mdx
Provides actions to automate browser interactions, such as opening URLs, typing text, and taking screenshots.
```APIDOC
## POST /computer-use
### Description
Automates various computer actions, including browser control, mouse movements, and keyboard input.
### Method
POST
### Endpoint
`/computer-use`
### Parameters
#### Request Body
- **action** (string) - Required - The action to perform (e.g., `"move_mouse"`, `"click_mouse"`, `"type_text"`, `"press_keys"`, `"screenshot"`, `"scroll"`).
- **coordinates** (object) - Optional - Used with `"move_mouse"`. Contains `x` and `y` integer coordinates.
- **button** (string) - Optional - Used with `"click_mouse"`. Specifies the mouse button (e.g., `"left"`, `"right"`).
- **text** (string) - Optional - Used with `"type_text"`. The text to type.
- **delay** (integer) - Optional - Used with `"type_text"`. Delay in milliseconds between typing characters.
- **key** (string) - Optional - Used with `"press_keys"`. The key to press (e.g., `"enter"`, `"tab"`, `"escape"`).
- **direction** (string) - Optional - Used with `"scroll"`. The scroll direction (`"up"` or `"down"`).
- **scrollCount** (integer) - Optional - Used with `"scroll"`. The number of scroll steps.
### Request Example (Automate Browser)
```json
{
"action": "move_mouse",
"coordinates": {"x": 100, "y": 960}
}
```
```json
{
"action": "click_mouse",
"button": "left"
}
```
```json
{
"action": "type_text",
"text": "https://example.com"
}
```
```json
{
"action": "press_keys",
"key": "enter"
}
```
```json
{
"action": "screenshot"
}
```
### Response
#### Success Response (200)
- **success** (boolean) - Indicates if the operation was successful.
- **message** (string) - A confirmation message or data (e.g., screenshot data).
#### Response Example (Screenshot)
```json
{
"success": true,
"data": "iVBORw0KGgoAAAANSUhEUgAA..."
}
```
#### Error Response (400 or 500)
- **success** (boolean) - Indicates if the operation was successful (will be false).
- **message** (string) - A message describing the error.
```json
{
"success": false,
"message": "Invalid action specified."
}
```
```
--------------------------------
### Control Computer Function - Python Example
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/rest-api/computer-use.mdx
A Python function using the 'requests' library to interact with the computer-use API. It demonstrates sending various actions and handling responses.
```python
import requests
def control_computer(action, **params):
url = "http://localhost:9990/computer-use"
data = {"action": action, **params}
response = requests.post(url, json=data)
return response.json()
# Move the mouse
result = control_computer("move_mouse", coordinates={"x": 100, "y": 100})
print(result)
```
--------------------------------
### Port-Forward Bytebot UI Service (Kubectl)
Source: https://github.com/bytebot-ai/bytebot/blob/main/helm/templates/NOTES.txt
This command allows local access to the Bytebot UI by forwarding traffic from your local machine to the service. It requires kubectl to be installed and configured to communicate with your Kubernetes cluster. The command forwards local port 9992 to the Bytebot UI service's port 9992 within the specified namespace.
```bash
kubectl port-forward -n {{ .Release.Namespace }} service/bytebot-ui 9992:9992
```
--------------------------------
### Configure Port for Bytebot UI (Bash)
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/quickstart.mdx
Modify the port configuration in the `docker-compose.yml` file to change the external port for the Bytebot UI. The example shows how to change the default port 8080 to a custom port.
```bash
# Change default ports if needed
# Edit docker-compose.yml ports section:
# bytebot-ui:
# ports:
# - "8080:9992" # Change 8080 to your desired port
```
--------------------------------
### Check Bytebot Deployment Status (Kubectl)
Source: https://github.com/bytebot-ai/bytebot/blob/main/helm/templates/NOTES.txt
This command retrieves the status of all pods belonging to the Bytebot deployment within a specific Kubernetes namespace. It is essential for verifying that the application's components are running correctly. The output will show information about each pod, including its name, ready status, and age.
```bash
kubectl get pods -n {{ .Release.Namespace }}
```
--------------------------------
### Customize Bytebot Desktop with Dockerfile
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/core-concepts/desktop-environment.mdx
A sample Dockerfile demonstrating how to extend the base Bytebot Desktop image. It shows how to install additional software like Slack and Zoom, and copy custom configuration files.
```dockerfile
FROM ghcr.io/bytebot-ai/bytebot-desktop:edge
# Install additional packages
RUN apt-get update && apt-get install -y \
slack-desktop \
zoom \
your-custom-app
# Copy configuration files
COPY configs/ /home/user/.config/
```
--------------------------------
### POST /computer-use - Copy and Paste Text
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/rest-api/examples.mdx
Example demonstrating how to perform copy and paste operations using cURL.
```APIDOC
## POST /computer-use (Copy and Paste)
### Description
This example illustrates how to execute copy and paste functionalities using the Bytebot API via cURL requests. It involves selecting text, copying it to the clipboard, moving the mouse, and then pasting the content.
### Method
POST
### Endpoint
http://localhost:9990/computer-use
### Parameters
#### Request Body
- **action** (string) - Required - The action to perform (e.g., "move_mouse", "click_mouse", "press_keys").
- **coordinates** (object) - Optional - Used with "move_mouse" to specify x and y coordinates.
- **button** (string) - Optional - Used with "click_mouse" to specify the mouse button (e.g., "left").
- **clickCount** (integer) - Optional - Used with "click_mouse" to specify the number of clicks (e.g., 3 for triple click).
- **keys** (array of strings) - Required for "press_keys" - Specifies the keys to press (e.g., ["ctrl", "c"], ["ctrl", "v"]).
- **press** (string) - Optional for "press_keys" - Specifies the key press state ("down" or "up").
### Request Example (Copy)
```bash
# Select text with triple click
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "move_mouse", "coordinates": {"x": 400, "y": 300}}'
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "click_mouse", "button": "left", "clickCount": 3}'
# Copy with Ctrl+C
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "press_keys", "keys": ["ctrl", "c"], "press": "down"}'
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "press_keys", "keys": ["ctrl", "c"], "press": "up"}'
```
### Request Example (Paste)
```bash
# Click elsewhere to prepare for paste
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "move_mouse", "coordinates": {"x": 400, "y": 500}}'
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "click_mouse", "button": "left"}'
# Paste with Ctrl+V
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "press_keys", "keys": ["ctrl", "v"], "press": "down"}'
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "press_keys", "keys": ["ctrl", "v"], "press": "up"}'
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
#### Response Example
```json
{
"status": "success",
"data": {}
}
```
```
--------------------------------
### Error Response Example (JSON)
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/api-reference/agent/tasks.mdx
Example JSON structure for an API error response, indicating a 'Not Found' error with a specific message.
```json
{
"statusCode": 404,
"message": "Task with ID task-123 not found",
"error": "Not Found"
}
```
--------------------------------
### API Key Management Example (YAML)
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/guides/password-management.mdx
Demonstrates how to store API keys, such as for OpenAI, within a password manager. It shows the structure for a password entry including the key itself and relevant notes like rate limits, and how to reference it in a task.
```yaml
# Store API keys in password manager
Password Entry: "OpenAI API Key"
- Username: "api"
- Password: "sk-proj-..."
- Notes: "Rate limit: 10000/day"
# Use in tasks
Task: "Configure the application to use our OpenAI API key
from the password manager"
```
--------------------------------
### Install Bytebot using Helm
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/deployment/helm.mdx
Installs Bytebot on a Kubernetes cluster using Helm, specifying the namespace and a custom values file. Ensures the namespace is created if it doesn't exist.
```bash
helm install bytebot ./helm \
--namespace bytebot \
--create-namespace \
-f values.yaml
```
--------------------------------
### Direct Desktop Control (Bash)
Source: https://github.com/bytebot-ai/bytebot/blob/main/README.md
Illustrates how to control the desktop agent directly using cURL commands. Examples include taking a screenshot and simulating mouse clicks at specific coordinates.
```bash
# Take a screenshot
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "screenshot"}'
# Click at specific coordinates
curl -X POST http://localhost:9990/computer-use \
-H "Content-Type: application/json" \
-d '{"action": "click_mouse", "coordinate": [500, 300]}'
```
--------------------------------
### Enterprise Deployment with Helm (Bash)
Source: https://github.com/bytebot-ai/bytebot/blob/main/README.md
Provides instructions for deploying Bytebot in an enterprise environment using Helm. It includes cloning the repository and installing with Helm, specifying environment variables like API keys.
```bash
# Clone the repository
git clone https://github.com/bytebot-ai/bytebot.git
cd bytebot
# Install with Helm
helm install bytebot ./helm \
--set agent.env.ANTHROPIC_API_KEY=sk-ant-...
```
--------------------------------
### Deploy Desktop Container with Docker Compose
Source: https://github.com/bytebot-ai/bytebot/blob/main/docs/quickstart.mdx
Instructions for deploying the virtual desktop container using Docker Compose. This can be done by pulling a pre-built image or building it locally. Access to the desktop is provided via a VNC URL.
```bash
# Using pre-built image (recommended)
docker-compose -f docker/docker-compose.core.yml pull
docker-compose -f docker/docker-compose.core.yml up -d
# Or build locally:
docker-compose -f docker/docker-compose.core.yml up -d --build
```