Skip to content

Configuring FastAPI

If you can run the fastapi dev command locally, you should be able to deploy to FastAPI Cloud with fastapi deploy as well! ✨

If you normally need to pass a path file to the fastapi dev command, for example like:

Terminal window
fastapi dev my_app/main.py

…you can instead configure it in the pyproject.toml file.

You can do this by adding a [tool.fastapi] section in the pyproject.toml file, for example:

[tool.fastapi]
entrypoint = "my_app.main:app"

This configuration tells the fastapi command to import the app object from the my_app.main “module” (the file my_app/main.py) as the FastAPI application instance.

It’s equivalent to:

from my_app.main import app

After this configuration, you should be able to just run:

Terminal window
fastapi dev

If now it works without passing the path, then you can now deploy with just:

Terminal window
fastapi deploy

And that should work as well! 🚀