Updated on 2025-07-10 GMT+08:00

Deploying and Using the Stable Diffusion Application

Use the Stable-Diffusion template to create an application and configure the required agency. After the application is created, you can use the built-in default models and temporary domain names.

Step 1: Creating a Cloud Service Agency for FunctionGraph

To deploy a Stable Diffusion application, you need to configure an agency for FunctionGraph to allow it to use other cloud services.

  1. Log in to the IAM console. In the navigation pane, choose Agencies. On the Agencies page that is displayed, click Create Agency in the upper right corner.
  2. Set the following parameters:

    • Agency Name: Enter serverless_trust.
    • Agency Type: Select Cloud service.
    • Cloud Service: Select FunctionGraph.
    • Validity Period: Select Unlimited.
    • (Optional) Description: Enter Stable Diffusion.

  3. Click OK. The system displays a message indicating that the creation is successful. Click Authorize.
  4. On the Select Policy/Role page, search for the policies listed in Table 1 as required, select them, and click Next.

    Table 1 Policies and related description

    Policy

    Description

    Mandatory

    SWR Admin

    SoftWare Repository for Container (SWR) administrator with full permissions.

    Yes

    VPC Administrator

    (The system will select the Server Administrator system role that the system role depends on. You do not need to manually cancel the selection.)

    VPC Administrator: administrator of the VPC service.

    Server Administrator: server administrator.

    Mandatory for uploading and using a custom model.

    SFS FullAccess

    Full permissions for SFS

    Mandatory for mounting an SFS file system.

    SFS Turbo FullAccess

    Full permissions for SFS Turbo.

    Mandatory for mounting an SFS file system.

  5. On the Select Scope page shown in Figure 1, select Region-specific projects, select cn-east-3 [CN East-Shanghai1], and click OK.

    Figure 1 Region-specific projects

  6. After the authorization is successful, click Finish to view the authorization record.

Step 2: Buying a Dedicated Gateway

Buy a dedicated gateway based on your service requirements. For details, see Creating a Gateway. Pay attention to the following configuration during the purchase:
  • Region: CN East-Shanghai1
  • AZ: The AZ must be the same as that of the created subnet. In this example, AZ 1 is used.
  • Public Inbound Access: In this example, enable the public inbound access. Select the bandwidth as required.

Step 3: Creating an Application Using the Stable Diffusion Template

  1. Log in to the FunctionGraph console and select CN East-Shanghai1 region. In the navigation pane on the left, choose Applications. In the upper right corner, click Create. The page for selecting a template is displayed.
  2. As shown in Figure 2, find the AI Drawing Stable-Diffusion template and click Create Application. Read the displayed description carefully, select the check box, and click Agree and Continue.

    Figure 2 Selecting the AI Drawing Stable-Diffusion template

    If the Service Subscription dialog box is displayed, read the description and click Enable Now.

  3. On the Configure Application page, set application parameters as shown in Figure 3. After setting the parameters, click Create Now in the lower right corner of the page.

  4. Wait until the application is created. The application contains resources such as functions, API gateways, and triggers, as shown in Figure 4. For details about the key resources of FunctionGraph, see Table 2.

    To make it easier for you to experience the feature, a temporary domain name is allocated to you. The temporary domain name can be used only for testing and is valid for 30 days. To allow long-term access to applications, bind a custom domain name. For details, see (Optional) Binding a Custom Domain Name.
    Figure 4 Application created
    Table 2 Key function services

    Resource Logical Name

    Description

    stable_diffusion

    Accesses the Stable Diffusion WebUI through the APIG trigger.

    custom_models_tool

    Manages Stable Diffusion resources (uploading models and plug-ins and downloading images) via the APIG trigger.

Step 3: Using the Default Model and Temporary Domain Name for AI Drawing

  1. On the application details page shown in Figure 5, click Access Application. The Stable Diffusion WebUI page is displayed. The first cold start takes about 30 seconds. If the loading times out, refresh the page.

    Figure 5 Accessing the application

  2. On the txt2img tab page, enter the corresponding prompt word and reverse prompt (in both Chinese and English), and click Generate on the right. An image that matches the prompt word description is generated.

    Figure 6 Stable Diffusion WebUI

    The application created in the preceding steps can only use the default model built in the application for AI drawing. If you want to use more custom models, you need to mount an external file system to the application. For details, see (Optional) Uploading a Custom Model.