Run a Function in the Cloud
The simplest way to run code on Beam is to add the@function decorator to any Python function. Save this to app.py:
app.py
Deploy a Web Endpoint
To turn your code into a live web API, swap@function for @endpoint. We’ll include numpy in the image to show how easily you can add Python packages.
Image()defines your container environment. You can add Python packages, system dependencies, or even custom Dockerfiles.@endpointturns your function into a real, live web API that runs in the cloud.
app.py
Deployment
Deploy the endpoint to the cloud:Call the API
When the deploy finishes, Beam prints your endpoint URL along with a ready-to-runcurl command. Replace [TOKEN] with your token and use the URL from your deploy output: