Class FluxImageProvider

Image generation provider connecting directly to the Black Forest Labs (BFL) API for Flux model access.

Implements the async submit-then-poll pattern: a generation request returns a task ID immediately, and the provider polls until the image is ready or a timeout is reached.

Implements

Example

const provider = new FluxImageProvider();
await provider.initialize({ apiKey: process.env.BFL_API_KEY! });

const result = await provider.generateImage({
modelId: 'flux-pro-1.1',
prompt: 'A photorealistic astronaut riding a horse on Mars',
size: '1024x1024',
});
console.log(result.images[0].url);

Implements

Constructors

Methods

  • Initialize the provider with API credentials and optional configuration.

    Parameters

    • config: Record<string, unknown>

      Configuration object. Must include apiKey.

    Returns Promise<void>

    Throws

    If apiKey is missing or empty.

    Example

    await provider.initialize({ apiKey: 'bfl_xxx' });
    
  • Generate an image using the BFL Flux API.

    Submits the generation task, then polls until the result is ready or the timeout is reached.

    Parameters

    Returns Promise<ImageGenerationResult>

    The generated image result with URL(s).

    Throws

    If the provider is not initialized.

    Throws

    If the API returns an error or times out.

    Example

    const result = await provider.generateImage({
    modelId: 'flux-pro-1.1',
    prompt: 'A serene Japanese garden in autumn',
    size: '1024x768',
    });

Properties

providerId: "bfl" = 'bfl'

Inherit Doc

isInitialized: boolean = false

Inherit Doc

defaultModelId?: string

Inherit Doc