Flux 2 Flex
Flux · Image · Text → Image
Adaptable generation across varied visual styles up to 4K.
Model ID:
flux-2-flexWorkflow: bfl/v1/flux-2Image Input4K
Install the SDK
The SDK targets Node 20+ and ships with TypeScript types.
npm
npm install @picsart/ai-sdkAuthenticate
Create a client once with your API key — it's sent as a bearer token on every request.
TypeScript
import { createClient } from '@picsart/ai-sdk';
const ai = createClient({
apiKey: process.env.PICSART_API_KEY, // sent as: Authorization: Bearer <key>
apiUrl: 'https://api.picsart.com',
});Run the model
Call the model with its parameters. This example uses the required ones.
TypeScript
import { createClient } from '@picsart/ai-sdk';
const ai = createClient({
apiKey: process.env.PICSART_API_KEY,
apiUrl: 'https://api.picsart.com',
});
const result = await ai.generate('flux-2-flex', {
prompt: "A serene mountain lake at golden hour, ultra detailed",
aspectRatio: "3:4",
resolution: "1K"
});
console.log(result.url); // image URLParameters
5 parameters. Required ones must be supplied; the rest fall back to their defaults. The API takes these same names over HTTP.
| Parameter | Type | Required | Default | Details |
|---|---|---|---|---|
promptPrompt | text | yes | — | — |
aspectRatio | enum | no | 3:4 | 1:1, 16:9, 9:16, 4:3, 3:4, 21:9, 9:21 |
resolution | enum | no | 1K | 1K, 2K, 4K |
count | enum | no | 1 | 1, 2, 4, 6, 8, 10 |
imageUrlsSource Image | file (image[]) | no | — | — |
Output
generate() resolves once the job completes. One or more image URLs.
Result
{
"url": "https://cdn.picsart.com/…/result",
"results": [
{
"url": "https://cdn.picsart.com/…/result"
}
],
"model": "flux-2-flex"
}