Skip to main content

Class: FluxImageProvider

Defined in: packages/agentos/src/core/images/providers/FluxImageProvider.ts:199

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

Constructor

new FluxImageProvider(): FluxImageProvider

Returns

FluxImageProvider

Properties

defaultModelId?

optional defaultModelId: string

Defined in: packages/agentos/src/core/images/providers/FluxImageProvider.ts:207

Inherit Doc

Implementation of

IImageProvider.defaultModelId


isInitialized

isInitialized: boolean = false

Defined in: packages/agentos/src/core/images/providers/FluxImageProvider.ts:204

Inherit Doc

Implementation of

IImageProvider.isInitialized


providerId

readonly providerId: "bfl" = 'bfl'

Defined in: packages/agentos/src/core/images/providers/FluxImageProvider.ts:201

Inherit Doc

Implementation of

IImageProvider.providerId

Methods

generateImage()

generateImage(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/core/images/providers/FluxImageProvider.ts:274

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

request

ImageGenerationRequest

Image generation request with prompt and optional params.

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',
});

Implementation of

IImageProvider.generateImage


initialize()

initialize(config): Promise<void>

Defined in: packages/agentos/src/core/images/providers/FluxImageProvider.ts:223

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' });

Implementation of

IImageProvider.initialize


listAvailableModels()

listAvailableModels(): Promise<ImageModelInfo[]>

Defined in: packages/agentos/src/core/images/providers/FluxImageProvider.ts:332

List available Flux models on the BFL API.

Returns

Promise<ImageModelInfo[]>

Static list of known BFL model identifiers.

Implementation of

IImageProvider.listAvailableModels