FastAPI expects to return something JSON-serializable, so instead of returning a plain string, return a dictionary:
from fastapi import FastAPI app = FastAPI() @app.get("/") def first_api(): return {"message": "Hello World"}