Developer Libraries

Python SDK

Install `bgblur-ai` for Python 3.10+ and automate BGBlur privacy processing from scripts, services, and data pipelines.

Installation

Shell
pip install bgblur-ai
Package: bgblur-ai Import: bgblur_ai

Authentication

Shell
export BGBLUR_AI_API_KEY="YOUR_API_KEY"

Get your API key from /developers/api-keys

Quick Start

Blur Faces

Python
from bgblur_ai import PrivacyBlur

with PrivacyBlur(api_key="YOUR_API_KEY") as client:
    client.face_blur(
        input="image.jpg",
        output="face-blurred.jpg",
        blur_type="gaussian",
    )

Blur License Plates

Python
from bgblur_ai import PrivacyBlur

with PrivacyBlur(api_key="YOUR_API_KEY") as client:
    client.license_plate_blur(
        input="car.jpg",
        output="plates-blurred.jpg",
    )

Anonymize Video

Python
from bgblur_ai import PrivacyBlur

with PrivacyBlur(api_key="YOUR_API_KEY") as client:
    client.face_anonymize(
        input="interview.mp4",
        output="anonymous-video.mp4",
    )

Blur Custom Objects

Python
from bgblur_ai import PrivacyBlur

with PrivacyBlur(api_key="YOUR_API_KEY") as client:
    client.blur_anything(
        input="street.jpg",
        prompt="person",
        output="objects-blurred.jpg",
    )

Dataset Processing

Batch process entire datasets.

Python
from bgblur_ai import DatasetProcessor

processor = DatasetProcessor(api_key="YOUR_API_KEY")

report = processor.process_dataset(
    dataset_path="dataset",
    output_path="dataset_private",
    face_blur=True,
    plate_blur=True,
    blur_type="pixelated",
)

print(report.to_json())

CLI

Shell
# Blur faces
bgblur-ai face-blur input.jpg output.jpg --blur-type gaussian

# Anonymize video
bgblur-ai face-anonymize input.mp4 output.mp4

# Blur license plates
bgblur-ai license-plate-blur car.jpg result.jpg

# Blur custom objects
bgblur-ai blur-anything image.jpg result.jpg --prompt "person"

# Process dataset
bgblur-ai dataset-process --input dataset --output dataset_private \
  --face-blur --plate-blur --blur-type pixelated

Error Handling

Python
from bgblur_ai import (
    InsufficientCreditsError,
    PrivacyBlur,
    PrivacyBlurError,
    AuthenticationError,
    RateLimitError,
    ServerError,
)

try:
    with PrivacyBlur(api_key="YOUR_API_KEY") as client:
        client.face_blur(input="image.jpg", output="result.jpg")
except InsufficientCreditsError as exc:
    print(f"Out of credits: {exc}")
except AuthenticationError as exc:
    print(f"Auth failed: {exc}")
except RateLimitError as exc:
    print(f"Rate limit exceeded: {exc}")
except PrivacyBlurError as exc:
    print(f"BGBlur error: {exc}")