Aleph Cloud is a Web3 Supercloud that provides infrastructure for decentralised storage, computing, and AI. It provides serverless computing, decentralised storage, and secure message routing without relying on traditional centralised servers. It also provides a blockchain indexing framework, allowing developers to index data from any blockchain network by leveraging the Aleph network's decentralised storage and compute capabilities. Aleph Cloud serverless computing decentralised storage secure message routing Now let’s get our hands dirty. In this article, you will learn how to deploy an API on Aleph Cloud using Aleph CLI. Now let’s get our hands dirty. In this article, you will learn how to deploy an API on Aleph Cloud using Aleph CLI. Now let’s get our hands dirty. In this article, you will learn how to deploy an API on Aleph Cloud using Aleph CLI. Prerequiste Knowledge of Python Must have installed Python and PIP on your local machine. You can check the version of your Python or pip, use the following commands: Knowledge of Python Must have installed Python and PIP on your local machine. You can check the version of your Python or pip, use the following commands: Python PIP python3 --version //check python version pip3 --version //check pip version pip3 install --upgrade pip //to upgrade pip python3 --version //check python version pip3 --version //check pip version pip3 install --upgrade pip //to upgrade pip At least 500 Aleph in your Ethereum or Solana wallet A Code editor, e.g VS Code A folder for your project with a directory structure like this:my-project/ │ ├── app/ │ └── main.py At least 500 Aleph in your Ethereum or Solana wallet A Code editor, e.g VS Code A folder for your project with a directory structure like this:my-project/ │ ├── app/ │ └── main.py Let’s dive in Let’s dive in Let’s dive in Set Up the Project Install virtualenv using this command: Install virtualenv using this command: pip3 install virtualenv pip3 install virtualenv 2. Create a virtual environment using this command: python3 -m virtualenv venv python3 -m virtualenv venv 3. Activate the virtual environment: source venv/bin/activate source venv/bin/activate Install all the following packages: Install all the following packages: pip3 install fastapi uvicorn aleph-client pip3 install fastapi uvicorn aleph-client Creating the Feedback API In your main.py, copy and paste the following code: main.py from fastapi import FastAPI, Request from pydantic import BaseModel app = FastAPI() # In-memory feedback storage feedback_store = [] class Feedback(BaseModel): dapp: str feedback: str @app.get("/") async def root(): return {"message": "Hello World"} @app.get("/feedback") async def get_feedback(): return feedback_store @app.post("/feedback") async def submit_feedback(item: Feedback): feedback_store.append(item.dict()) return {"message": "Feedback received"} from fastapi import FastAPI, Request from pydantic import BaseModel app = FastAPI() # In-memory feedback storage feedback_store = [] class Feedback(BaseModel): dapp: str feedback: str @app.get("/") async def root(): return {"message": "Hello World"} @app.get("/feedback") async def get_feedback(): return feedback_store @app.post("/feedback") async def submit_feedback(item: Feedback): feedback_store.append(item.dict()) return {"message": "Feedback received"} Test Locally Run the server: Run the server: uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 Then test: Then test: curl -X POST http://localhost:8000/feedback -H "Content-Type: application/json" -d '{"dapp": "MyCoolDapp", "feedback": "Love the UI!"}' curl -X POST http://localhost:8000/feedback -H "Content-Type: application/json" -d '{"dapp": "MyCoolDapp", "feedback": "Love the UI!"}' You should see the result here: This shows that your API is working perfectly Deploy to Aleph Cloud You have to create an Aleph CLI account with your private key by following this process: Create a new account using this command: Create a new account using this command: aleph account create --private-key TEXT aleph account create --private-key TEXT Enter your private key Select the chain of your private key Enter your private key Select the chain of your private key To deploy the project: Compress your main.py file into a .zip file Upload the file using this command: Compress your main.py file into a .zip file main.py Upload the file using this command: aleph program upload app/main.py.zip main:app aleph program upload app/main.py.zip main:app Select the tier of the program you are going for and accept runtime reference Select the tier of the program you are going for and accept runtime reference choose based on the amount of tokens you’ve and the project’s needs choose based on the amount of tokens you’ve and the project’s needs Enter the name of your application Since our project doesn’t require any volume and uses an environment variable n Enter the name of your application Since our project doesn’t require any volume and uses an environment variable n n Preset to default chain: SOL ╭─ Pricing: Program ───────────────────────────────────────────────────────────────────────────────╮ │ ╷ ╷ ╷ ╷ ╷ ╷ │ │ Tier │ Compute Units │ vCPUs │ RAM (GiB) │ Disk (GiB) │ $ALEPH (Holding) │ + Internet Access │ │ ╶──────┼───────────────┼───────┼───────────┼────────────┼──────────────────┼───────────────────╴ │ │ 1 │ 1 │ 1 │ 2 │ 2 │ 200 tokens │ 400 tokens │ │ ╶──────┼───────────────┼───────┼───────────┼────────────┼──────────────────┼───────────────────╴ │ │ 2 │ 2 │ 2 │ 4 │ 4 │ 400 tokens │ 800 tokens │ │ ╶──────┼───────────────┼───────┼───────────┼────────────┼──────────────────┼───────────────────╴ │ │ 3 │ 4 │ 4 │ 8 │ 8 │ 800 tokens │ 1600 tokens │ │ ╶──────┼───────────────┼───────┼───────────┼────────────┼──────────────────┼───────────────────╴ │ │ 4 │ 6 │ 6 │ 12 │ 12 │ 1200 tokens │ 2400 tokens │ │ ╶──────┼───────────────┼───────┼───────────┼────────────┼──────────────────┼───────────────────╴ │ │ 5 │ 8 │ 8 │ 16 │ 16 │ 1600 tokens │ 3200 tokens │ │ ╶──────┼───────────────┼───────┼───────────┼────────────┼──────────────────┼───────────────────╴ │ │ 6 │ 12 │ 12 │ 24 │ 24 │ 2400 tokens │ 4800 tokens │ │ ╵ ╵ ╵ ╵ ╵ ╵ │ │ Extra Volume Cost: 51.2 token/GiB (Holding) -or- 0.02401 token/GiB/day (Pay-As-You-Go) │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ Select a tier by index: 1 Program name: Feedback API Ref of runtime? [63f07193e6ee9d207b7d1fcf8286f9aee34e6f12f101d2ec77c1229f92964696] Add volume? [y/n] (n): n Add environment variable? [y/n] (n): n Preset to default chain: SOL ╭─ Pricing: Program ───────────────────────────────────────────────────────────────────────────────╮ │ ╷ ╷ ╷ ╷ ╷ ╷ │ │ Tier │ Compute Units │ vCPUs │ RAM (GiB) │ Disk (GiB) │ $ALEPH (Holding) │ + Internet Access │ │ ╶──────┼───────────────┼───────┼───────────┼────────────┼──────────────────┼───────────────────╴ │ │ 1 │ 1 │ 1 │ 2 │ 2 │ 200 tokens │ 400 tokens │ │ ╶──────┼───────────────┼───────┼───────────┼────────────┼──────────────────┼───────────────────╴ │ │ 2 │ 2 │ 2 │ 4 │ 4 │ 400 tokens │ 800 tokens │ │ ╶──────┼───────────────┼───────┼───────────┼────────────┼──────────────────┼───────────────────╴ │ │ 3 │ 4 │ 4 │ 8 │ 8 │ 800 tokens │ 1600 tokens │ │ ╶──────┼───────────────┼───────┼───────────┼────────────┼──────────────────┼───────────────────╴ │ │ 4 │ 6 │ 6 │ 12 │ 12 │ 1200 tokens │ 2400 tokens │ │ ╶──────┼───────────────┼───────┼───────────┼────────────┼──────────────────┼───────────────────╴ │ │ 5 │ 8 │ 8 │ 16 │ 16 │ 1600 tokens │ 3200 tokens │ │ ╶──────┼───────────────┼───────┼───────────┼────────────┼──────────────────┼───────────────────╴ │ │ 6 │ 12 │ 12 │ 24 │ 24 │ 2400 tokens │ 4800 tokens │ │ ╵ ╵ ╵ ╵ ╵ ╵ │ │ Extra Volume Cost: 51.2 token/GiB (Holding) -or- 0.02401 token/GiB/day (Pay-As-You-Go) │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ Select a tier by index: 1 Program name: Feedback API Ref of runtime? [63f07193e6ee9d207b7d1fcf8286f9aee34e6f12f101d2ec77c1229f92964696] Add volume? [y/n] (n): n Add environment variable? [y/n] (n): n After successfully deploying your project, you will receive a notification that your application has been deployed, including your API URL, like this: ╭─ Program Created ────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ Your program 7067be26978fd4a78fe106a7b428c576195597b7e224f6863bf8f5b57843afa1 has been uploaded on aleph.im. │ │ │ │ Available on: │ │ ↳ https://aleph.sh/vm/7067be26978fd4a78fe106a7b428c576195597b7e224f6863bf8f5b57843afa1 │ │ ↳ https://obt34juxr7kkpd7ba2t3ikgfoymvlf5x4ispnbr37d23k6cdv6qq.aleph.sh │ │ │ │ Visualise on: │ │ https://explorer.aleph.im/address/SOL/CsnKR2rR5nykvJ3GX2VFptiim6Bbg9b3Zz1uo5VDdvTm/message/PROGRAM/7067be26978fd4a78 │ │ fe106a7b428c576195597b7e224f6863bf8f5b57843afa1 ╭─ Program Created ────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ Your program 7067be26978fd4a78fe106a7b428c576195597b7e224f6863bf8f5b57843afa1 has been uploaded on aleph.im. │ │ │ │ Available on: │ │ ↳ https://aleph.sh/vm/7067be26978fd4a78fe106a7b428c576195597b7e224f6863bf8f5b57843afa1 │ │ ↳ https://obt34juxr7kkpd7ba2t3ikgfoymvlf5x4ispnbr37d23k6cdv6qq.aleph.sh │ │ │ │ Visualise on: │ │ https://explorer.aleph.im/address/SOL/CsnKR2rR5nykvJ3GX2VFptiim6Bbg9b3Zz1uo5VDdvTm/message/PROGRAM/7067be26978fd4a78 │ │ fe106a7b428c576195597b7e224f6863bf8f5b57843afa1 Congratulations, you’ve just successfully deployed your API to Aleph cloud 🎉 You can add this feedback API to your dApp to get user feedback. You can add this feedback API to your dApp to get user feedback. Conclusion Aleph Cloud makes deployment easy for developers with its CLI and web console. CLI web console You can do much more with Aleph Cloud, such as: Host your AI models as an instance. Host your frontend code using the web hosting service. Host your AI models as an instance. instance Host your frontend code using the web hosting service. web hosting And much more. You can explore Aleph doc or join the Aleph developers' community on Discord or Telegram. Aleph doc Discord Telegram