### Install Bun and Run Server-Demo Source: https://docs.blackbox.ai/features/blackbox-logger This snippet details the process of installing Bun (a JavaScript runtime) and then starting the server-demo application. It assumes Bun is installed and the server-demo environment is configured. ```bash bun install bun index.ts ``` -------------------------------- ### Start BLACKBOX CLI Source: https://docs.blackbox.ai/features/blackbox-cli This command starts the BLACKBOX CLI after it has been installed and configured. It will prompt for configuration if it's the first run. ```bash blackbox ``` -------------------------------- ### Example Multi-Agent Workflow in Blackbox CLI Source: https://docs.blackbox.ai/features/blackbox-cli/commands-reference Illustrates a typical workflow for using the multi-agent feature, starting a session and then initiating a task. The output describes the branches that will be created. ```bash # Start session blackbox session # Run multi-agent task > /multi-agent build a todo app with React and TypeScript # BLACKBOX CLI will: # 1. Create branch: blackboxai/multi-agent-claude- # 2. Create branch: blackboxai/multi-agent-blackbox- # 3. Create branch: blackboxai/multi-agent-codex- (if OpenAI key configured) ``` -------------------------------- ### Code Example in Markdown (Python) Source: https://docs.blackbox.ai/features/blackbox-cli/skills Illustrates how to include executable code examples within markdown files, specifically for demonstrating a function's behavior. This is essential for providing clear and testable examples within skills documentation. The example shows a simple Python function for user creation. ```python ## Examples ### Good Example ```python def test_user_creation(): user = User(name="John", email="john@example.com") assert user.name == "John" ``` ``` -------------------------------- ### Download BlackBox AI IDE for Different Platforms Source: https://docs.blackbox.ai/features/blackbox-ide Provides direct download links for the BlackBox AI IDE installer, catering to Apple Silicon, Apple Intel-based Macs, and Windows operating systems. No specific dependencies are mentioned, and the output is the downloaded installer file. ```html
Apple Silicon Apple Intel Chip Windows
``` -------------------------------- ### Install Blackbox CLI on Unix/Linux/macOS Source: https://docs.blackbox.ai/features/blackbox-cli/commands-reference Installs the Blackbox CLI using a curl command to download and execute the installation script. This is the standard method for Unix-like systems. ```bash curl -fsSL https://blackbox.ai/install.sh | bash ``` -------------------------------- ### Connect MCP Server via Terminal Source: https://docs.blackbox.ai/features/blackbox-cloud-mcp This command adds the Blackbox AI MCP remote server to your local setup. It requires the MCP setup command or a direct URL and an authorization token. Replace '' with your actual token. ```bash blackbox mcp add remote-code https://cloud.blackbox.ai/api/mcp -t http -H "Authorization: Bearer " ``` -------------------------------- ### Tool Calling Example (TypeScript) Source: https://docs.blackbox.ai/api-reference/tool-calling A TypeScript code example demonstrating how to integrate Blackbox AI's tool calling functionality, including setting up API credentials and making the initial request. ```APIDOC ## Tool Calling Example (TypeScript) ### Description This example shows a basic TypeScript implementation for interacting with the Blackbox AI chat completions API, specifically for initiating a conversation that might involve tool calls. ### Method POST ### Endpoint `/chat/completions` ### Parameters #### Request Body (as shown in Step 1) #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., `Bearer YOUR_API_KEY`). - **Content-Type** (string) - Required - Set to `application/json`. ### Request Example ```typescript const API_KEY = "YOUR_API_KEY"; const API_URL = "https://api.blackbox.ai/chat/completions"; async function callBlackboxAI() { try { const response = await fetch(API_URL, { method: "POST", headers: { Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ model: "blackboxai/google/gemini-2.0-flash-001", messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "What are the titles of some James Joyce books?", } ], // Tools would be included here as per Step 1 documentation // tools: [ // { // type: "function", // function: { // name: "search_gutenberg_books", // description: "Search for books in the Project Gutenberg library", // parameters: { // type: "object", // properties: { // search_terms: { // type: "array", // items: { type: "string" }, // description: "List of search terms to find books" // } // }, // required: ["search_terms"] // } // } // } // ] }), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); console.log(data); // Process the response, potentially handling tool_calls } catch (error) { console.error("Error calling Blackbox AI:", error); } } callBlackboxAI(); ``` ### Response #### Success Response (200) Refer to the response format described in "Step 1: Inference Request with Tools" or "Step 3: Inference Request with Tool Results", depending on the stage of the tool calling workflow. #### Response Example (See examples in Step 1 and Step 3) ``` -------------------------------- ### Install BLACKBOX CLI on Windows Source: https://docs.blackbox.ai/features/blackbox-cli This command downloads the PowerShell installation script for BLACKBOX CLI and then executes it. It requires PowerShell to be available on the Windows system. ```powershell Invoke-WebRequest -Uri "https://blackbox.ai/install.ps1" -OutFile "install.ps1"; .\install.ps1 ``` -------------------------------- ### Install BLACKBOX CLI on Unix/Linux/macOS Source: https://docs.blackbox.ai/features/blackbox-cli This command downloads and executes the installation script for BLACKBOX CLI on Unix-like systems using curl. It requires a terminal with bash support. ```bash curl -fsSL https://blackbox.ai/install.sh | bash ``` -------------------------------- ### Multi-Agent Task API Source: https://docs.blackbox.ai/releases/releases Run tasks across multiple AI agents simultaneously for comparing approaches, validating solutions, and getting diverse perspectives on code quality. An AI judge automatically selects the best solution. ```APIDOC ## POST /api/multi-agent-tasks ### Description Execute tasks across multiple AI agents simultaneously to compare different implementation approaches, validate solutions across multiple AI models, and get diverse perspectives on code quality. An AI judge automatically selects the best solution for the final pull request. ### Method POST ### Endpoint /api/multi-agent-tasks ### Parameters #### Request Body - **repository_url** (string) - Required - URL of the GitHub repository. - **task_prompt** (string) - Required - The prompt describing the task to be executed. - **agents** (array) - Required - A list of AI agents to be used for the task. Each agent object should include: - **agent_type** (string) - Required - The type of AI agent (e.g., "Claude Agent", "Blackbox Agent"). - **model** (string) - Required - The specific AI model to use (e.g., "Opus 4", "GPT-5 Codex"). ### Request Example ```json { "repository_url": "https://github.com/user/repo.git", "task_prompt": "Implement a new feature to handle user authentication.", "agents": [ { "agent_type": "Claude Agent", "model": "Opus 4" }, { "agent_type": "Blackbox Agent", "model": "BLACKBOX PRO" }, { "agent_type": "Codex Agent", "model": "GPT-5 Codex" } ] } ``` ### Response #### Success Response (200) - **task_id** (string) - Unique identifier for the multi-agent task. - **status** (string) - Current status of the task (e.g., "in_progress", "completed", "failed"). - **best_solution_pr_url** (string) - URL to the pull request generated by the AI judge's selected solution. - **individual_results** (array) - Details of results from each agent. #### Response Example ```json { "task_id": "multi_task_67890", "status": "completed", "best_solution_pr_url": "https://github.com/user/repo/pull/2", "individual_results": [ { "agent_type": "Claude Agent", "model": "Opus 4", "status": "completed", "pr_url": "https://github.com/user/repo/pull/1-claude" }, { "agent_type": "Blackbox Agent", "model": "BLACKBOX PRO", "status": "completed", "pr_url": "https://github.com/user/repo/pull/1-blackbox" } ] } ``` ``` -------------------------------- ### Specify Different Repository for Task Execution Source: https://docs.blackbox.ai/features/blackbox-cloud-mcp These examples demonstrate how to execute tasks on repositories different from the one currently being worked on. This includes adding a new repository for documentation, implementing features in open-source projects, and fixing bugs in personal API repositories. ```bash /remote add documentation microsoft/vscode ``` ```bash /remote implement dark mode facebook/react --branch feature/dark-mode ``` ```bash /remote fix authentication bug john/my-api --branch main ``` -------------------------------- ### Retrieve GitHub Issues using Python Source: https://docs.blackbox.ai/api-reference/github-issues This Python example utilizes the requests library to fetch GitHub issues. It requires your Blackbox API key and repository details, and constructs the appropriate request headers. ```python import requests API_KEY = "bb_YOUR_API_KEY" owner = "example-user" repo = "example-repo" API_URL = f"https://cloud.blackbox.ai/api/github/issues?owner={owner}&repo={repo}" headers = { "Authorization": f"Bearer {API_KEY}" } response = requests.get(API_URL, headers=headers) issues = response.json() print(issues) ``` -------------------------------- ### Review and Compare AI Implementations Source: https://docs.blackbox.ai/features/blackbox-cli/common-use-cases After the multi-agent execution, use Git commands to list the newly created branches and check out each one to review the different implementations. This allows for a thorough comparison of code quality, structure, error handling, security, and performance. ```bash # List all branches created git branch # Check out each branch to review git checkout blackboxai/multi-agent-claude- git checkout blackboxai/multi-agent-blackbox- git checkout blackboxai/multi-agent-codex- ``` -------------------------------- ### Retrieve GitHub Issues using cURL Source: https://docs.blackbox.ai/api-reference/github-issues This example demonstrates how to fetch GitHub issues from a repository using a cURL command. It requires your Blackbox API key and the repository owner and name as query parameters. ```bash curl --location 'https://cloud.blackbox.ai/api/github/issues?owner=example-user&repo=example-repo' \ --header 'Authorization: Bearer bb_YOUR_API_KEY' ``` -------------------------------- ### Clone and Configure Server-Demo Environment Source: https://docs.blackbox.ai/features/blackbox-logger This snippet shows how to clone the server-demo repository and set up its environment variables, including Twilio credentials, ElevenLabs API key, and Blackbox API key. It requires the server-demo repository and specific environment variables. ```bash git clone https://github.com/blackboxaicode/server-demo.git cd server-demo cp .env.example .env # Add all required environment variables to server-demo/.env # Example: AILOGW_TWILIO_ACCOUNT_SID="" AILOGW_TWILIO_AUTH_TOKEN="" AILOGW_NUMBER_TO="" AILOGW_NUMBER_FROM="" ELEVENLABS_API_KEY="" AILOGW_ALERT_AGENT_ID="" AILOGW_GITHUB_AGENT_ID="" BLACKBOX_API_KEY="" AILOGW_LOG= ``` -------------------------------- ### Initialize Stripe with Secret Key (TypeScript) Source: https://docs.blackbox.ai/api-reference/get-task Initializes the Stripe SDK using a secret key from environment variables. This is a common setup for integrating Stripe payments in a TypeScript project. It requires the 'stripe' package to be installed and the STRIPE_SECRET_KEY environment variable to be set. ```typescript import Stripe from 'stripe'; export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY); ``` -------------------------------- ### Use Case: Critical Features Source: https://docs.blackbox.ai/api-reference/multi-agent-task Example JSON configuration for implementing critical features, such as payment processing with Stripe integration. This setup uses 2-3 agents for validation purposes, ensuring robustness and correctness. ```json { "prompt": "Implement payment processing with Stripe integration", "selectedAgents": [/* 2-3 agents for validation */] } ``` -------------------------------- ### Fetch All GitHub Repositories (Node.js) Source: https://docs.blackbox.ai/api-reference/github-all-repos This Node.js example shows how to retrieve all accessible GitHub repositories using the Fetch API. It includes setting the Authorization header with your API key. The response is parsed as JSON, and the 'repos' array is logged to the console. ```javascript const API_KEY = "bb_YOUR_API_KEY"; const API_URL = "https://cloud.blackbox.ai/api/github/all-repos"; const response = await fetch(API_URL, { method: "GET", headers: { Authorization: `Bearer ${API_KEY}`, }, }); const data = await response.json(); console.log(data.repos); ``` -------------------------------- ### Agent Selection: Diverse Models Source: https://docs.blackbox.ai/api-reference/multi-agent-task Configuration for selecting diverse AI agents with different strengths. This example includes Claude for reasoning, Codex for code generation, and Gemini for efficiency, demonstrating a multi-agent setup for comprehensive task handling. ```json { "selectedAgents": [ { "agent": "claude", "model": "blackboxai/anthropic/claude-sonnet-4.5" }, // Great for complex reasoning { "agent": "codex", "model": "gpt-5-codex" }, // Excellent for code generation { "agent": "gemini", "model": "gemini-2.0-flash-exp" } // Fast and efficient ] } ``` -------------------------------- ### Fetch Task Details using Node.js Source: https://docs.blackbox.ai/api-reference/get-task This Node.js example shows how to fetch task details from the Blackbox AI API using the `fetch` API. It includes setting up the API URL, task ID, and authentication headers. ```javascript const API_KEY = "bb_YOUR_API_KEY"; const TASK_ID = "9qQe2F8Z_nXx9-eJA0BD6"; const API_URL = `https://cloud.blackbox.ai/api/tasks/${TASK_ID}`; const response = await fetch(API_URL, { method: "GET", headers: { Authorization: `Bearer ${API_KEY}`, Accept: "application/json", }, }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Assistant Prefill Example (TypeScript) Source: https://docs.blackbox.ai/api-reference/requests Demonstrates how to use the 'assistant prefill' feature by including a message with `role: 'assistant'` at the end of the `messages` array. This guides the model to complete a partial response. Requires an API key and sends a POST request to the completions endpoint. ```typescript const API_KEY = "YOUR_API_KEY"; fetch('https://api.blackbox.ai/api/chat/completions', { method: 'POST', headers: { Authorization: 'Bearer ${API_KEY}', 'Content-Type': 'application/json', }, body: JSON.stringify({ model: 'BLACKBOX AI/openai/gpt-4o', messages: [ { role: 'user', content: 'What is the meaning of life?' }, { role: 'assistant', content: "I'm not sure, but my best guess is" }, ], }), }); ``` -------------------------------- ### Initialize and Navigate Git Repository Source: https://docs.blackbox.ai/features/blackbox-cli/common-use-cases Before using the multi-agent feature, ensure you are within a Git-initialized directory. This snippet shows how to initialize a new Git repository or navigate to an existing one. ```bash # Initialize Git if needed git init # Or navigate to an existing Git repository cd your-project ``` -------------------------------- ### Install BLACKBOX AI Logger NPM Package Source: https://docs.blackbox.ai/features/blackbox-logger This command installs the BLACKBOX AI Logger package using npm. Ensure you have Node.js and npm installed on your system. ```bash npm install @blackbox_ai/ai-logs-watcher ``` -------------------------------- ### Blackbox CLI Skill Commands (Reference) Source: https://docs.blackbox.ai/features/blackbox-cli/skills A quick reference table listing common Blackbox CLI commands for managing skills, including their descriptions and example usage. This is useful for quick lookups. ```bash | Command | Description | Example | | ---------------------- | ------------------ | ------------------------ | | `/skill` | Show help | `/skill` | | `/skill list` | List all skills | `/skill list` | | `/skill create ` | Create new skill | `/skill create frontend` | | `/skill info ` | View skill details | `/skill info frontend` | ``` -------------------------------- ### Configure BLACKBOX CLI Source: https://docs.blackbox.ai/features/blackbox-cli This command initiates the configuration process for BLACKBOX CLI, prompting the user to set up providers and enter their API key. It's essential for the first-time use and can be run anytime to reconfigure settings. ```bash blackbox configure ``` -------------------------------- ### GET /api/github/repos Source: https://docs.blackbox.ai/api-reference/github-repos Retrieve repositories for a specific GitHub user or organization. ```APIDOC ## GET /api/github/repos ### Description Retrieve repositories for a specific GitHub user or organization. ### Method GET ### Endpoint https://cloud.blackbox.ai/api/github/repos ### Parameters #### Query Parameters - **owner** (string) - Required - The GitHub username or organization name whose repositories you want to retrieve. #### Headers - **Authorization** (string) - Required - API Key of the form `Bearer `. ### Request Example ```bash curl --location 'https://cloud.blackbox.ai/api/github/repos?owner=example-user' \ --header 'Authorization: Bearer bb_YOUR_API_KEY' ``` ### Response #### Success Response (200) - **name** (string) - The repository name. - **full_name** (string) - The full repository name including owner (format: `owner/repo-name`). - **description** (string) - The repository description. Can be `null` if no description is set. - **private** (boolean) - Whether the repository is private (`true`) or public (`false`). - **clone_url** (string) - The HTTPS URL for cloning the repository. - **updated_at** (string) - ISO 8601 timestamp of the last update to the repository. - **language** (string) - The primary programming language of the repository. Can be `null` if not detected. #### Response Example ```json [ { "name": "example-repo", "full_name": "example-user/example-repo", "description": "An example repository", "private": false, "clone_url": "https://github.com/example-user/example-repo.git", "updated_at": "2025-11-15T10:30:00Z", "language": "JavaScript" } ] ``` ``` -------------------------------- ### Fetch Task Details using Go Source: https://docs.blackbox.ai/api-reference/get-task This Go snippet shows how to retrieve task information from the Blackbox AI API. It constructs an HTTP GET request, sets the necessary authorization and accept headers, and prints the response body. Error handling for the HTTP request and response reading is included. ```go package main import ( "fmt" "io" "net/http" ) func main() { apiKey := "bb_YOUR_API_KEY" taskId := "9qQe2F8Z_nXx9-eJA0BD6" url := fmt.Sprintf("https://cloud.blackbox.ai/api/tasks/%s", taskId) req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", apiKey)) req.Header.Add("Accept", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) } ``` -------------------------------- ### GET /api/github/branches Source: https://docs.blackbox.ai/api-reference/github-branches Retrieves all branches from a specified GitHub repository. Requires authentication with a BLACKBOX API Key. ```APIDOC ## GET /api/github/branches ### Description Retrieves all branches from a specific GitHub repository. This endpoint returns a list of all branches in a specified GitHub repository, including branch names, protection status, and default branch information. ### Method GET ### Endpoint /api/github/branches ### Parameters #### Query Parameters - **owner** (string) - Required - The GitHub username or organization name that owns the repository. - **repo** (string) - Required - The repository name from which to retrieve branches. #### Request Body None ### Headers - **Authorization** (string) - Required - API Key of the form `Bearer `. ### Request Example ```bash curl --location 'https://cloud.blackbox.ai/api/github/branches?owner=example-user&repo=example-repo' \ --header 'Authorization: Bearer bb_YOUR_API_KEY' ``` ### Response #### Success Response (200) - **name** (string) - The name of the branch. - **protected** (boolean) - Whether the branch is protected from force pushes and deletion. - **isDefault** (boolean) - Whether this is the default branch of the repository (typically `main` or `master`). #### Response Example ```json [ { "name": "main", "protected": true, "isDefault": true }, { "name": "feature/new-api", "protected": false, "isDefault": false } ] ``` #### Error Response (400) ```json { "error": "Bad Request", "message": "Missing required parameters: owner and repo", "status": 400 } ``` #### Error Response (404) ```json { "error": "Not Found", "message": "Repository not found or you don't have access", "status": 404 } ``` ``` -------------------------------- ### GET /api/github/orgs Source: https://docs.blackbox.ai/api-reference/github-orgs Retrieves a list of GitHub organizations associated with the authenticated user's account. Requires an API key for authentication. ```APIDOC ## GET /api/github/orgs ### Description Retrieves a list of all GitHub organizations that the authenticated user has access to, including organization details such as name, login, and avatar. ### Method GET ### Endpoint https://cloud.blackbox.ai/api/github/orgs ### Parameters #### Headers - **Authorization** (string) - Required - API Key of the form `Bearer `. ### Request Example ```bash cURL curl --location 'https://cloud.blackbox.ai/api/github/orgs' \ --header 'Authorization: Bearer bb_YOUR_API_KEY' ``` ### Response #### Success Response (200) - **login** (string) - The organization's GitHub username/login identifier. - **name** (string) - The display name of the organization. - **avatar_url** (string) - URL to the organization's avatar image. #### Response Example ```json [ { "login": "example-org", "name": "Example Organization", "avatar_url": "https://avatars.githubusercontent.com/u/12345678?v=4" } ] ``` #### Error Response (401) - **error** (string) - Error message. - **message** (string) - Detailed error description. - **status** (integer) - HTTP status code. #### Response Example ```json { "error": "Unauthorized", "message": "Invalid or missing API key", "status": 401 } ``` ```