> ## Documentation Index
> Fetch the complete documentation index at: https://runcrate.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Generation

> Generate images from text prompts using FLUX, Stable Diffusion, and more.

export const RuncrateStyles = () => {
  if (typeof document !== 'undefined' && !document.getElementById('runcrate-overrides')) {
    const s = document.createElement('style');
    s.id = 'runcrate-overrides';
    s.textContent = `
      /* Match Runcrate's rounding scale (--radius: 0.75rem) */
      .rounded-sm { border-radius: 0.5rem !important; }   /* 8px */
      .rounded-md { border-radius: 0.625rem !important; } /* 10px */
      .rounded-lg { border-radius: 0.75rem !important; }  /* 12px */
      .rounded-l-sm { border-top-left-radius: 0.5rem !important; border-bottom-left-radius: 0.5rem !important; }
      .rounded-r-sm { border-top-right-radius: 0.5rem !important; border-bottom-right-radius: 0.5rem !important; }
      .rounded-l-md { border-top-left-radius: 0.625rem !important; border-bottom-left-radius: 0.625rem !important; }
      .rounded-r-md { border-top-right-radius: 0.625rem !important; border-bottom-right-radius: 0.625rem !important; }
      .rounded-l-lg { border-top-left-radius: 0.75rem !important; border-bottom-left-radius: 0.75rem !important; }
      .rounded-r-lg { border-top-right-radius: 0.75rem !important; border-bottom-right-radius: 0.75rem !important; }

      /* Cards: never pure white in light mode */
      .card { background-color: #fcfcfc !important; border-radius: 0.75rem !important; }
      html.dark .card { background-color: #141414 !important; }

      /* Docs hero box */
      .rc-hero { background-color: #fcfcfc; border: 1px solid #e0e0e0; }
      html.dark .rc-hero { background-color: #141414; border-color: #242424; }
      html.dark .rc-hero h1 { color: #f5f5f5; }

      /* Runcrate scrollbar — thin, transparent track, hide-until-hover thumb */
      ::-webkit-scrollbar { width: 6px; height: 6px; background-color: transparent; }
      ::-webkit-scrollbar-track { background-color: transparent; }
      ::-webkit-scrollbar-thumb { background-color: rgba(155, 155, 155, 0.5); border-radius: 10px; transition: opacity 0.3s ease; opacity: 0; }
      ::-webkit-scrollbar-thumb:hover { background-color: rgba(155, 155, 155, 0.7); }
      *:hover::-webkit-scrollbar-thumb,
      *:focus::-webkit-scrollbar-thumb,
      *:active::-webkit-scrollbar-thumb { opacity: 1; }
      * { scrollbar-width: thin; scrollbar-color: rgba(155, 155, 155, 0.5) transparent; }
    `;
    document.head.appendChild(s);
  }
  return null;
};

<RuncrateStyles />

Generate images from text prompts using models like FLUX.1, FLUX.2, and others.

## Endpoint

```
POST https://api.runcrate.ai/v1/images/generations
```

## Basic Usage

<CodeGroup>
  ```bash curl theme={"theme":"github-dark"}
  curl https://api.runcrate.ai/v1/images/generations \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer rc_live_YOUR_API_KEY" \
    -d '{
      "model": "black-forest-labs/FLUX.1-schnell",
      "prompt": "A futuristic cityscape at sunset, cyberpunk style",
      "aspect_ratio": "16:9"
    }'
  ```

  ```python Python theme={"theme":"github-dark"}
  from openai import OpenAI

  client = OpenAI(
      base_url="https://api.runcrate.ai/v1",
      api_key="rc_live_YOUR_API_KEY",
  )

  response = client.images.generate(
      model="black-forest-labs/FLUX.1-schnell",
      prompt="A futuristic cityscape at sunset, cyberpunk style",
  )
  print(response.data[0].url)
  ```

  ```javascript JavaScript theme={"theme":"github-dark"}
  import OpenAI from "openai";

  const client = new OpenAI({
    baseURL: "https://api.runcrate.ai/v1",
    apiKey: "rc_live_YOUR_API_KEY",
  });

  const response = await client.images.generate({
    model: "black-forest-labs/FLUX.1-schnell",
    prompt: "A futuristic cityscape at sunset, cyberpunk style",
  });
  console.log(response.data[0].url);
  ```
</CodeGroup>

## Parameters

Parameters vary by model. Common parameters include:

| Parameter             | Type    | Description                                              |
| --------------------- | ------- | -------------------------------------------------------- |
| `model`               | string  | Model ID (required)                                      |
| `prompt`              | string  | Text description of the image (required)                 |
| `aspect_ratio`        | string  | Output ratio: `1:1`, `16:9`, `9:16`, `4:3`, `3:2`, etc.  |
| `num_inference_steps` | integer | Number of diffusion steps (higher = more detail, slower) |
| `guidance`            | number  | How closely to follow the prompt                         |
| `seed`                | integer | Reproducibility seed (omit for random)                   |
| `negative_prompt`     | string  | What to avoid in the image                               |

### Model-Specific Parameters

Some models support additional inputs:

* **FLUX Kontext models**: Accept `input_image` for image editing
* **FLUX Canny**: Requires `control_image` for edge-guided generation
* **FLUX.2 Pro**: Accepts up to 8 `input_images` for reference-based generation
* **FLUX Dev/Krea**: Accept `image` for img2img mode with `prompt_strength` control

Check the [Playground](/models/playground) to see the exact parameters available for each model.

## Response

```json theme={"theme":"github-dark"}
{
  "data": [
    {
      "url": "https://...",
      "b64_json": "..."
    }
  ]
}
```

The response includes either a `url` to the generated image or `b64_json` base64-encoded image data.

## Available Image Models

| Model              | Speed  | Quality   | Notes                         |
| ------------------ | ------ | --------- | ----------------------------- |
| **FLUX.1 Schnell** | Fast   | Good      | Best for rapid prototyping    |
| **FLUX.1 Dev**     | Medium | High      | Open-weights, img2img support |
| **FLUX.1 Pro**     | Medium | Very High | Production-grade              |
| **FLUX.1.1 Pro**   | Medium | Very High | Updated Pro model             |
| **FLUX.2 Pro**     | Medium | Highest   | Up to 4MP, multi-reference    |
| **FLUX Kontext**   | Medium | High      | Image editing and generation  |
