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

# gRPC API parameters

> Reference for legacy gRPC API generation parameters, including dimensions, steps, CFG scale, engines, samplers, and seeds.

> [!WARNING]
>
> The gRPC API is in legacy maintenance mode and won't receive new features. For new projects, use the [REST v2beta API](https://docs.stability.ai/api-reference/generate/stable-image-ultra.md).

When calling the gRPC API, `prompt` is the only required variable. Provided alone, this call will generate an image according to our default generation settings.

The gRPC response will contain a `finish_reason` specifying the outcome of your request in addition to the delivered asset. If the `finish_reason` is `filter`, this means our safety filter has been activated and the resulting image will be blurred. This is by design.

These calls can be assigned a variety of parameters, some of which have an effect on pricing, as detailed below.

### Prompt

Accepts singular as well as multiple prompts with weights. See the [Multi-prompting](https://docs.stability.ai/legacy/grpc-api/features/multi-prompting.md) documentation for more information.

| Parameter | Default | Affects Pricing? |
| - | - | - |
| `prompt` | none | No |

### Height

Measured in pixels. Pixel limit is `1048576`, so technically any dimension is allowable within that amount.

| Parameter | Default | Typical | Allowable | Affects Pricing? |
| - | - | - | - | - |
| `height` | 512 | 512 | [See Below](#about-dimensions) | Yes |

### Width

Measured in pixels. Pixel limit is `1048576`, so technically any dimension is allowable within that amount.

| Parameter | Default | Typical | Allowable | Affects Pricing? |
| - | - | - | - | - |
| `width` | 512 | 512 | [See Below](#about-dimensions) | Yes |

### About Dimensions

A minimum of `262k` pixels and a maximum of `1.04m` pixels are recommended when generating images with `512px` models, and a minimum of `589k` pixels and a maximum of `1.04m` pixels for `768px` models. The true pixel limit is `1048576`.

To avoid the dreaded `6N IndexError` it is advised to use `64px` increments when choosing an aspect ratio. Popular ratio combinations for `512px` models include `1536 x 512` and `1536 x 384`, while `1536 x 640` and `1024 x 576` are recommended for `768px` models.

For `512px` models, the minimum useful sizes are `192-256` in one dimension. For `768px` models the minimum useful size is `384` in one dimension.

Generating images under the recommended dimensions may result in undesirable artifacts.

### Steps

Affects the number of diffusion steps performed on the requested generation.

| Parameter | Default | Typical | Allowable | Affects Pricing? |
| - | - | - | - | - |
| `steps` | 30 | 30-50 | 10-150 | Yes |

### Samples

Number of images to generate. Allows for batch image generations.

| Parameter | Default | Typical | Allowable | Affects Pricing? |
| - | - | - | - | - |
| `num_samples` | 1 | 1-9 | 1-10 | Yes |

### CFG Scale

Dictates how closely the engine attempts to match a generation to the provided prompt. v2-x models respond well to lower CFG (IE: 4-8), where as v1-x models respond well to a higher range (IE: 7-14) and SDXL models respond well to a wider range (IE: 4-12).

| Parameter | Default | Typical | Allowable | Affects Pricing? |
| - | - | - | - | - |
| `cfg_scale` | 7.0 | 4-14 | 1-35 | No |

### Engine

Engine (model) to use. Available engines:

***Note: The models below have special pricing considerations. For additional information please check out the [Pricing](https://docs.stability.ai/pricing.md) page.***

* (`SDXL`) `stable-diffusion-xl-1024-v0-9`
* (`SDXL`) `stable-diffusion-xl-1024-v1-0`
* `esrgan-v1-x2plus`

***Note: Engines in the list below are now deprecated and can no longer be accessed. Please use one of the models listed above.***

* `stable-diffusion-v1`
* `stable-diffusion-v1-5`
* `stable-diffusion-512-v2-0`
* `stable-diffusion-768-v2-0`
* `stable-diffusion-512-v2-1`
* `stable-diffusion-768-v2-1`
* `stable-diffusion-xl-beta-v2-2-2`
* `stable-inpainting-v1-0`
* `stable-inpainting-512-v2-0`
* `stable-diffusion-x4-latent-upscaler`

| Parameter | Default | Typical | Allowable | Affects Pricing? |
| - | - | - | - | - |
| `engine` | `stable-diffusion-xl-1024-v0-9` | `stable-diffusion-xl-1024-v0-9` | [See Above](#engine) | [See Above](#engine) |

### Image Upscaler

Dictates the parameters sent to our image upscaling engine. Check out the examples on our Image Upscaling documentation to learn how to execute an image upscaling call via our gRPC API.

| Parameter | Default | Typical | Allowable | Affects Pricing? |
| - | - | - | - | - |
| `stability_api.upscale` | init\_image= | init\_image= | init\_image=, width= **or** height= (but not both) | Yes |

### Sampler

Sampling engine to use. If no sampler is declared, an appropriate default sampler for the declared inference engine will be applied automatically.

Available samplers:

* `ddim`
* `plms`
* `k_euler`
* `k_euler_ancestral`
* `k_heun`
* `k_dpm_2`
* `k_dpm_2_ancestral`
* `k_dpmpp_2s_ancestral`
* `k_dpmpp_2m`
* `k_dpmpp_sde`

| Parameter | Default | Typical | Allowable | Affects Pricing? |
| - | - | - | - | - |
| `sampler` | `k_dpmpp_2m` | `k_dpmpp_2m` | Check Comments | No |

### Seed

Seed for random latent noise generation. Deterministic if not being used in concert with CLIP Guidance. If not specified, or set to `0`, then a random value will be used.

| Parameter | Default | Allowable | Affects Pricing? |
| - | - | - | - |
| `seed` | 0 (random) | 0 - 2147483647 | No |

### Initial Image

Image used to initialize the diffusion process, in lieu of random noise.

| Parameter | Default | Typical | Allowable | Affects Pricing? |
| - | - | - | - | - |
| `init_image` | none | PNG | PNG | No |

### Mask Image

Grayscale mask to exclude diffusion from some pixels. Must be the same dimensions as `init_image`.

| Parameter | Default | Typical | Allowable | Affects Pricing? |
| - | - | - | - | - |
| `mask_image` | none | PNG | PNG | No |

### Start Schedule

Skips a proportion of the start of the diffusion steps, allowing the `init_image` to influence the final generated image. Lower values will result in more influence from the `init_image`, while higher values will result in more influence from the diffusion steps. (e.g. a value of 0 would simply return you the `init_image`, where a value of 1 would return you a completely different image.)

| Parameter | Default | Typical | Allowable | Affects Pricing? |
| - | - | - | - | - |
| `start_schedule` | 0 | 0.6 | 0.0 - 1.0 | No |

### End Schedule

Skips a proportion of the end of the diffusion steps, allowing the `init_image` to influence the final generated image. Lower values will result in more influence from the `init_image`, while higher values will result in more influence from the diffusion steps.

| Parameter | Default | Typical | Allowable | Affects Pricing? |
| - | - | - | - | - |
| `end_schedule` | 0 | 0.1 | 0.0 - 1.0 | No |

### CLIP Guidance

CLIP guidance preset, use with ancestral sampler for best results.

| Parameter | Default | Typical | Allowable | Affects Pricing? |
| - | - | - | - | - |
| `guidance_preset` | none | generation.GUIDANCE\_PRESET\_FAST\_GREEN | \_NONE \_FAST\_GREEN \_FAST\_BLUE | No |

### Prefix

SDK CLI switch for assigning artifact prefixes.

| Parameter | Default | Affects Pricing? |
| - | - | - |
| `prefix` | --prefix | No |

### Store

SDK CLI switch indicating whether to write out artifacts.

| Parameter | Default | Affects Pricing? |
| - | - | - |
| no-store | --no-store | No |

### Show

SDK CLI switch for opening artifacts using PIL.

| Parameter | Default | Affects Pricing? |
| - | - | - |
| `show` | --show | No |

**Note:** This is a living page and may not be representative of all of the parameters currently available for image generation.

Please check out our [protobuf reference](https://github.com/Stability-AI/api-interfaces/blob/main/src/proto/generation.proto) for a complete list of parameters available for image generation.
