Skip to content

Unofficial Python client for interacting with the Black Forest Labs API

License

Notifications You must be signed in to change notification settings

mattt/bfl-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Black Forest Labs API Client

This is an unofficial Python client for interacting with the Black Forest Labs API.

pip install black-forest-labs
export BFL_API_KEY="..."
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

About

Unofficial Python client for interacting with the Black Forest Labs API

Resources

License

Stars

Watchers

Forks

Languages