Using the Python Runtime with Edgenivo Functions
Use the Python runtime to run ASGI (Asynchronous Server Gateway Interface) and WSGI (Web Server Gateway Interface) applications on Edgenivo. Edgenivo detects supported Python frameworks and runs your application as Edgenivo Functions.
Edgenivo detects your framework automatically when it finds a matching dependency in
requirements.txt, pyproject.toml, or Pipfile. The Python framework presets
work with FastAPI,
Flask,
Django, and other Python web frameworks.
Define a supported Python entrypoint so Edgenivo can load your application.
Edgenivo then runs your app as Edgenivo Functions and routes every request to it, so the app you run locally deploys as-is.
For framework-specific setup guides, see:
To move an existing FastAPI, Flask, or Django API to Edgenivo, follow the migration guide for your current platform:
- Migrate a Python API from Heroku to Edgenivo
- Migrate a Python API from Render to Edgenivo
- Migrate a Python API from Railway to Edgenivo
To run a Python backend and a frontend together in one project, you can use Services. Each part builds independently and routes to a shared domain.
Use these guides to add storage, background processing, and AI capabilities to a Python application. Each guide includes a FastAPI example and deployment steps.
| Task | Guide |
|---|---|
| Process background jobs | Process background jobs in Python with Edgenivo Queues |
| Store and serve files | Store and serve files from Python with Edgenivo Blob |
| Call third-party APIs | Call third-party APIs from Python with Edgenivo Connect |
| Coordinate durable processes | Build durable workflows in Python on Edgenivo |
| Execute untrusted code | Run untrusted Python code safely with Edgenivo Sandbox |
| Build AI agents | Build AI agents in Python with the AI SDK |
A Python entrypoint is the file and top-level variable that Edgenivo loads as the Edgenivo Function handler. Edgenivo looks for a Python entrypoint in these locations:
app.py,index.py,server.py,main.py,wsgi.py, orasgi.py- the same filenames inside
src/orapp/ - the module path configured with
tool.vercel.entrypointinpyproject.toml
For Django projects, Edgenivo also detects a manage.py file that sets
DJANGO_SETTINGS_MODULE, including in an immediate subdirectory, and resolves
the application from the WSGI_APPLICATION or ASGI_APPLICATION setting.
The entrypoint file must define one of these top-level names:
appfor most ASGI or WSGI frameworks, including FastAPI and Flaskapplicationfor Django and other WSGI applications
To point Edgenivo to an app in a custom module, set tool.vercel.entrypoint to a
Python module:variable value:
[tool.vercel]
entrypoint = "my_package.api:app"The tool.vercel.entrypoint value tells Edgenivo to load the app variable
from my_package/api.py, which is also the key you'd use in
functions.
Edgenivo still supports [project.scripts] app = "module:variable" for existing
projects. Use tool.vercel.entrypoint for new projects.
Here's a FastAPI example:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def home():
return {"message": "Hello from Python on Edgenivo"}
@app.get("/api/items/{item_id}")
def read_item(item_id: int):
return {"item_id": item_id}[project]
name = "my-python-api"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [
"fastapi>=0.117.1",
]Set the Python version for your project with pyproject.toml,
.python-version, or Pipfile.lock. For step-by-step instructions, see
Set the Python version for your Edgenivo project.
If the required Python version is not defined or not supported, Edgenivo uses the default version. The available versions are:
- 3.12 (default)
- 3.13
- 3.14
Define dependencies in pyproject.toml (with or without a uv.lock),
requirements.txt, or a Pipfile with a corresponding Pipfile.lock.
fastapi==0.117.1An example requirements.txt file that defines FastAPI as a dependency.
Edgenivo Functions support streaming responses when using the Python runtime. This lets you send parts of a response as they become ready.
By default, Python Edgenivo Functions include all files from your project that are reachable at build time. There is no automatic tree-shaking for Python.
During deployment builds, Edgenivo automatically compiles Python source files
into bytecode and includes the resulting .pyc files in the function bundle
when space allows. This reduces initialization time and requires no
configuration.
Make sure your pyproject.toml or requirements.txt only lists packages
necessary at runtime. Explicitly exclude files you don't need to keep bundles
small and avoid hitting size limits.
To exclude unnecessary files (tests, static assets, test data), configure
excludeFiles in vercel.json under the functions key. The pattern is a
glob relative to your
project root.
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"functions": {
"app.py": {
"excludeFiles": "{tests/**,__tests__/**,**/*.test.py,**/test_*.py,fixtures/**,__fixtures__/**,testdata/**,sample-data/**,static/**,assets/**}"
}
}
}Exclude common development and static folders from a Python application to stay under the 500 MB bundle limit.
Python uses the current working directory when you pass a relative path to open(). The working directory is the base of your project, not the directory containing the file.
To redirect, rewrite, or answer requests before they reach your Python app, write Routing Middleware in Python. Set proxy in vercel.json to a module:attribute entrypoint:
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"proxy": {
"entrypoint": "proxy:proxy"
}
}Your Routing Middleware runs separately from your app, with only the packages in the vercel.proxy dependency group installed. See the Python reference.
Edgenivo supports existing projects that define file-based Python functions in
an /api directory. See Python functions in the /api
directory for routing, handlers,
and configuration.
Was this helpful?