Skip to main content

The official Python library for the Black Forest Labs API

Project description

BFL Client - Black Forest Labs API Client

A Python client for interacting with the Black Forest Labs API.

Installation

You can install the package using either name:

pip install blackforest

Quick Start

# You can import using either name
from blackforest import BFLClient
# or
from blackforestlabs import BFLClient

import os

# For synchronous API call (great for testing, but please use "production" for async calls, for faster throughput)
os.environ["BFL_ENV"] = "dev"  

# Initialize the client
client = BFLClient(api_key="your-api-key")

# Use the client to make API calls
inputs = {
        "prompt": "a beautiful sunset over mountains, digital art style",
        "width": 1024,
        "height": 768,
        "output_format": "jpeg"
    }
response = client.generate("flux-pro-1.1", inputs)

# For Flux Kontext Pro with reference images
kontext_inputs = {
        "prompt": "A beautiful landscape in the style of the reference image",
        "input_image": "path/to/reference/image.jpg",  # File path (auto-encoded) or base64
        "input_image_2": "path/to/another/image.png",  # Optional multiref (experimental)
        "aspect_ratio": "16:9",  # Between 1:4 and 4:1
        "output_format": "png",
        "seed": 42,  # Optional for reproducibility
        "safety_tolerance": 2,  # 0-6, higher = less strict
        "prompt_upsampling": True  # Enhanced prompt processing
    }
response = client.generate("flux-kontext-pro", kontext_inputs)

Features

  • Official Python interface for Black Forest Labs API
  • Automatic request handling and response parsing
  • Type hints for better IDE support
  • Support for all Flux models including Flux Kontext Pro with multi-reference capabilities

Supported Models

  • flux-dev - Development model
  • flux-pro - Professional model
  • flux-pro-1.1 - Enhanced professional model
  • flux-pro-1.1-ultra - Ultra high-quality model
  • flux-kontext-pro - Context-aware model with reference image support and experimental multi-reference capabilities
  • flux-pro-1.0-fill - Image inpainting model
  • flux-pro-1.0-expand - Image expansion model
  • flux-pro-1.0-canny - Canny edge-guided model
  • flux-pro-1.0-depth - Depth-guided model

Requirements

  • Python 3.7+
  • requests>=2.31.0
  • pydantic>=2.0.0,
  • pillow==10.4.0,

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

blackforest-0.1.2a1.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

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

blackforest-0.1.2a1-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file blackforest-0.1.2a1.tar.gz.

File metadata

  • Download URL: blackforest-0.1.2a1.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for blackforest-0.1.2a1.tar.gz
Algorithm Hash digest
SHA256 9dea80b4d963ba6bf07640af1c843dee9e79497989831a6c16b7b26a1425c3c4
MD5 d4d376e16f18bf92e2be04a8da4fde7d
BLAKE2b-256 a15c6ee15a044cf745b05c83684c5cf2775d8d4524f93ab274b02b2408289aea

See more details on using hashes here.

File details

Details for the file blackforest-0.1.2a1-py3-none-any.whl.

File metadata

  • Download URL: blackforest-0.1.2a1-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for blackforest-0.1.2a1-py3-none-any.whl
Algorithm Hash digest
SHA256 9a5afd4f36070fd2ac36a29637536650c45adae218f3753a9b74755fe02c26db
MD5 413e981e6b7207f55372b04af286b25e
BLAKE2b-256 d05dabaec2fe97fdf48433e56efbd4e9a9d2b3f4091f0c8b72d100552c9d4e1a

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