This example uses examples/python/functions/langgraph_service/function.py to package a LangGraph-backed FastAPI service and expose it through a Nullspace service URL.

Setup

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

CLI

nullspace functions deploy

nullspace functions url langgraph-service \
  --env OPENAI_API_KEY="$OPENAI_API_KEY"

nullspace functions status langgraph-service --service fnsvc_123
nullspace functions logs langgraph-service --service fnsvc_123
nullspace functions stop langgraph-service
The service exposes /health and /invoke. Keep LangGraph thread IDs in your application request/session layer.

Function Definition

function.py
import nullspace

function = nullspace.Function(
    "langgraph-service",
    mode="service",
    install="python -m pip install -e .",
    entrypoint="python -m uvicorn src.server:app --host 0.0.0.0 --port 8000",
    service=nullspace.Service(
        port=8000,
        readiness={"type": "http", "path": "/health", "timeout_seconds": 30},
    ),
    policy=nullspace.Policy(public_url=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={"OPENAI_API_KEY": "..."})
service_url = function.service_url(service.id)
print(function.name, version.id, len(manifest.entries), service_url.public_url)
Run the complete script:
python run.py
Related: LangGraph, Functions, and Preview URLs.