FLUX.2 klein 4B for Core AI on iPhone
black-forest-labs/FLUX.2-klein-4B (4B parameters, step-distilled text-to-image) exported to Apple Core AI for iOS with the apple/coreai-models recipe. It runs on iOS 27 and macOS 27 with the FlowTransformerPipeline from the CoreAIDiffusion product of coreai-models, and generates 512x512 images in 4 steps.
Files
ios/ holds the text-to-image components of the recipe's iOS export, 4-bit weights (4.0 GB):
| File | Size | |
|---|---|---|
Transformer_512.aimodel |
2.0 GB | DiT, 25 blocks, 512x512 |
TextEncoder.aimodel |
1.6 GB | Qwen3 text encoder |
VAEDecoder_half.aimodel |
95 MB | latent to 512x512 image |
tokenizer/, metadata.json, vae_bn_*.npy |
11 MB |
The image-to-image transformer and VAE encoder of the full iOS export are left out. The pipeline loads one component at a time by default (lazyModelLoading), so it fits in the memory an iPhone 17 Pro gives an app.
Use
With @react-native-ai/core-ai, download the ios folder and pass its path:
import { coreAI } from '@react-native-ai/core-ai'
import { generateImage } from 'ai'
const { image } = await generateImage({
model: coreAI.imageModel({
id: 'flux2-klein-4b',
source: { type: 'file', uri: fluxModelPath },
}),
prompt: 'a red apple on a wooden table',
size: '512x512',
seed: 42,
providerOptions: { 'core-ai': { stepCount: 4 } },
})
In Swift:
import CoreAIDiffusionPipeline
let pipeline = try await FlowTransformerPipeline(from: modelURL)
let configuration = PipelineConfiguration(
prompt: "a red apple on a wooden table",
seed: 42,
stepCount: 4,
guidanceScale: 1.0,
schedulerType: .discreteFlow
)
let image = try await pipeline.generateImages(configuration: configuration) { _ in true }.images[0]
Export
From apple/coreai-models at 5de95c6 (1.0.0), with coreai-core 1.0.0b3. This is --platform iOS (4-bit, single-function, 512) without the image-to-image components:
uv run coreai.diffusion.export flux2-klein-4b --single-function \
--components transformer_512 text_encoder vae_decoder_half
License
Apache-2.0, as the original model. The weights were converted to Core AI and quantized to 4 bits, and are otherwise unchanged. FLUX.2 [klein] is by Black Forest Labs.
Model tree for grabbou/FLUX.2-klein-4B-CoreAI
Base model
black-forest-labs/FLUX.2-klein-4B