Class: FalImageProvider
Defined in: packages/agentos/src/core/images/providers/FalImageProvider.ts:210
Image generation provider connecting to the Fal.ai serverless platform.
Implements the queue-based submit-then-poll pattern: a generation request returns a request ID immediately, and the provider polls the status endpoint until completion or timeout.
Implements
Example
const provider = new FalImageProvider();
await provider.initialize({ apiKey: process.env.FAL_API_KEY! });
const result = await provider.generateImage({
modelId: 'fal-ai/flux/dev',
prompt: 'A photorealistic astronaut riding a horse on Mars',
});
console.log(result.images[0].url);
Implements
Constructors
Constructor
new FalImageProvider():
FalImageProvider
Returns
FalImageProvider
Properties
defaultModelId?
optionaldefaultModelId:string
Defined in: packages/agentos/src/core/images/providers/FalImageProvider.ts:218
Inherit Doc
Implementation of
isInitialized
isInitialized:
boolean=false
Defined in: packages/agentos/src/core/images/providers/FalImageProvider.ts:215
Inherit Doc
Implementation of
providerId
readonlyproviderId:"fal"='fal'
Defined in: packages/agentos/src/core/images/providers/FalImageProvider.ts:212
Inherit Doc
Implementation of
Methods
generateImage()
generateImage(
request):Promise<ImageGenerationResult>
Defined in: packages/agentos/src/core/images/providers/FalImageProvider.ts:285
Generate an image using the Fal.ai queue API.
Submits the generation task to the queue, then polls the status endpoint until the result is ready or the timeout is reached.
Parameters
request
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: 'fal-ai/flux/dev',
prompt: 'A serene Japanese garden in autumn',
n: 2,
});
Implementation of
initialize()
initialize(
config):Promise<void>
Defined in: packages/agentos/src/core/images/providers/FalImageProvider.ts:234
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: 'fal_xxx' });
Implementation of
listAvailableModels()
listAvailableModels():
Promise<ImageModelInfo[]>
Defined in: packages/agentos/src/core/images/providers/FalImageProvider.ts:357
List available Flux models on the Fal.ai platform.
Returns
Promise<ImageModelInfo[]>
Static list of known Fal.ai model identifiers.