Framework / Quickstart
Move from one call to a workflow
Use the Python framework when work needs explicit states, permitted transitions, and an audit of every control cycle.1. Install and bind a project
Framework clients use the service root, not the /api/v1 proxy base. Create or reuse a project before running a remote workflow.
Pythonpython
from neosyntropy import Client
client = Client(api_key="nsk_...", base_url="https://api.neosyntropy.com")
project = client.create_project(
name="Support workflow",
slug="support-workflow",
)
print(project["id"])2. Define and run the workflow
Workflow supplies the entry path and dedicated fallback. Typed schemas validate each capability. Node output is committed into workflow state; it does not replace the original run input, so later nodes read prior values from ctx.state.
Pythonpython
from pydantic import BaseModel, ConfigDict
from neosyntropy import EmptyOutput, OpenInput, SchemaNode, TextOutput, Workflow, node
class Ticket(BaseModel):
model_config = ConfigDict(extra="forbid")
order_id: str
reason: str
extract = SchemaNode(
id="ExtractTicket",
input_schema=OpenInput,
output_schema=Ticket,
prompt="Extract the order id and refund reason.",
)
@node(id="ReviewTicket", input_schema=OpenInput, output_schema=EmptyOutput)
def review(ctx):
order_id = ctx.state["order_id"]
reason = ctx.state["reason"]
return ctx.result(
output={},
state_updates={"reviewed": True, "reviewed_order": order_id},
next_state="End",
)
@node(id="OutOfScope", is_fallback=True, input_schema=OpenInput, output_schema=TextOutput)
def fallback(ctx):
return ctx.result(output={"message": "Request could not be processed."})
workflow = Workflow([extract, review], fallback=fallback)
result = workflow.run(
{"text": "Refund order NS-1042 because it arrived damaged."},
client=client,
)
print(result.final_state, result.rejected)
print(result.audit.committed_transitions)