# Stability AI

The Stability AI piece in ZBrain Flow enables AI-powered image generation and custom API interactions. This integration allows you to generate high-quality images from text descriptions or interact directly with Stability AI’s API for advanced customization. By using Stability AI in your workflows, you can automate image creation and integrate AI-driven visuals seamlessly into your applications.

### **How to Use Stability AI in ZBrain Flow** <a href="#how-to-use-stability-ai-in-zbrain-flow" id="how-to-use-stability-ai-in-zbrain-flow"></a>

**Select Stability AI as Your Connection**

1. Click on the ‘+’ button in the Flow.
2. Search for ‘Stability AI’ and select it.
3. Choose the action you want to perform. ZBrain Flow provides the following options:
   * **‘Text to Image’ –** Generate an image from a text prompt.
   * **‘Custom API Call’ –** Send a request to a specific Stability AI API endpoint.

### **How to Generate Images Using Stability AI in ZBrain Flow** <a href="#how-to-generate-images-using-stability-ai-in-zbrain-flow" id="how-to-generate-images-using-stability-ai-in-zbrain-flow"></a>

**Step 1: Create a Stability AI Connection**

1. In the ‘Connection’ dropdown, click on 'create connection'.
2. A small window will appear. Fill in the following details:
   * **‘Connection Name’ –** Enter a name for this Stability AI connection.
   * **‘API Key’ –** Obtain your API key from [Stability AI’s authentication guide](https://platform.stability.ai/docs/getting-started/authentication) and enter it here.
3. Click ‘Save’.

**Step 2: Configure the Image Generation Request**

1. In the ‘Prompt’ field, enter a text description of the image you want to generate.
2. (Optional) Adjust advanced settings:
   * ‘cfg\_scale’ – Controls how closely the image adheres to the prompt (Range: 0–35, default: 7).
   * ‘height’ and ‘width’ – Define image dimensions in increments of 64 (minimum: 128 pixels).
   * ‘samples’ – Set the number of images to generate (maximum: 10).
   * ‘steps’ – Specify the number of diffusion steps (Range: 10–150).
   * ‘weight’ – Adjusts the influence of the prompt.
   * ‘clip\_guidance\_preset’ – Select additional guidance for image generation.
   * ‘style\_preset’ – Apply a predefined artistic style (Photographic, anime, fantasy art).
   * ‘Engine ID’ – Choose the Stability AI model to use for generation.

### **How to Use Stability AI Custom API Call in ZBrain Flow** <a href="#how-to-use-stability-ai-custom-api-call-in-zbrain-flow" id="how-to-use-stability-ai-custom-api-call-in-zbrain-flow"></a>

**Step 1: Create a Stability AI Connection**

Follow the steps from the ‘Step 1: Create a Stability AI Connection’ section above to set up your Stability AI connection.

**Step 2: Set Up the API Request**

1. In the ‘URL’ field, enter the base API URL: '<https://api.stability.ai/v1>'. Add the specific API endpoint you want to use, such as '/models' for retrieving available models.
2. From the ‘Method’ dropdown, choose the HTTP method (GET, POST, etc.) based on the API call’s requirements.

**Step 3: Configure Request Parameters**

1. Headers – Click ‘Add Item’ to include any additional headers. Note that authorization headers are automatically added from your connection.
2. Query Parameters – Click ‘Add Item’ to include optional filters or settings.
3. Body – If the API request requires a request body, add the necessary JSON structure.

**Step 4: Set Additional Options**

1. ‘No Error on Failure’ – Enable this if you want the workflow to continue even if the API call encounters an error.
2. ‘Timeout (in seconds)’ – Set the maximum wait time before the request times out.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zbrain.ai/zbrain-documentation/zbrain-builder/flows/flow-components/stability-ai.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
