# Introduction
FastAPI has grown far past being only a easy Python library for serving APIs. It has grow to be a broader ecosystem that many builders depend on to construct trendy internet purposes, particularly for AI and machine studying initiatives. One of many causes FastAPI turned so standard is its velocity, simplicity, and developer-friendly design.

Picture from FastAPI Cloud
Now, with FastAPI Cloud, the deployment expertise is turning into a lot simpler too. As an alternative of spending time configuring servers and deployment pipelines, you may deploy an software in seconds utilizing the FastAPI Cloud command-line interface (CLI). The setup feels easy, light-weight, and far nearer to the sleek expertise builders anticipate from trendy managed platforms.
On the time of writing, entry remains to be rolling out via a waitlist. I utilized a few months in the past and not too long ago obtained entry, so I needed to place collectively a easy information based mostly on my expertise. On this tutorial, I’ll stroll via the fundamental setup course of and present the best way to deploy a small FastAPI app in only a few steps.
# Creating the Venture
On this tutorial, you’ll construct a easy stay metals dashboard utilizing FastAPI. The app will fetch gold and silver costs from an API, return the information in JSON format, and show the values within the browser utilizing a small HTML interface.
Earlier than you start, ensure you have:
- uv put in for challenge scaffolding, or a current supported Python model.
- A FastAPI Cloud account.
To get began, create a brand new FastAPI challenge with the official setup command:
uvx fastapi-new metals-live
cd metals-live
Inside a number of seconds, FastAPI will generate the challenge construction and set up the required dependencies for you.

Picture by Writer
Subsequent, activate the digital surroundings contained in the challenge listing.
On Linux/macOS:
supply .venv/bin/activate
On Home windows PowerShell:
.venvScriptsActivate.ps1
# Including httpx
Subsequent, set up the packages the app will want. We’ll use httpx to fetch stay gold and silver costs from the API, and we can even be sure that the usual FastAPI extras are put in so the app runs and deploys easily with out lacking dependencies.
uv add httpx "fastapi[standard]"
This command provides httpx for making outbound API requests and installs the usual FastAPI dependencies generally wanted for growth and deployment.
# Changing the Default App
Now it’s time to change the default FastAPI app with the model you’ll truly deploy.
That is what the default challenge construction seems like:

Picture by Writer
Open important.py and change its contents with the customized code proven under. This model does two issues: it fetches stay gold and silver costs from the Gold API, and it serves a easy browser dashboard that refreshes routinely each 15 seconds.
Paste this into important.py:
import httpx
from fastapi import FastAPI, HTTPException
from fastapi.responses import HTMLResponse
app = FastAPI(title="Reside Gold & Silver Costs")
GOLD_API_BASE = "https://api.gold-api.com"
async def fetch_price(image: str):
url = f"{GOLD_API_BASE}/value/{image}"
async with httpx.AsyncClient(timeout=10.0) as consumer:
response = await consumer.get(url)
if response.status_code != 200:
increase HTTPException(status_code=502, element=f"Did not fetch {image} value")
knowledge = response.json()
return {
"image": knowledge.get("image", image),
"identify": knowledge.get("identify", image),
"value": knowledge.get("value"),
"forex": knowledge.get("forex", "USD"),
"updatedAt": knowledge.get("updatedAt") or knowledge.get("timestamp"),
}
@app.get("/api/costs")
async def get_prices():
gold = await fetch_price("XAU")
silver = await fetch_price("XAG")
return {
"gold": gold,
"silver": silver,
}
@app.get("https://www.kdnuggets.com/", response_class=HTMLResponse)
async def residence():
return """
Reside Gold & Silver Costs
Costs refresh routinely each 15 seconds.
"""
What this code does:
- Creates a FastAPI app.
- Fetches stay gold and silver costs from the API.
- Returns the information via
/api/costs. - Serves a easy HTML dashboard at
/. - Refreshes the displayed costs each 15 seconds.
# Testing Regionally
Earlier than deploying, it’s a good suggestion to run the app regionally and ensure every thing works as anticipated. FastAPI makes this straightforward with its built-in growth server.
Begin the app with:
As soon as the server begins, FastAPI will generate a neighborhood URL in your app and a docs URL for testing the endpoints.

Picture by Writer
Open your browser and go to:
You need to see your stay dashboard exhibiting gold and silver costs. The values will refresh routinely each 15 seconds.

Picture by Writer
You may as well check the JSON endpoint immediately at:
http://127.0.0.1:8000/api/costs
That is particularly helpful if you wish to examine the uncooked response or later join the information to a different frontend or software.

Picture by Writer
# Deploying to FastAPI Cloud
As soon as the app works regionally, you’re able to deploy it to FastAPI Cloud. The deployment stream could be very easy and begins with a single command.
Run:
The CLI will information you thru connecting your FastAPI Cloud account and finishing the setup. Throughout onboarding, it’s possible you’ll be requested a number of brief questions, akin to your crew identify, app identify, and deployment settings.

Picture by Writer
As soon as that’s executed, FastAPI Cloud will construct and deploy your app for you.

Picture by Writer
After the deployment finishes, you’ll get a stay public URL in your app — for instance:

Picture by Writer
https://metals-live.fastapicloud.dev/
FastAPI Cloud additionally provides you interactive API docs at:
https://metals-live.fastapicloud.dev/docs

Picture by Writer
That is helpful as a result of you may check your API immediately from the browser, with no need any additional instruments.

Picture by Writer
# Monitoring the App
After deployment, you should utilize the FastAPI Cloud dashboard to watch your app and test its logs.
To view the logs:
- Open the FastAPI Cloud dashboard.
- Go to Apps.
- Choose your app.
- Open Logs.
That is helpful for checking whether or not your app is working appropriately, recognizing API errors, and debugging points after deployment.

Picture by Writer
FastAPI Cloud additionally begins to really feel nearer to platforms like Supabase or Vercel, with managed internet hosting, fast CLI-based deployment, and further integrations you may connect with your app as you develop it.

Picture by Writer
# Wrapping Up
FastAPI Cloud makes it straightforward to take a small FastAPI app from native growth to a stay deployment. On this information, we constructed a easy stay metals dashboard, examined it regionally, deployed it with one command, and checked logs after launch.
For a primary deployment, the workflow is easy and a superb introduction to the FastAPI Cloud expertise.
Abid Ali Awan (@1abidaliawan) is an authorized knowledge scientist skilled who loves constructing machine studying fashions. At the moment, he’s specializing in content material creation and writing technical blogs on machine studying and knowledge science applied sciences. Abid holds a Grasp’s diploma in expertise administration and a bachelor’s diploma in telecommunication engineering. His imaginative and prescient is to construct an AI product utilizing a graph neural community for college students fighting psychological sickness.
