# Brainiall Image API — Full Documentation ## Overview Brainiall Image API provides GPU-accelerated image processing powered by three state-of-the-art deep learning models: BiRefNet for background removal, Real-ESRGAN for 4x upscaling, and GFPGAN for face restoration. All models run on NVIDIA A10 GPUs with automatic VRAM management. Pricing: $0.003-$0.005 per image. Compare: remove.bg = $0.195/image, Photoroom = $0.02/image, imgupscaler = $0.10/image. ## Base URL https://apim-ai-apis.azure-api.net/v1/image ## Authentication Three authentication methods (use any one): 1. Bearer Token: `Authorization: Bearer YOUR_KEY` 2. API Key: `api-key: YOUR_KEY` 3. Subscription Key: `Ocp-Apim-Subscription-Key: YOUR_KEY` Get your API key at https://brainiall.com ## Endpoints ### POST /remove-background Remove background from an image using BiRefNet (Bilateral Reference Network). Returns PNG with transparent background. Input: multipart/form-data with `file` field Output: PNG image with transparent background ```python import requests response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/remove-background", headers={"Authorization": "Bearer YOUR_KEY"}, files={"file": open("photo.jpg", "rb")} ) with open("result.png", "wb") as f: f.write(response.content) ``` ### POST /remove-background/base64 Same operation with base64 input/output. Useful for web applications and APIs. Input: JSON `{"image": "base64_encoded_image"}` Output: JSON `{"image": "base64_encoded_result"}` ```python import requests import base64 with open("photo.jpg", "rb") as f: b64 = base64.b64encode(f.read()).decode() response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/remove-background/base64", headers={"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"}, json={"image": b64} ) result = response.json() with open("result.png", "wb") as f: f.write(base64.b64decode(result["image"])) ``` ### POST /upscale Upscale an image by 4x using Real-ESRGAN x4plus. A 256x256 image becomes 1024x1024. Input: multipart/form-data with `file` field Output: PNG image (4x resolution) ```python import requests response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/upscale", headers={"Authorization": "Bearer YOUR_KEY"}, files={"file": open("small.jpg", "rb")} ) with open("upscaled.png", "wb") as f: f.write(response.content) ``` ### POST /upscale/base64 Same as above but with base64 input/output. ```python import requests import base64 with open("small.jpg", "rb") as f: b64 = base64.b64encode(f.read()).decode() response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/upscale/base64", headers={"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"}, json={"image": b64} ) result = response.json() with open("upscaled.png", "wb") as f: f.write(base64.b64decode(result["image"])) ``` ### POST /restore-face Restore and enhance faces using GFPGAN v1.3. Removes blur, noise, and compression artifacts from faces. Input: multipart/form-data with `file` field Output: PNG image with restored faces ```python import requests response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/restore-face", headers={"Authorization": "Bearer YOUR_KEY"}, files={"file": open("blurry.jpg", "rb")} ) with open("restored.png", "wb") as f: f.write(response.content) ``` ### POST /restore-face/base64 Same as above but with base64 input/output. ```python import requests import base64 with open("blurry.jpg", "rb") as f: b64 = base64.b64encode(f.read()).decode() response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/restore-face/base64", headers={"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"}, json={"image": b64} ) result = response.json() with open("restored.png", "wb") as f: f.write(base64.b64decode(result["image"])) ``` ### GET /health Service health check with GPU status and model information. ```bash curl -s https://apim-ai-apis.azure-api.net/v1/image/health \ -H "Authorization: Bearer YOUR_KEY" ``` Response: ```json { "status": "healthy", "gpu": { "name": "NVIDIA A10", "vram_total_mb": 24576, "vram_used_mb": 1422, "vram_free_mb": 23154 }, "models": { "birefnet": "loaded", "realesrgan": "loaded", "gfpgan": "loaded" } } ``` ## Code Examples ### Python: Complete Image Processing Pipeline ```python import requests import base64 from pathlib import Path BASE_URL = "https://apim-ai-apis.azure-api.net/v1/image" HEADERS = {"Authorization": "Bearer YOUR_KEY"} def remove_bg(input_path, output_path): """Remove background from image.""" with open(input_path, "rb") as f: resp = requests.post(f"{BASE_URL}/remove-background", headers=HEADERS, files={"file": f}) resp.raise_for_status() with open(output_path, "wb") as f: f.write(resp.content) print(f"Background removed: {output_path}") def upscale(input_path, output_path): """Upscale image 4x.""" with open(input_path, "rb") as f: resp = requests.post(f"{BASE_URL}/upscale", headers=HEADERS, files={"file": f}) resp.raise_for_status() with open(output_path, "wb") as f: f.write(resp.content) print(f"Upscaled 4x: {output_path}") def restore(input_path, output_path): """Restore faces in image.""" with open(input_path, "rb") as f: resp = requests.post(f"{BASE_URL}/restore-face", headers=HEADERS, files={"file": f}) resp.raise_for_status() with open(output_path, "wb") as f: f.write(resp.content) print(f"Face restored: {output_path}") # Full pipeline: remove bg -> upscale -> restore face remove_bg("portrait.jpg", "step1_nobg.png") upscale("step1_nobg.png", "step2_upscaled.png") restore("portrait.jpg", "step3_restored.png") ``` ### Python: Batch Processing with Progress ```python import requests from concurrent.futures import ThreadPoolExecutor, as_completed from pathlib import Path import time BASE_URL = "https://apim-ai-apis.azure-api.net/v1/image" HEADERS = {"Authorization": "Bearer YOUR_KEY"} def process_one(input_path, output_dir, operation="remove-background"): """Process a single image.""" name = Path(input_path).stem output_path = Path(output_dir) / f"{name}_{operation}.png" with open(input_path, "rb") as f: resp = requests.post( f"{BASE_URL}/{operation}", headers=HEADERS, files={"file": f}, timeout=30 ) if resp.status_code == 200: with open(output_path, "wb") as f: f.write(resp.content) return str(output_path), True return str(input_path), False def batch_process(input_dir, output_dir, operation="remove-background", workers=5): """Process all images in a directory.""" input_dir = Path(input_dir) output_dir = Path(output_dir) output_dir.mkdir(exist_ok=True) files = list(input_dir.glob("*.jpg")) + list(input_dir.glob("*.png")) print(f"Processing {len(files)} images with {workers} workers...") start = time.time() results = {"success": 0, "failed": 0} with ThreadPoolExecutor(max_workers=workers) as pool: futures = { pool.submit(process_one, str(f), str(output_dir), operation): f for f in files } for future in as_completed(futures): path, success = future.result() if success: results["success"] += 1 else: results["failed"] += 1 print(f" [{results['success'] + results['failed']}/{len(files)}] {Path(path).name}") elapsed = time.time() - start print(f"Done: {results['success']} success, {results['failed']} failed in {elapsed:.1f}s") print(f"Average: {elapsed / len(files):.2f}s per image") # Usage: batch_process("input_images/", "output_images/", "remove-background", workers=5) batch_process("input_images/", "output_images/", "upscale", workers=3) batch_process("input_images/", "output_images/", "restore-face", workers=5) ``` ### Python: Async Processing with httpx ```python import asyncio import httpx import base64 from pathlib import Path BASE_URL = "https://apim-ai-apis.azure-api.net/v1/image" API_KEY = "YOUR_KEY" async def remove_bg_async(image_bytes: bytes) -> bytes: """Remove background from image bytes asynchronously.""" b64 = base64.b64encode(image_bytes).decode() async with httpx.AsyncClient(timeout=30) as client: resp = await client.post( f"{BASE_URL}/remove-background/base64", headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}, json={"image": b64}, ) resp.raise_for_status() return base64.b64decode(resp.json()["image"]) async def upscale_async(image_bytes: bytes) -> bytes: """Upscale image 4x asynchronously.""" b64 = base64.b64encode(image_bytes).decode() async with httpx.AsyncClient(timeout=60) as client: resp = await client.post( f"{BASE_URL}/upscale/base64", headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}, json={"image": b64}, ) resp.raise_for_status() return base64.b64decode(resp.json()["image"]) async def restore_face_async(image_bytes: bytes) -> bytes: """Restore faces asynchronously.""" b64 = base64.b64encode(image_bytes).decode() async with httpx.AsyncClient(timeout=30) as client: resp = await client.post( f"{BASE_URL}/restore-face/base64", headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}, json={"image": b64}, ) resp.raise_for_status() return base64.b64decode(resp.json()["image"]) async def batch_remove_bg(input_dir: str, output_dir: str, concurrency: int = 5): """Process multiple images concurrently.""" input_path = Path(input_dir) output_path = Path(output_dir) output_path.mkdir(exist_ok=True) files = list(input_path.glob("*.jpg")) + list(input_path.glob("*.png")) semaphore = asyncio.Semaphore(concurrency) async def process_one(filepath): async with semaphore: image_bytes = filepath.read_bytes() result = await remove_bg_async(image_bytes) out = output_path / f"{filepath.stem}_nobg.png" out.write_bytes(result) print(f" Done: {filepath.name}") await asyncio.gather(*[process_one(f) for f in files]) print(f"Processed {len(files)} images") asyncio.run(batch_remove_bg("photos/", "output/", concurrency=5)) ``` ### Python: Error Handling with Retry ```python import requests import time BASE_URL = "https://apim-ai-apis.azure-api.net/v1/image" class BrainiallImage: def __init__(self, api_key: str, max_retries: int = 3, timeout: int = 30): self.session = requests.Session() self.session.headers.update({"Authorization": f"Bearer {api_key}"}) self.max_retries = max_retries self.timeout = timeout def _upload(self, endpoint: str, file_path: str) -> bytes: for attempt in range(self.max_retries): try: with open(file_path, "rb") as f: resp = self.session.post( f"{BASE_URL}/{endpoint}", files={"file": f}, timeout=self.timeout, ) if resp.status_code == 429: time.sleep(2 ** attempt) continue if resp.status_code == 503: time.sleep(5) continue resp.raise_for_status() return resp.content except requests.exceptions.ConnectionError: if attempt < self.max_retries - 1: time.sleep(2) continue raise raise Exception(f"Failed after {self.max_retries} retries") def remove_background(self, file_path: str, output_path: str): result = self._upload("remove-background", file_path) with open(output_path, "wb") as f: f.write(result) return output_path def upscale(self, file_path: str, output_path: str): result = self._upload("upscale", file_path) with open(output_path, "wb") as f: f.write(result) return output_path def restore_face(self, file_path: str, output_path: str): result = self._upload("restore-face", file_path) with open(output_path, "wb") as f: f.write(result) return output_path def health(self) -> dict: resp = self.session.get(f"{BASE_URL}/health", timeout=10) return resp.json() # Usage client = BrainiallImage(api_key="YOUR_KEY") client.remove_background("photo.jpg", "nobg.png") client.upscale("small.jpg", "upscaled.png") client.restore_face("blurry.jpg", "restored.png") print(client.health()) ``` ### Python: FastAPI Image Processing Service ```python from fastapi import FastAPI, UploadFile, File, HTTPException from fastapi.responses import StreamingResponse import httpx import io app = FastAPI() IMAGE_API = "https://apim-ai-apis.azure-api.net/v1/image" API_KEY = "YOUR_KEY" @app.post("/api/remove-background") async def remove_background(file: UploadFile = File(...)): """Remove background from uploaded image.""" content = await file.read() if len(content) > 10 * 1024 * 1024: raise HTTPException(413, "File too large (max 10MB)") async with httpx.AsyncClient(timeout=30) as client: resp = await client.post( f"{IMAGE_API}/remove-background", headers={"Authorization": f"Bearer {API_KEY}"}, files={"file": (file.filename, content, file.content_type)}, ) if resp.status_code != 200: raise HTTPException(resp.status_code, "Image processing failed") return StreamingResponse(io.BytesIO(resp.content), media_type="image/png") @app.post("/api/upscale") async def upscale(file: UploadFile = File(...)): """Upscale image 4x.""" content = await file.read() async with httpx.AsyncClient(timeout=60) as client: resp = await client.post( f"{IMAGE_API}/upscale", headers={"Authorization": f"Bearer {API_KEY}"}, files={"file": (file.filename, content, file.content_type)}, ) if resp.status_code != 200: raise HTTPException(resp.status_code, "Upscaling failed") return StreamingResponse(io.BytesIO(resp.content), media_type="image/png") @app.post("/api/restore-face") async def restore_face(file: UploadFile = File(...)): """Restore faces in image.""" content = await file.read() async with httpx.AsyncClient(timeout=30) as client: resp = await client.post( f"{IMAGE_API}/restore-face", headers={"Authorization": f"Bearer {API_KEY}"}, files={"file": (file.filename, content, file.content_type)}, ) if resp.status_code != 200: raise HTTPException(resp.status_code, "Face restoration failed") return StreamingResponse(io.BytesIO(resp.content), media_type="image/png") ``` ### Python: E-Commerce Product Image Pipeline ```python import requests from pathlib import Path BASE_URL = "https://apim-ai-apis.azure-api.net/v1/image" HEADERS = {"Authorization": "Bearer YOUR_KEY"} def process_product_image(input_path: str, output_dir: str) -> dict: """Full e-commerce product image pipeline. 1. Remove background for clean product shots 2. Upscale for high-resolution listing images """ output = Path(output_dir) output.mkdir(exist_ok=True) name = Path(input_path).stem # Step 1: Remove background with open(input_path, "rb") as f: resp = requests.post(f"{BASE_URL}/remove-background", headers=HEADERS, files={"file": f}) nobg_path = output / f"{name}_nobg.png" nobg_path.write_bytes(resp.content) # Step 2: Upscale the clean image with open(nobg_path, "rb") as f: resp = requests.post(f"{BASE_URL}/upscale", headers=HEADERS, files={"file": f}) hires_path = output / f"{name}_hires.png" hires_path.write_bytes(resp.content) return { "original": input_path, "no_background": str(nobg_path), "high_resolution": str(hires_path), } # Process all product photos products = Path("product_photos/").glob("*.jpg") for photo in products: result = process_product_image(str(photo), "processed/") print(f"Processed: {photo.name}") ``` ### Python: Photo Enhancement Workflow ```python import requests from pathlib import Path BASE_URL = "https://apim-ai-apis.azure-api.net/v1/image" HEADERS = {"Authorization": "Bearer YOUR_KEY"} def enhance_portrait(input_path: str, output_dir: str) -> dict: """Enhance a portrait photo. 1. Restore face quality (remove blur, noise, compression artifacts) 2. Upscale to high resolution """ output = Path(output_dir) output.mkdir(exist_ok=True) name = Path(input_path).stem # Step 1: Restore face with open(input_path, "rb") as f: resp = requests.post(f"{BASE_URL}/restore-face", headers=HEADERS, files={"file": f}) restored_path = output / f"{name}_restored.png" restored_path.write_bytes(resp.content) # Step 2: Upscale with open(restored_path, "rb") as f: resp = requests.post(f"{BASE_URL}/upscale", headers=HEADERS, files={"file": f}) final_path = output / f"{name}_enhanced.png" final_path.write_bytes(resp.content) return {"restored": str(restored_path), "enhanced": str(final_path)} result = enhance_portrait("old_photo.jpg", "enhanced/") print(f"Enhanced: {result['enhanced']}") ``` ### Python: LangChain Agent with Image Tools ```python from langchain_core.tools import tool from langchain_brainiall import ChatBrainiall from langgraph.prebuilt import create_react_agent import requests import base64 IMAGE_API = "https://apim-ai-apis.azure-api.net/v1/image" API_KEY = "YOUR_KEY" @tool def remove_background(image_url: str) -> str: """Remove background from an image at the given URL. Returns base64 PNG.""" image_data = requests.get(image_url).content b64 = base64.b64encode(image_data).decode() resp = requests.post( f"{IMAGE_API}/remove-background/base64", headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}, json={"image": b64}, ) return f"Background removed. Result size: {len(resp.json()['image'])} chars base64" @tool def upscale_image(image_url: str) -> str: """Upscale an image 4x from the given URL. Returns base64 PNG.""" image_data = requests.get(image_url).content b64 = base64.b64encode(image_data).decode() resp = requests.post( f"{IMAGE_API}/upscale/base64", headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}, json={"image": b64}, ) return f"Image upscaled 4x. Result size: {len(resp.json()['image'])} chars base64" @tool def restore_face(image_url: str) -> str: """Restore and enhance faces in an image from the given URL.""" image_data = requests.get(image_url).content b64 = base64.b64encode(image_data).decode() resp = requests.post( f"{IMAGE_API}/restore-face/base64", headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}, json={"image": b64}, ) return f"Face restored. Result size: {len(resp.json()['image'])} chars base64" llm = ChatBrainiall(model="claude-sonnet-4-6") agent = create_react_agent(llm, [remove_background, upscale_image, restore_face]) result = agent.invoke({ "messages": [("human", "Remove the background from this product photo: https://example.com/product.jpg")] }) ``` ### JavaScript: All Operations ```javascript import fs from "fs"; const BASE_URL = "https://apim-ai-apis.azure-api.net/v1/image"; const API_KEY = "YOUR_KEY"; async function removeBackground(inputPath, outputPath) { const formData = new FormData(); formData.append("file", new Blob([fs.readFileSync(inputPath)])); const response = await fetch(`${BASE_URL}/remove-background`, { method: "POST", headers: { Authorization: `Bearer ${API_KEY}` }, body: formData, }); fs.writeFileSync(outputPath, Buffer.from(await response.arrayBuffer())); console.log(`Background removed: ${outputPath}`); } async function upscaleImage(inputPath, outputPath) { const formData = new FormData(); formData.append("file", new Blob([fs.readFileSync(inputPath)])); const response = await fetch(`${BASE_URL}/upscale`, { method: "POST", headers: { Authorization: `Bearer ${API_KEY}` }, body: formData, }); fs.writeFileSync(outputPath, Buffer.from(await response.arrayBuffer())); console.log(`Upscaled: ${outputPath}`); } async function restoreFace(inputPath, outputPath) { const formData = new FormData(); formData.append("file", new Blob([fs.readFileSync(inputPath)])); const response = await fetch(`${BASE_URL}/restore-face`, { method: "POST", headers: { Authorization: `Bearer ${API_KEY}` }, body: formData, }); fs.writeFileSync(outputPath, Buffer.from(await response.arrayBuffer())); console.log(`Face restored: ${outputPath}`); } async function removeBackgroundBase64(inputPath, outputPath) { const imageBuffer = fs.readFileSync(inputPath); const imageB64 = imageBuffer.toString("base64"); const response = await fetch(`${BASE_URL}/remove-background/base64`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${API_KEY}`, }, body: JSON.stringify({ image: imageB64 }), }); const result = await response.json(); fs.writeFileSync(outputPath, Buffer.from(result.image, "base64")); console.log(`Background removed (base64): ${outputPath}`); } async function checkHealth() { const response = await fetch(`${BASE_URL}/health`, { headers: { Authorization: `Bearer ${API_KEY}` }, }); const health = await response.json(); console.log(`Status: ${health.status}`); console.log(`GPU: ${health.gpu.name}`); console.log(`VRAM: ${health.gpu.vram_used_mb}MB / ${health.gpu.vram_total_mb}MB`); } // Usage: await removeBackground("photo.jpg", "nobg.png"); await upscaleImage("small.jpg", "upscaled.png"); await restoreFace("blurry.jpg", "restored.png"); await checkHealth(); ``` ### JavaScript: Express.js Image Processing API ```javascript import express from "express"; import multer from "multer"; const app = express(); const upload = multer({ limits: { fileSize: 10 * 1024 * 1024 } }); const IMAGE_API = "https://apim-ai-apis.azure-api.net/v1/image"; const API_KEY = "YOUR_KEY"; async function processImage(file, operation) { const formData = new FormData(); formData.append("file", new Blob([file.buffer]), file.originalname); const response = await fetch(`${IMAGE_API}/${operation}`, { method: "POST", headers: { Authorization: `Bearer ${API_KEY}` }, body: formData, }); if (!response.ok) { throw new Error(`Processing failed: ${response.status}`); } return Buffer.from(await response.arrayBuffer()); } app.post("/api/remove-bg", upload.single("image"), async (req, res) => { const result = await processImage(req.file, "remove-background"); res.type("image/png").send(result); }); app.post("/api/upscale", upload.single("image"), async (req, res) => { const result = await processImage(req.file, "upscale"); res.type("image/png").send(result); }); app.post("/api/restore", upload.single("image"), async (req, res) => { const result = await processImage(req.file, "restore-face"); res.type("image/png").send(result); }); app.listen(3000, () => console.log("Image API proxy running on :3000")); ``` ### curl: All Operations ```bash BASE="https://apim-ai-apis.azure-api.net/v1/image" KEY="YOUR_KEY" # Remove background (multipart) curl -X POST "$BASE/remove-background" \ -H "Authorization: Bearer $KEY" \ -F "file=@photo.jpg" \ -o nobg.png # Remove background (base64) B64=$(base64 -i photo.jpg) curl -X POST "$BASE/remove-background/base64" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $KEY" \ -d "{\"image\": \"$B64\"}" | python3 -c " import json, sys, base64 data = json.load(sys.stdin) with open('nobg_b64.png', 'wb') as f: f.write(base64.b64decode(data['image'])) print('Saved nobg_b64.png') " # Upscale 4x curl -X POST "$BASE/upscale" \ -H "Authorization: Bearer $KEY" \ -F "file=@small.jpg" \ -o upscaled.png # Restore face curl -X POST "$BASE/restore-face" \ -H "Authorization: Bearer $KEY" \ -F "file=@blurry.jpg" \ -o restored.png # Health check curl -s "$BASE/health" \ -H "Authorization: Bearer $KEY" | python3 -m json.tool ``` ## Use Cases ### E-Commerce Product Photography Remove backgrounds from product photos for clean, professional listings. Process hundreds of images automatically for marketplace uploads (Amazon, Shopify, eBay). ### Photo Restoration Enhance old, blurry, or low-resolution photos. Combine face restoration with upscaling for dramatic quality improvements on family photos, historical images, and scanned documents. ### Social Media Content Creation Quickly remove backgrounds for social media posts, create clean product shots for Instagram, and upscale images for high-DPI displays. ### Real Estate Photography Clean up property photos by removing distracting elements, upscale low-resolution images, and enhance interior shots. ### AI Agent Workflows Integrate image processing into AI agent pipelines. LangChain and CrewAI agents can call image tools to process user-uploaded photos, create product catalogs, or enhance content. ## Migration Guides ### Migrating from remove.bg ```python # Before: remove.bg ($0.195/image) import requests response = requests.post( "https://api.remove.bg/v1.0/removebg", files={"image_file": open("photo.jpg", "rb")}, data={"size": "auto"}, headers={"X-Api-Key": "REMOVEBG_KEY"}, ) # After: Brainiall ($0.005/image — 39x cheaper) response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/remove-background", headers={"Authorization": "Bearer YOUR_KEY"}, files={"file": open("photo.jpg", "rb")} ) ``` ### Migrating from Photoroom ```python # Before: Photoroom ($0.02/image) # Requires SDK installation and complex setup # After: Brainiall ($0.005/image — 4x cheaper) import requests response = requests.post( "https://apim-ai-apis.azure-api.net/v1/image/remove-background", headers={"Authorization": "Bearer YOUR_KEY"}, files={"file": open("photo.jpg", "rb")} ) # Simple REST API, no SDK needed ``` ## MCP Server ### Configuration (Claude Desktop / Cursor / Cline) ```json { "mcpServers": { "brainiall-image": { "url": "https://apim-ai-apis.azure-api.net/mcp/image/mcp", "headers": { "Accept": "application/json, text/event-stream" } } } } ``` ### Tools | Tool | Description | Parameters | |------|-------------|------------| | remove_background | Remove image background using BiRefNet | image_url or image_base64 | | upscale_image | Upscale image 4x using Real-ESRGAN | image_url or image_base64 | | restore_face | Restore faces using GFPGAN | image_url or image_base64 | | check_image_service | Health check with GPU info | none | ## Pricing | Operation | Price | Monthly cost (10K images) | |-----------|-------|--------------------------| | Background removal | $0.005/image | $50 | | Upscaling | $0.003/image | $30 | | Face restoration | $0.005/image | $50 | ### Cost Comparison | Provider | Background Removal | Upscaling | Face Restore | |----------|-------------------|-----------|-------------| | **Brainiall** | **$0.005** | **$0.003** | **$0.005** | | remove.bg | $0.195 | — | — | | Photoroom | $0.02 | — | — | | imgupscaler | — | $0.10 | — | | Replicate (BiRefNet) | $0.01 | $0.01 | $0.01 | ## Models | Model | Version | VRAM | Description | |-------|---------|------|-------------| | BiRefNet | latest | ~850 MB | Bilateral Reference Network for salient object detection | | Real-ESRGAN | x4plus | ~300 MB | Enhanced Super-Resolution GAN for 4x upscaling | | GFPGAN | v1.3 | ~260 MB | Generative Facial Prior GAN for blind face restoration | Total VRAM: ~1,422 MB out of 24,576 MB (A10) ## Input Requirements - Formats: JPEG, PNG, WebP, BMP, TIFF - Minimum size: 10x10 pixels - Maximum file size: 10MB - Base64: Standard encoding (no data URI prefix needed) ## Error Codes | Code | Meaning | |------|---------| | 200 | Success | | 400 | Bad request (invalid image, too small, wrong format) | | 401 | Invalid or missing API key | | 413 | Image too large (>10MB) | | 429 | Rate limited | | 503 | GPU temporarily unavailable | ## Technical Details - GPU: NVIDIA A10 (24GB VRAM) - Infrastructure: 2x A10 VMs behind Azure Load Balancer (HA) - Processing time: 0.5-3s per image (depends on size and operation) - Concurrent requests: 5-10 per GPU - Output format: PNG (lossless) - VRAM management: Automatic cache clearing between requests ## Links - Website: https://brainiall.com - Get API Key: https://brainiall.com - LLM Gateway: https://github.com/fasuizu-br/brainiall-llm-gateway - NLP APIs: https://github.com/fasuizu-br/brainiall-nlp-api - Speech AI: https://github.com/fasuizu-br/speech-ai-examples