All skills
Skillintermediate

RunwayML - Image Generation

| Property | Details | |-------|-------| | Description | RunwayML provides advanced AI-powered image generation with high-quality results | | Provider Route on LiteLLM | `runwayml/` | | Supported Operations | [`/images/generations`](#quick-start) | | Link to Provider Doc | [RunwayML API ↗](https://docs.dev.runwayml.com/) |

Claude Code Knowledge Pack7/10/2026

Overview

RunwayML - Image Generation

Overview

PropertyDetails
DescriptionRunwayML provides advanced AI-powered image generation with high-quality results
Provider Route on LiteLLMrunwayml/
Supported Operations/images/generations
Link to Provider DocRunwayML API ↗

LiteLLM supports RunwayML's Gen-4 image generation API, allowing you to generate high-quality images from text prompts.

Quick Start

from litellm import image_generation

os.environ["RUNWAYML_API_KEY"] = "your-api-key"

response = image_generation(
    model="runwayml/gen4_image",
    prompt="A serene mountain landscape at sunset",
    size="1920x1080"
)

print(response.data[0].url)

Authentication

Set your RunwayML API key:


os.environ["RUNWAYML_API_KEY"] = "your-api-key"

Supported Parameters

ParameterTypeRequiredDescription
modelstringYesModel to use (e.g., runwayml/gen4_image)
promptstringYesText description for the image
sizestringNoImage dimensions (default: 1920x1080)

Supported Sizes

  • 1024x1024
  • 1792x1024
  • 1024x1792
  • 1920x1080 (default)
  • 1080x1920

Async Usage

from litellm import aimage_generation

os.environ["RUNWAYML_API_KEY"] = "your-api-key"

async def generate_image():
    response = await aimage_generation(
        model="runwayml/gen4_image",
        prompt="A futuristic city skyline at night",
        size="1920x1080"
    )
    
    print(response.data[0].url)

asyncio.run(generate_image())

LiteLLM Proxy Usage

Add RunwayML to your proxy configuration:

model_list:
  - model_name: gen4-image
    litellm_params:
      model: runwayml/gen4_image
      api_key: os.environ/RUNWAYML_API_KEY

Start the proxy:

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

Generate images through the proxy:

curl --location 'http://localhost:4000/v1/images/generations' \\
--header 'Content-Type: application/json' \\
--header 'x-litellm-api-key: sk-1234' \\
--data '{
    "model": "runwayml/gen4_image",
    "prompt": "A serene mountain landscape at sunset",
    "size": "1920x1080"
}'

Supported Models

ModelDescriptionDefault Size
runwayml/gen4_imageHigh-quality image generation1920x1080

Cost Tracking

LiteLLM automatically tracks RunwayML image generation costs:

from litellm import image_generation, completion_cost

response = image_generation(
    model="runwayml/gen4_image",
    prompt="A serene mountain landscape at sunset",
    size="1920x1080"
)

cost = completion_cost(completion_response=response)
print(f"Image generation cost: ${cost}")

Supported Features

FeatureSupported
Image Generation
Cost Tracking
Logging
Fallbacks
Load Balancing

How It Works

RunwayML uses an asynchronous task-based API pattern. LiteLLM handles the polling and response transformation automatically.

Complete Flow Diagram

sequenceDiagram
    participant Client
    box rgb(200, 220, 255) LiteLLM AI Gateway
        participant LiteLLM
    end
    participant RunwayML as RunwayML API

    Client->>LiteLLM: POST /images/generations (OpenAI format)
    Note over LiteLLM: Transform to RunwayML format
    
    LiteLLM->>RunwayML: POST v1/text_to_image
    RunwayML-->>LiteLLM: 200 OK + task ID
    
    Note over LiteLLM: Automatic Polling
    loop Every 2 seconds
        LiteLLM->>RunwayML: GET v1/tasks/{task_id}
        RunwayML-->>LiteLLM: Status: RUNNING
    end
    
    LiteLLM->>RunwayML: GET v1/tasks/{task_id}
    RunwayML-->>LiteLLM: Status: SUCCEEDED + image URL
    
    Note over LiteLLM: Transform to OpenAI format
    LiteLLM-->>Client: Image Response (OpenAI format)

What LiteLLM Does For You

When you call litellm.image_generation() or /v1/images/generations:

  1. Request Transformation: Converts OpenAI image generation format → RunwayML format
  2. Submits Task: Sends transformed request to RunwayML API
  3. Receives Task ID: Captures the task ID from the initial response
  4. Automatic Polling:
    • Polls the task status endpoint every 2 seconds
    • Continues until status is SUCCEEDED or FAILED
    • Default timeout: 10 minutes (configurable via RUNWAYML_POLLING_TIMEOUT)
  5. Response Transformation: Converts RunwayML format → OpenAI format
  6. Returns Result: Sends unified OpenAI format response to client

Polling Configuration:

  • Default timeout: 600 seconds (10 minutes)
  • Configurable via RUNWAYML_POLLING_TIMEOUT environment variable
  • Uses sync (time.sleep()) or async (await asyncio.sleep()) based on call type

:::info Typical processing time: 10-30 seconds depending on image size and complexity :::