This example uses examples/python/functions/minimal_service/function.py to package a Python HTTP server, start it as a managed service, and fetch its public URL.

Setup

uv pip install "nullspace-sdk[cli]"
export NULLSPACE_API_KEY=ns_live_...
export NULLSPACE_API_URL=https://api.your-nullspace-domain
cd examples/python/functions/minimal_service

CLI

nullspace functions deploy

nullspace functions url minimal-service-function \
  --env EXAMPLE_FUNCTION_GREETING=hello

nullspace functions status minimal-service-function --service fnsvc_123
nullspace functions logs minimal-service-function --service fnsvc_123
nullspace functions stop minimal-service-function --service fnsvc_123
nullspace functions delete minimal-service-function --yes
The service binds to 0.0.0.0:8000, exposes /health, and uses nullspace.Policy(public_url=True) so nullspace functions url can return a public endpoint. Expected output includes a public URL, a ready service status, and a /health response with {"ok": true}.

Python

The companion run.py script uses the same function contract through the SDK:
from pathlib import Path

from nullspace import Function

project = Path(__file__).resolve().parent
function, version, manifest = Function.deploy(path=project)
service = function.start_service(envs={"EXAMPLE_FUNCTION_GREETING": "hello"})
url = function.service_url(service.id)
print(function.name, version.id, len(manifest.entries), url.public_url)
Run the complete script:
python run.py

Project Files

examples/python/functions/minimal_service/
  README.md
  server.py
  run.py
  function.py
Related: Functions, Preview URLs, and CLI reference.