from splox import SploxClient
client = SploxClient(api_key="YOUR_API_KEY")
# List workflows
workflows = client.workflows.list()
for wf in workflows.workflows:
print(wf.id, wf.latest_version.name)
# Create a chat and run a workflow
chat = client.chats.create(name="My Session", resource_id=wf.id)
version = client.workflows.get_latest_version(wf.id)
start_nodes = client.workflows.get_start_nodes(version.id)
result = client.workflows.run(
workflow_version_id=version.id,
chat_id=chat.id,
start_node_id=start_nodes.nodes[0].id,
query="Hello, world!",
)
# Stream real-time updates
for event in client.workflows.listen(result.workflow_request_id):
if event.node_execution:
print(f"[{event.node_execution.status}] {event.node_execution.node_id}")
# Check your balance
balance = client.billing.get_balance()
print(f"Balance: ${balance.balance_usd:.2f}")