Quick start
Function AI lets you deploy Stable Diffusion image generation projects with a single click and manage the entire application lifecycle, from project development to API calls. This topic describes how to quickly deploy and use a Stable Diffusion WebUI text-to-image project.
The full lifecycle of an image generation application includes the project development phase and the API call phase.
-
Project development phase: After you deploy an image generation application in Function AI, you can debug prompts and workflows, install models and plugins, and generate images or videos that meet your expectations.
-
API call phase: After you set up the image generation environment by installing models, plugins, and dependencies in the development phase, you can publish the debugged workspace as an elastic, highly available Serverless API. Workflows can then run in this environment to efficiently generate images.
Prerequisites
-
We recommend an account balance of at least 100 CNY. To save costs, new customers can claim a free trial package.
Deploy a Stable Diffusion project
-
Log on to the Function Compute 3.0 console. In the left-side navigation pane, click Function AI. On the Function AI page, click Projects in the navigation bar, and then choose .
NoteIf Function Compute 3.0 is displayed in the upper-left corner, you are using the 3.0 console.
-
Set the project type to Stable Diffusion project, specify a project name, and select a region. Keep the default values for other settings, and then click Deploy Project.
Note-
GPU fees are based on serverless billing. The estimated cost displayed on the UI is for reference only. Actual charges are based on your usage.
-
If your users are in a specific geographic area, create the project in the corresponding region. If the GPU Specifications in the current region do not meet your requirements, select a different region.
-
-
In the Project Resource Preview dialog box, review the billing and resource usage for the products involved in this deployment, and then click Confirm Deployment.
-
After deployment, the workspace starts automatically, beginning the project development phase.
-
Starting the workspace launches a GPU instance. You can then download models, install plugins, debug prompts and workflows, and generate images and videos.
-
When you are finished, close the workspace promptly. After you close the workspace, the function instance is destroyed and billing stops. You must restart the workspace to use it again.
-
-
In the Stable Diffusion project workspace, set a prompt and click Generate to create an image.
On the txt2img tab, enter a positive and negative prompt. If needed, adjust generation parameters such as Sampling method, Sampling steps, Width, Height, and CFG Scale.
Generated images are saved to the
output/directory and can be accessed from the File Management tab. -
On the Stable Diffusion project development page, select the File Management tab and upload a custom model to the
models/directory.Use a custom model and adjust parameters such as Sampling method, Sampling steps, Hires. fix, and Seed to generate your desired image. You can then publish the API.
In the top navigation bar, click the File Management tab. On the file management page, click the models/ folder.
Publish an API
-
Publishing an API makes the current debugged workspace available. The workspace includes the source code, plugins, and dependencies required by Stable Diffusion.
-
Publishing an API creates a new function. You can configure new resource specifications and a scaling policy to enable elastic image generation with the Serverless API.
-
On the project development page, click Publish API in the upper-right corner.
-
In the Initialize API dialog box, select the GPU specifications, configure a scaling policy, and then click OK.
ImportantWhen you publish an API, a snapshot is enabled by default for the API call phase to reserve resources and prevent a cold start. Outside of image generation periods, a small snapshot fee applies. During image generation, billing is based on elastic instances. If you do not plan to use the Stable Diffusion project for a period of time, go to the API Call page, select the Configuration Management tab, and set the snapshot count to 0.
-
After the API is published, select the API Call tab. You can use cURL commands or third-party tools such as Postman to call the API to generate images.
Delete a project
-
Click the project name to go to the project details page, and then click Delete.
-
In the dialog box that appears, you can see the resources scheduled for deletion. By default, Function AI deletes all services under the project. To keep a resource, clear its checkbox. Only selected services will be deleted.
-
Select the "I understand that deleting this project and its selected services will immediately interrupt the online services they support. This action is irreversible and will permanently delete all dependent cloud resources." checkbox, and then click Confirm Deletion.