Get started
Run a controlled workflow
Install the Python SDK, define a small graph, and run it through the backend-owned control cycle.1. Install the SDK
Install the neosyntropy package from the framework repository (or your package index when published).
Bashbash
pip install -e .
# or: pip install neosyntropy2. Set credentials
Point the SDK at the NeoSyntropy API. Use an API key with the framework:invoke scope, or a user access token with an active subscription.
.envdotenv
NEOSYNTROPY_API_URL=https://api.neosyntropy.com
NEOSYNTROPY_API_KEY=nsk_...
NEOSYNTROPY_PROJECT_ID=your-project-id
# or: NEOSYNTROPY_ACCESS_TOKEN=...3. Define a graph and run
ControlManager discovers credentials from the environment when backend is omitted. Every cycle returns a RunResult with an AuditRecord of proposals, gate checks, and committed transitions.
Pythonpython
from neosyntropy import BackendClient, ControlManager, Edge, FSM, EmptyOutput, TextOutput, node
@node(id="VerifyIdentity")
def verify_identity(ctx):
"""Verify the requester owns the order."""
return ctx.result(state_updates={"verified": True})
@node(id="IssueRefund", prerequisites=("VerifyIdentity",))
def issue_refund(ctx):
return ctx.result(state_updates={"refund_issued": True}, next_state="End")
@node(id="OutOfScope", is_fallback=True)
def out_of_scope(ctx):
return ctx.result(output="Out of scope for this workflow.")
graph = FSM(
nodes=[verify_identity, issue_refund, out_of_scope],
edges=[
Edge(source="Start", target="VerifyIdentity", label="first"),
Edge(source="VerifyIdentity", target="IssueRefund", label="next"),
Edge(source="IssueRefund", target="End", label="complete"),
],
)
backend = BackendClient.from_env()
manager = ControlManager(graph, backend=backend)
result = manager.run({"intent": "refund my order", "current_state": "Start"})
print(result.final_state)
print(result.audit.committed_transitions)Example adapted from neosyntropy-framework/README.md.