This example uses examples/python/functions/claude_agent_sdk_job/function.py to package a Claude Agent SDK app, run it as a finite job, and collect declared outputs.

Setup

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

CLI

nullspace functions deploy

nullspace functions run claude-agent-sdk-job \
  --input-json '{"prompt":"write a short release note"}' \
  --env ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY" \
  --retain-on-failure \
  --json

nullspace functions logs claude-agent-sdk-job --run fnrun_123
nullspace functions outputs claude-agent-sdk-job --run fnrun_123
nullspace functions machine claude-agent-sdk-job --run fnrun_123
Use the retained backing machine for PTY, SSH, command, or file debugging when the Claude run fails.

Function Definition

function.py
import nullspace

function = nullspace.Function(
    "claude-agent-sdk-job",
    mode="job",
    install="python -m pip install -e .",
    entrypoint="python main.py",
    env=nullspace.Env(required=["ANTHROPIC_API_KEY"]),
    outputs=nullspace.Outputs(paths=["result.json", "reports"]),
)

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)
call = function.spawn(
    input={"prompt": "Write a short release note for Functions."},
    envs={"ANTHROPIC_API_KEY": "..."},
    retain_on_failure=True,
)
run = call.get(timeout=60)
print(function.name, version.id, len(manifest.entries), run.id)
Run the complete script:
python run.py
Related: Claude Agent SDK and Functions.