Skip to main content

Python SDK for the BGBlur API.

Project description

bgblur-ai

bgblur-ai is a Python SDK and CLI for the BGBlur public API on https://www.bgblur.com. It does not run AI processing locally. Files are uploaded through BGBlur's presigned upload API, processing is delegated to the existing backend stack, and results are downloaded automatically.

Installation

pip install bgblur-ai

Quick start

from bgblur_ai import PrivacyBlur

client = PrivacyBlur(api_key="YOUR_API_KEY")

client.face_blur(
    input="image.jpg",
    output="result.jpg",
    blur_type="gaussian",
)

client.face_anonymize(
    input="video.mp4",
    output="result.mp4",
)

client.license_plate_blur(
    input="car.jpg",
    output="result.jpg",
)

client.blur_anything(
    input="image.jpg",
    prompt="person",
    output="result.jpg",
)

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

bgblur-ai face-blur input.jpg output.jpg --blur-type gaussian
bgblur-ai face-anonymize input.mp4 output.mp4
bgblur-ai license-plate-blur car.jpg result.jpg
bgblur-ai blur-anything image.jpg result.jpg --prompt "person"
bgblur-ai dataset-process --input dataset --output dataset_private --face-blur --plate-blur --blur-type pixelated

API key resolution order:

  1. --api-key
  2. BGBLUR_AI_API_KEY

Base URL resolution order:

  1. --base-url
  2. BGBLUR_AI_BASE_URL
  3. https://www.bgblur.com

API contract

The SDK follows the current BGBlur public API flow:

  • POST /api/v1/uploads/image or POST /api/v1/uploads/video to obtain a presigned upload_url plus image_url or video_url
  • PUT the original file bytes to the returned presigned upload URL
  • POST /api/v1/images/... for synchronous image operations
  • POST /api/v1/videos/... for async video operations
  • GET /api/v1/jobs/{job_id} to inspect queued video jobs

The current implementation uses these BGBlur public endpoints:

  • POST /api/v1/images/face-blur
  • POST /api/v1/images/license-plate-blur
  • POST /api/v1/images/blur-anything
  • POST /api/v1/videos/face-blur
  • POST /api/v1/videos/license-plate-blur
  • POST /api/v1/videos/blur-anything
  • POST /api/v1/videos/face-anonymization

DatasetProcessor uses those same public routes. plate_mode="replace" is not currently exposed by the BGBlur public API, so the SDK raises a clear error for that mode instead of silently falling back to local processing.

Errors

The SDK raises:

  • PrivacyBlurError
  • AuthenticationError
  • RateLimitError
  • ServerError

Development

python -m venv .venv
source .venv/bin/activate
pip install -e .[dev]
pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bgblur_ai-0.1.0.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bgblur_ai-0.1.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file bgblur_ai-0.1.0.tar.gz.

File metadata

  • Download URL: bgblur_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for bgblur_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5e0485f4ea5ff0969cce39b21102927d324703506562ec9f12e4013e41f0d7be
MD5 e57eb9c095bc26b24fd8a6758cf963b2
BLAKE2b-256 552e79041389ce88eaed2ad2cabe10d6f0e58b212bfa6d974454e719dad2a10c

See more details on using hashes here.

File details

Details for the file bgblur_ai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bgblur_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for bgblur_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64948d74b0c39780b77d81c20ce772647fe87a6a845854f4c51569f26fd72437
MD5 e515f39c0bc6fef5b868ba76fcf9b504
BLAKE2b-256 860f795b63f5acc67c92120a728f8fbf400aeac1859a37b5c858337b57e34410

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page