Skip to content
b

flux-1-schnell Beta

Text-to-Imageblack-forest-labs
@cf/black-forest-labs/flux-1-schnell

FLUX.1 [schnell] is a 12 billion parameter rectified flow transformer capable of generating images from text descriptions.

    Usage

    Workers - TypeScript

    export interface Env {
    AI: Ai;
    }
    export default {
    async fetch(request, env): Promise<Response> {
    const inputs = {
    prompt: "cyberpunk cat",
    };
    const response = await env.AI.run(
    "@cf/black-forest-labs/flux-1-schnell",
    inputs
    );
    return new Response(response, {
    headers: {
    "content-type": "image/png",
    },
    });
    },
    } satisfies ExportedHandler<Env>;

    curl

    Terminal window
    curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/black-forest-labs/flux-1-schnell \
    -X POST \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
    -d '{ "prompt": "cyberpunk cat" }'

    Parameters

    Input

    • prompt string min 1

      A text description of the image you want to generate

    • num_steps integer default 4 max 8

      The number of diffusion steps; higher values can improve quality but take longer

    Output

    • image string

      The generated image in Base64 format.

    API Schemas

    The following schemas are based on JSON Schema

    {
    "type": "object",
    "properties": {
    "prompt": {
    "type": "string",
    "minLength": 1,
    "description": "A text description of the image you want to generate"
    },
    "num_steps": {
    "type": "integer",
    "default": 4,
    "maximum": 8,
    "description": "The number of diffusion steps; higher values can improve quality but take longer"
    }
    },
    "required": [
    "prompt"
    ]
    }