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

# FastAPI

> Guide for deploying FastAPI applications written in Python.

***

## Prerequisites

<AccordionGroup>
  <Accordion title="Supported Python Versions" defaultOpen={true}>
    * FastAPI requires **Python version 3.7 or higher**.
  </Accordion>
</AccordionGroup>

<Warning>
  Ensure the Python version specified in your project configuration files (e.g., requirements.txt) matches the version selected during deployment. A mismatch may cause build and runtime errors.
</Warning>

## Select Template and Repository

<Frame>
  <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/developers/images/en/django_02.png" />
</Frame>

> On the dashboard, click <Icon icon="circle-plus" iconType="solid" size={15} color="2396F1" /> or `⌘ + K` to open the deployment modal and select the **Python** template. Then choose a GitHub repository from the dropdown or [input a Git repository URL in the Git URL tab](/en/developers/private-repo).

## Deployment Settings

> Apply the following settings to ensure your service runs seamlessly.

<AccordionGroup>
  <Accordion title="Basic Settings">
    * **Version**
    * [Environment Variables](/en/developers/env)
    * **Port Number**: `8000` (default)
    * **Start Command**: `uvicorn main:app --host=0.0.0.0 --port=8000` (default)
    * [Health Check](/en/developers/zero-downtime-deployment): Endpoint for verifying container status

    <Info>
      When entering a start command, refer to the following and modify the arguments according to your source.

      ```
      uvicorn main:app --host=0.0.0.0 --port=8000

      # [Example]
      # If myapi=FastAPI() in main.py, 
      uvicorn main:myapi --host=0.0.0.0 --port=8000
      ```
    </Info>
  </Accordion>

  <Accordion title="More Options">
    * **Build Variables**: Variables to include during container image builds
    * **Embedded node.js**: Node.js version required for builds within the project
    * **Install Command**: Python package installation command
    * **Pre-start Command**: Commands to run before the start command
    * **Update strategy**
      * **Rolling Update**: Deploy new version incrementally while maintaining service availability. Requires sufficient node resources
      * **Recreate**: Stop all instances before deploying new version. Results in downtime
  </Accordion>
</AccordionGroup>

## Set Resources and Deploy

<Frame>
  <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/developers/images/en/08_04.png" />
</Frame>

* **Resource Type**: Select between [On-demand or Spot instance types](/en/developers/resource#on-demand-spot)

* **CPU**: Maximum vCPU resource for the service. Minimum vCPU means 0.1 vCPU

* **Memory**: Maximum memory size your service can use

* [Replica](/en/developers/replica): Number of service replicas for high availability and load balancing

* **Deploy**: Click `Deploy`

<Info>
  Once deployment is complete, you can access the web page via the preview domain or send requests using an API tool.
</Info>

<Tip>
  If deployment fails due to resource limitations, see [the Space and Resource Management page](/en/operations/spaces#3) to add resources to your space.
</Tip>

***

[FastAPI Docs](https://fastapi.tiangolo.com/)
