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 modelflux-pro- Professional modelflux-pro-1.1- Enhanced professional modelflux-pro-1.1-ultra- Ultra high-quality modelflux-kontext-pro- Context-aware model with reference image support and experimental multi-reference capabilitiesflux-pro-1.0-fill- Image inpainting modelflux-pro-1.0-expand- Image expansion modelflux-pro-1.0-canny- Canny edge-guided modelflux-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.
Metadata
Release files for blackforest 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| blackforest-0.1.3.tar.gz | 18.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| blackforest-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 41.7 kB
Release files / blackforest-0.1.3.tar.gz
| Download URL | blackforest-0.1.3.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e5b069690a036fda90c1f3b8b44189a873522d54852cbea5642f2bcf4df3158
|
|
BLAKE2b-256 checksum How to use checksums |
b4e5e580c9ae37bcf2d70365c452d3e6a34e5f9cf0ced4fcb63430d46530a908
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / blackforest-0.1.3-py3-none-any.whl
| Download URL | blackforest-0.1.3-py3-none-any.whl |
|---|---|
| Size | 22.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8f0fed51e305ed93711e756971bf7b85569f03714504d55e154bbb0c2cf6cfb1
|
|
BLAKE2b-256 checksum How to use checksums |
8bca02cbaab5a7979fa39547269bbb9bf434013c68115ae633d948697514ef4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|