> Source: https://meetrix.io/blogs/how-to-set-up-fooocus-api-configuration-aws-developer-guide/
> Markdown copy of that page. Cite the URL above, not this file.

AI Image Tools

# How to Set up Fooocus with API Configuration on AWS - Developer Guide

[By Dinesh Chathuranga](https://meetrix.io/blogs/authors/dinesh-chathuranga/) • October 16, 2023 • 13 min read

Welcome to the Fooocus 2.0 Setup Guide, your key to unlocking the full potential of our AI-powered image creation tool. In this step-by-step guide, we'll walk you through the seamless installation process.

### Video

### Blog

[

How to 1 Click Install Fooocus AI on AWS: The Ultimate Image Generator

Explore Fooocus, the forefront of AI-driven image generation, offering unparalleled efficiency and a user-friendly interface. Perfect for creatives in the UK, USA, Europe, Ireland, Singapore, and Thailand, embrace the future of digital artistry and step into a new era of image creation.

Meetrix.IO | Kelum Sampath

![How to 1 Click Install Fooocus AI on AWS](https://meetrix.io/blog-images/paas-products-articles/how-to-install-fooocus-on-aws/how-to-install-fooocus-on-aws.png)](https://meetrix.io/blogs/how-to-install-fooocus-aws/)

### Learn more on Linkedin

[

How to Simply Set Up Fooocus 2.0 in Self Hosted on AWS

In the digital frontier, AI image generation stands as a testament to how far technology has advanced in understanding and replicating the nuances of human creativity. This rapidly advancing field allows us to convert complex ideas into vivid visuals, streamlining workflows across various industries.

Meetrix.IO | Published Nov 15, 2023

![How to Simply Set Up Fooocus 2.0 on AWS](https://meetrix.io/blog-images/paas-dev-guides/how-to-simply-setup-fooocus/how-to-simply-setup-fooocus.png)](https://www.linkedin.com/pulse/how-simply-set-up-fooocus-self-hosted-aws-meetrixio-e6rnc/)

Prerequisites

Before you begin, ensure you have the following prerequisites in place:

-   Basic knowledge of AWS services (EC2 and CloudFormation).
-   An active AWS account.
-   Equipped with necessary vCPU quota for your selected instance type. Read how to increase AWS vCPU quota here: [https://meetrix.io/blogs/increase-aws-vcpu-quota/](https://meetrix.io/blogs/increase-aws-vcpu-quota/)

## Launching the AMI

### Step 1: Find and Select 'Fooocus 2.0' AMI

1.  Log in to your AWS Management Console.
2.  Navigate to the "[Fooocus 2.0](https://aws.amazon.com/marketplace/pp/prodview-4xzjmoi4f3ml4)" in AWS Marketplace.

### Step 2: Initial Setup and Configuration

1.  Click the **"Continue to Subscribe"** button.
2.  After subscribing, you will need to accept the terms and conditions. Click on **"Accept Terms"** to proceed.
3.  Please wait for a few minutes while the processing takes place. Once it's completed, click on **"Continue to Configuration"**.
4.  Select the **"CloudFormation Template for fooocus"** as the fulfilment option and choose your preferred region on the "Configure this software" page. Afterward, click the **"Continue to Launch"** button.
5.  From the "Choose Action" dropdown menu in "Launch this software" page, select **"Launch CloudFormation"** and click **"Launch"** button.

## Create CloudFormation Stack

### Step 1: Create Stack

1.  Ensure the **"Template is ready"** radio button is selected under "Prepare template".
2.  Click **"Next"**.

### Step 2: Specify Stack Options

1.  Provide a unique **"Stack name"**.
2.  Provide the **"Admin Email"** for SSL generation.
3.  For **"DeploymentName"**, enter a name of your choice.
4.  Provide the domain name for **"FooocusDomainName"**. (Fooocus will automatically try to setup SSL based on provided domain name, if that domain is hosted on Route 53. Please make sure your domain name is hosted on Route 53. If it's unsuccessful then you have to setup SSL manually.)
5.  Choose an instance type, **"FooocusInstanceType"** (Recommended: `g4dn.2xlarge`).
6.  Select your preferred **"keyName"**.
7.  Set **"SSHLocation"** as `0.0.0.0/0`.
8.  Keep **"SubnetCidrBlock"** as `10.0.0.0/24`.
9.  Keep **"VpcCidrBlock"** as `10.0.0.0/16`.
10.  Click **"Next"**.

### Step 3: Configure Stack Options

1.  Under "Stack failure options", select **"Roll back all stack resources"**.
2.  Click **"Next"**.

### Step 4: Review

1.  Review and verify the details you've entered.

![CloudFormation stack parameters for Fooocus](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus-01.png)

2.  Tick the box that says, **"I acknowledge that AWS CloudFormation might create IAM resources with custom names"**.

![Acknowledge IAM resources checkbox for Fooocus CloudFormation stack](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus-02.png)

3.  Click **"Submit"**.

Afterward, you'll be directed to the CloudFormation stacks page. You can easily locate the corresponding stack by searching for the stack name you entered in Step 2. Please wait for 5-10 minutes until the stack has been successfully created. Afterward, you can click the "Refresh" button under the "Stacks" section.

![CloudFormation stack CREATE\_COMPLETE status for Fooocus](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus-03.png)

## Access Fooocus Dashboard

### Method 1: Using Public IP

Click the link located under the **"DashboardUrlIp"** section in the **"Outputs"** tab. This will direct you to the Fooocus Dashboard.

![Outputs tab showing the DashboardUrlIp link for Fooocus](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus-04.png) ![Fooocus dashboard accessed via public IP](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus-05.png)

### Method 2: Using Domain

1.  Copy the Public IP address indicated as **"PublicIp"** in the **"Outputs"** tab.

![Outputs tab showing the PublicIp value for Fooocus](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus-06.png)

2.  Go to AWS "Route 53" and navigate to "Hosted Zones".
3.  From there, select the domain you provided to **"FooocusDomainName"**.

![Route 53 hosted zone record for the Fooocus domain](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus-07.png)

4.  Click **"Edit record"** in the "Record details" and then paste the copied **"PublicIp"** into the **"value"** textbox and click "Save".

![Editing the Route 53 record value for Fooocus](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus-08.png)

5.  Open a new tab and navigate to the **"FooocusDomainName"** to access the Fooocus dashboard.

502 Bad Gateway Error?

If you encounter a "502 Bad Gateway" error, please wait for about 5 minutes before refreshing the page.

## Generate SSL Manually

Fooocus will automatically try to setup SSL based on the provided domain name, if that domain is hosted on Route 53. If it's unsuccessful then you have to setup SSL manually. Admin Email is required to generate SSL certificates.

### Step 1: Point Domain Name to Server IP

Follow steps 1 to 4 in the **"Method 2: Using Domain"** section mentioned above, under **"Access Fooocus Dashboard"**, to point the domain name to the server's IP.

### Step 2: Log in to the Server

1.  Copy the Public IP address indicated as **"PublicIp"** in the **"Outputs"** tab.

![Outputs tab showing the PublicIp value for Fooocus](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus-09.png)

2.  Open the terminal and go to the directory where your private key is located.
3.  Paste the following command into your terminal and press Enter:

```bash
ssh -i <your key name> ubuntu@<Public IP address>
```

![SSH terminal connecting to the Fooocus server](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus-10.png)

Type "yes" and press Enter. This will log you into the server.

### Step 3: Generate SSL

Paste the following command into your terminal and press Enter:

```bash
sudo /root/certificate_generate_standalone.sh
```

## Shutting Down

1.  Click the link labeled **"Fooocus"** in the **"Resources"** tab to access the EC2 instance. You will be directed to the Fooocus instance in EC2.

![Resources tab showing the Fooocus EC2 instance link](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus-11.png)

2.  Select the Fooocus instance by marking the checkbox and click **"Stop instance"** from the **"Instance state"** dropdown. You can restart the instance at your convenience by selecting **"Start instance"**.

![Instance state dropdown showing Stop instance option](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus12.png)

## Remove Fooocus

Delete the stack that has been created in the AWS Management Console under 'CloudFormation Stacks' by clicking the 'Delete' button.

## API Documentation

### 1\. Generate Text-to-Image

Generate images based on the provided prompt.

```bash
Endpoint: /api/v1/generation/text-to-image
Method: POST
```

Request Body (Enter the text in 'prompt'):

```json
{
  "prompt": "car",
  "negative_prompt": "",
  "style_selections": [
    "Fooocus V2",
    "Fooocus Enhance",
    "Fooocus Sharp"
  ],
  "performance_selection": "Speed",
  "aspect_ratios_selection": "1152*896",
  "image_number": 1,
  "image_seed": -1,
  "sharpness": 2,
  "guidance_scale": 4,
  "base_model_name": "juggernautXL_version6Rundiffusion.safetensors",
  "refiner_model_name": "None",
  "refiner_switch": 0.5,
  "loras": [
    {
      "model_name": "sd_xl_offset_example-lora_1.0.safetensors",
      "weight": 0.1
    }
  ],
  "advanced_params": {
    "adaptive_cfg": 7,
    "adm_scaler_end": 0.3,
    "adm_scaler_negative": 0.8,
    "adm_scaler_positive": 1.5,
    "canny_high_threshold": 128,
    "canny_low_threshold": 64,
    "controlnet_softness": 0.25,
    "debugging_cn_preprocessor": false,
    "debugging_inpaint_preprocessor": false,
    "disable_preview": false,
    "freeu_b1": 1.01,
    "freeu_b2": 1.02,
    "freeu_enabled": false,
    "freeu_s1": 0.99,
    "freeu_s2": 0.95,
    "inpaint_disable_initial_latent": false,
    "inpaint_engine": "v1",
    "inpaint_erode_or_dilate": 0,
    "inpaint_respective_field": 1,
    "inpaint_strength": 1,
    "invert_mask_checkbox": false,
    "mixing_image_prompt_and_inpaint": false,
    "mixing_image_prompt_and_vary_upscale": false,
    "overwrite_height": -1,
    "overwrite_step": -1,
    "overwrite_switch": -1,
    "overwrite_upscale_strength": -1,
    "overwrite_vary_strength": -1,
    "overwrite_width": -1,
    "refiner_swap_method": "joint",
    "sampler_name": "dpmpp_2m_sde_gpu",
    "scheduler_name": "karras",
    "skipping_cn_preprocessor": false
  },
  "require_base64": false,
  "async_process": false,
  "webhook_url": "string"
}
```

Response Body:

```json
[
  {
    "base64": null,
    "url": "http://fooocus-test-prod.meetrix.io/api/files/2024-02-16/d0c43ae9-a4fa-4111-ac86-3976fcdaf3ea.png",
    "seed": "7157889350071648458",
    "finish_reason": "SUCCESS"
  }
]
```

### 2\. List Models

Retrieves a list of available models.

```bash
Endpoint: /api/v1/engines/all-models
Method: GET
```

Response Body:

```json
{
  "model_filenames": [
    "juggernautXL_version6Rundiffusion.safetensors",
    "sd_xl_base_1.0_0.9vae.safetensors",
    "sd_xl_refiner_1.0_0.9vae.safetensors"
  ],
  "lora_filenames": [
    "sd_xl_offset_example-lora_1.0.safetensors"
  ]
}
```

You can find out the full API documentation here [https://github.com/konieshadow/Fooocus-API/blob/main/docs/api\_doc\_en.md](https://github.com/konieshadow/Fooocus-API/blob/main/docs/api_doc_en.md)

## Upgrades

When there is an upgrade, we will update the product with a newer version. You can check the product version in AWS Marketplace. If a newer version is available, you can remove the previous version and launch the product again using the newer version. Remember to backup the necessary server data before removing.

## Troubleshoot

1.  If you face the following error, please follow [https://meetrix.io/blogs/increase-aws-vcpu-quota/](https://meetrix.io/blogs/increase-aws-vcpu-quota/) blog to increase vCPU quota.

![AWS vCPU limit exceeded error when creating the Fooocus stack](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus-13.png)

2.  If you face the following error (_do not have sufficient <instance\_type> capacity..._) while creating the stack, try changing the region or try creating the stack at a later time.

![Insufficient instance capacity error when creating the Fooocus stack](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus-14.png)

3.  If you face the below error, when you try to access the API dashboard, please wait 5-10 minutes and then try.

![502 Bad Gateway error when accessing the Fooocus API dashboard](https://meetrix.io/blog-images/paas-dev-guides/how-to-set-up-fooocus/how-to-set-up-fooocus-15.png)

## Conclusion

The Fooocus 2.0 Setup Guide equips you with the knowledge to seamlessly install and unlock the full potential of this AI-powered image creation tool. Fooocus excels in AI-driven image generation with its unique inpainting algorithms, image prompt enhancements, versatile model support, and robust API capabilities. Offering a user-friendly yet powerful platform for both novice and advanced creators, Fooocus simplifies the creative process, allowing users to produce stunning, relevant images effortlessly. As you follow this guide, you'll discover why Fooocus is rapidly becoming the preferred choice for AI-generated imagery among beginners and seasoned professionals alike.

## Technical Support

Reach out to Meetrix Support ([aws@meetrix.io](mailto:aws@meetrix.io)) for assistance with Fooocus issues.

## Frequently Asked Questions

What instance type is recommended for Fooocus?

We recommend g4dn.2xlarge for optimal performance with Fooocus image generation workloads.

How do I increase my AWS vCPU quota?

Follow our [guide to increasing your AWS vCPU quota](/blogs/increase-aws-vcpu-quota/) to request an increase in your AWS account.

What should I do if SSL setup fails automatically?

If your domain is not hosted on Route 53, automatic SSL setup will fail. You will need to manually run the certificate generation script: sudo /root/certificate\_generate\_standalone.sh

How do I upgrade to a newer version of Fooocus?

When a new version is available in AWS Marketplace, remove the previous stack and launch the product again using the newer version. Remember to back up your server data before removing the old version.

## Ready to Launch Fooocus on AWS?

Get started in minutes with our pre-configured AMI and unlock the full power of AI image generation.

[Deploy Fooocus from AWS Marketplace](https://aws.amazon.com/marketplace/pp/prodview-4xzjmoi4f3ml4)

Meetrix Store

Fooocus

SDXL image generation with a web UI and API

[Deploy it](https://meetrix.io/store/fooocus/)

Meetrix Store New

Deploy what this guide covers, pre-configured.

-    [Fooocus SDXL image generation with a web UI and API](https://meetrix.io/store/fooocus/)
-    [OpenWebUI A private ChatGPT-style assistant](https://meetrix.io/store/openwebui/)
-    [vLLM Serve open models on your own GPU](https://meetrix.io/store/vllm/)
-    [Jitsi Meet Self-hosted video calls for 50 to 500 users](https://meetrix.io/store/jitsi-meet/)
-    [RustDesk Remote desktop AMI, a TeamViewer alternative](https://meetrix.io/store/rustdesk/)
-    [Coturn TURN/STUN for WebRTC, no per-minute relay fees](https://meetrix.io/store/coturn/)

[Browse all products](https://meetrix.io/store/)
