All skills
Skillintermediate

Fal AI

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

Claude Code Knowledge Pack7/10/2026

Overview

Fal AI

Fal AI provides fast, scalable access to state-of-the-art image generation models including FLUX, Stable Diffusion, Imagen, and more.

Overview

PropertyDetails
DescriptionFal AI offers optimized infrastructure for running image generation models at scale with low latency.
Provider Route on LiteLLMfal_ai/
Provider DocFal AI Documentation ↗
Supported Operations/images/generations

Setup

API Key


# Set your Fal AI API key
os.environ["FAL_AI_API_KEY"] = "your-fal-api-key"

Get your API key from fal.ai.

Supported Models

Model NameDescriptionDocumentation
fal_ai/fal-ai/flux-pro/v1.1FLUX Pro v1.1 - Balanced speed and qualityDocs ↗
fal_ai/flux/schnellFlux Schnell - Low-latency generation with image_size supportDocs ↗
fal_ai/fal-ai/bytedance/seedream/v3/text-to-imageByteDance Seedream v3 - Text-to-image with image_size controlDocs ↗
fal_ai/fal-ai/bytedance/dreamina/v3.1/text-to-imageByteDance Dreamina v3.1 - Text-to-image with image_size controlDocs ↗
fal_ai/fal-ai/flux-pro/v1.1-ultraFLUX Pro v1.1 Ultra - High-quality image generationDocs ↗
fal_ai/fal-ai/imagen4/previewGoogle's Imagen 4 - Highest quality modelDocs ↗
fal_ai/fal-ai/recraft/v3/text-to-imageRecraft v3 - Multiple style optionsDocs ↗
fal_ai/fal-ai/ideogram/v3Ideogram v3 - Lettering-first creative model (Balanced: $0.06/image)Docs ↗
fal_ai/fal-ai/stable-diffusion-v35-mediumStable Diffusion v3.5 MediumDocs ↗
fal_ai/bria/text-to-image/3.2Bria 3.2 - Commercial-grade generationDocs ↗

Image Generation

Usage - LiteLLM Python SDK


# Set your API key
os.environ["FAL_AI_API_KEY"] = "your-fal-api-key"

# Generate an image
response = litellm.image_generation(
    model="fal_ai/fal-ai/flux-pro/v1.1-ultra",
    prompt="A serene mountain landscape at sunset with vibrant colors"
)

print(response.data[0].url)

os.environ["FAL_AI_API_KEY"] = "your-fal-api-key"

# Generate with Imagen 4
response = litellm.image_generation(
    model="fal_ai/fal-ai/imagen4/preview",
    prompt="A vintage 1960s kitchen with flour package on countertop",
    aspect_ratio="16:9",
    num_images=1
)

print(response.data[0].url)

os.environ["FAL_AI_API_KEY"] = "your-fal-api-key"

# Generate with specific style
response = litellm.image_generation(
    model="fal_ai/fal-ai/recraft/v3/text-to-image",
    prompt="A red panda eating bamboo",
    style="realistic_image",
    image_size="landscape_4_3"
)

print(response.data[0].url)

async def generate_image():
    os.environ["FAL_AI_API_KEY"] = "your-fal-api-key"
    
    response = await litellm.aimage_generation(
        model="fal_ai/fal-ai/stable-diffusion-v35-medium",
        prompt="A cyberpunk cityscape with neon lights",
        guidance_scale=7.5,
        num_inference_steps=50
    )
    
    print(response.data[0].url)
    return response

asyncio.run(generate_image())

os.environ["FAL_AI_API_KEY"] = "your-fal-api-key"

# Generate with advanced parameters
response = litellm.image_generation(
    model="fal_ai/fal-ai/flux-pro/v1.1-ultra",
    prompt="A majestic dragon soaring over mountains",
    n=2,
    size="1792x1024",  # Maps to aspect_ratio="16:9"
    seed=42,
    safety_tolerance="2",
    enhance_prompt=True
)

for image in response.data:
    print(f"Generated image: {image.url}")

Usage - LiteLLM Proxy Server

1. Configure your config.yaml

model_list:
  - model_name: flux-ultra
    litellm_params:
      model: fal_ai/fal-ai/flux-pro/v1.1-ultra
      api_key: os.environ/FAL_AI_API_KEY
    model_info:
      mode: image_generation
  
  - model_name: imagen4
    litellm_params:
      model: fal_ai/fal-ai/imagen4/preview
      api_key: os.environ/FAL_AI_API_KEY
    model_info:
      mode: image_generation
  
  - model_name: stable-diffusion
    litellm_params:
      model: fal_ai/fal-ai/stable-diffusion-v35-medium
      api_key: os.environ/FAL_AI_API_KEY
    model_info:
      mode: image_generation

general_settings:
  master_key: sk-1234

2. Start LiteLLM Proxy Server

litellm --config /path/to/config.yaml

# RUNNING on http://0.0.0.0:4000

3. Make requests

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:4000",
    api_key="sk-1234"
)

response = client.images.generate(
    model="flux-ultra",
    prompt="A beautiful sunset over the ocean",
    n=1,
    size="1024x1024"
)

print(response.data[0].url)

response = litellm.image_generation(
    model="litellm_proxy/imagen4",
    prompt="A cozy coffee shop interior",
    api_base="http://localhost:4000",
    api_key="sk-1234"
)

print(response.data[0].url)
curl --location 'http://localhost:4000/v1/images/generations' \\
--header 'Content-Type: application/json' \\
--header 'Authorization: Bearer sk-1234' \\
--data '{
    "model": "stable-diffusion",
    "prompt": "A serene Japanese garden with cherry blossoms",
    "n": 1,
    "size": "1024x1024"
}'

Using Model-Specific Parameters

LiteLLM forwards any additional parameters directly to the Fal AI API. You can pass model-specific parameters in your request and they will be sent to Fal AI.


# Any parameters beyond the standard ones are forwarded to Fal AI
response = litellm.image_generation(
    model="fal_ai/fal-ai/flux-pro/v1.1-ultra",
    prompt="A beautiful sunset",
    # Model-specific Fal AI parameters
    aspect_ratio="16:9",
    safety_tolerance="2",
    enhance_prompt=True,
    seed=42
)

For the complete list of parameters supported by each model, see:

Supported Parameters

Standard OpenAI-compatible parameters that work across all models:

ParameterTypeDescriptionDefault
promptstringText description of desired imageRequired
modelstringFal AI model to useRequired
nintegerNumber of images to generate (1-4)1
sizestringImage dimensions (maps to model-specific format)Model default
api_keystringYour Fal AI API keyEnvironment variable

Getting Started

  1. Sign up at fal.ai
  2. Get your API key from your account settings
  3. Set FAL_AI_API_KEY environment variable
  4. Choose a model from the Fal AI model gallery
  5. Start generating images with LiteLLM

Additional Resources