https://github.com/mattt/bfl-python
Unofficial Python client for interacting with the Black Forest Labs API
https://github.com/mattt/bfl-python
Last synced: 9 months ago
JSON representation
Unofficial Python client for interacting with the Black Forest Labs API
- Host: GitHub
- URL: https://github.com/mattt/bfl-python
- Owner: mattt
- License: mit
- Created: 2024-10-03T18:16:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-16T12:01:21.000Z (about 1 year ago)
- Last Synced: 2024-10-18T01:19:40.878Z (about 1 year ago)
- Language: Python
- Homepage: https://pypi.org/project/black-forest-labs/
- Size: 24.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Black Forest Labs API Client
This is an unofficial Python client for interacting with the
[Black Forest Labs API](https://api.bfl.ml/).
```console
pip install black-forest-labs
```
```console
export BFL_API_KEY="..."
```
```python
import black_forest_labs
import time
task = black_forest_labs.generate(
"flux-pro",
prompt="ein fantastisches bild",
)
print(f"Task created with id `{task.id}`")
print("Polling for results...", end="", flush=True)
while not task.is_done:
print(".", end="", flush=True)
task = black_forest_labs.get_result(task.id)
time.sleep(1)
print(f"\nTask finished with status `{task.status}`")
if task.result:
print(f"Prompt: {task.result.prompt}")
print(f"Image URL: {task.result.sample}")
```
```
Task created with id `ce9e065d-dc90-4633-9c1e-44ea839ed569`
Polling for results............
Task finished with status `Ready`
Prompt: ein fantastisches bild
Image URL: https://bflapistorage.blob.core.windows.net/public/db43e36806f74c1a9c6972127c9d71ea/sample.jpg
```