This is the simplest possible OpenLambda function — the "hello world" of serverless. If you've never written a serverless function before, start here.
A lambda is just a small function that runs on demand. You don't manage a server,
a main(), or a web framework — you write one function, and OpenLambda runs it
whenever someone calls it.
The entire program is f.py:
def f(event):
return 'hello'The contract is tiny:
- The function must be named
f. - It takes one argument,
event— the data sent in the request. - Whatever you
returnbecomes the response (encoded as JSON).
You need a running OpenLambda worker. OpenLambda runs on Linux (Ubuntu 24.04 LTS), needs root privileges, and cgroups v2 — so on macOS/Windows use a Linux VM or container.
Follow the Getting Started guide to build and start a worker. The short version:
make ol imgs/ol-min # build (Python-only)
./ol worker init -i ol-min
./ol worker up # starts the worker on localhost:5000With a worker running, install this function straight from GitHub:
./ol admin install https://github.com/open-lambda/hello-lambda-example.gitThe function name is taken from the repo name, so invoke it like this:
curl -X POST localhost:5000/run/hello-lambda-example -d ''You should get back:
"hello"
🎉 You just ran your first serverless function.
Open f.py and make it greet you by name. The request body is passed in
as event, so you can read from it:
def f(event):
name = event.get('name', 'world')
return f'hello, {name}!'Reinstall and call it again, this time sending some JSON:
./ol admin install https://github.com/open-lambda/hello-lambda-example.git
curl -X POST localhost:5000/run/hello-lambda-example -d '{"name": "Ada"}'→ "hello, Ada!"
That's the whole loop: edit f.py → install → curl.
- Need a Python package? Add a
requirements.txtnext tof.pyand OpenLambda installs it for you. - Browse the
examples/directory in the main repo — numpy, pandas, Flask, and more. - Read the worker docs to learn how OpenLambda runs your code fast.
Welcome to serverless. 🚀