Skip to content
Black Forest Labs logo

FLUX 2 Klein 9B

Text-to-ImageBlack Forest LabsProxied

FLUX 2 Klein is Black Forest Labs' 9-billion parameter image generation model optimized for fast inference.

Model Info
Terms and Licenselink
More informationlink

Usage

TypeScript
const response = await env.AI.run(
'black-forest-labs/flux-2-klein-9b',
{
prompt: 'A golden retriever puppy playing in autumn leaves',
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Response 200 Simple Prompt

Examples

Detailed Scene — Complex scene with specific dimensions
TypeScript
const response = await env.AI.run(
'black-forest-labs/flux-2-klein-9b',
{
prompt:
'A Victorian-era street scene at dusk, gas lamps casting warm pools of light on cobblestones, horse-drawn carriages, and elegantly dressed pedestrians',
width: 1024,
height: 768,
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Response 200 Detailed Scene
High Quality Generation — More inference steps for better quality
TypeScript
const response = await env.AI.run(
'black-forest-labs/flux-2-klein-9b',
{
prompt:
'A detailed oil painting portrait of a Renaissance nobleman with intricate lace collar',
num_steps: 50,
guidance: 7.5,
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Response 200 High Quality Generation
Fast Draft — Quick generation with fewer steps
TypeScript
const response = await env.AI.run(
'black-forest-labs/flux-2-klein-9b',
{
prompt: 'A simple sketch of a mountain landscape',
num_steps: 10,
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Response 200 Fast Draft
Reproducible Generation — Using a seed for consistent results
TypeScript
const response = await env.AI.run(
'black-forest-labs/flux-2-klein-9b',
{
prompt:
'A serene Japanese zen garden with raked sand patterns and a single bonsai tree',
seed: 42,
num_steps: 25,
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Response 200 Reproducible Generation

Parameters

prompt
stringrequired
width
numberexclusiveMinimum: 0
height
numberexclusiveMinimum: 0
num_steps
numberexclusiveMinimum: 0
guidance
number
seed
number

API Schemas

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"prompt": {
"type": "string"
},
"width": {
"type": "number",
"exclusiveMinimum": 0
},
"height": {
"type": "number",
"exclusiveMinimum": 0
},
"num_steps": {
"type": "number",
"exclusiveMinimum": 0
},
"guidance": {
"type": "number"
},
"seed": {
"type": "number"
}
},
"required": [
"prompt"
],
"additionalProperties": false
}