///
The Quicksilver SDK empowers developers to move beyond static payment structures by defining **programmable products**. These products encapsulate pricing models, service level guarantees, and even mu
56 views
~56 views from guests
Guest views are estimated from total page views. These include anonymous visitors and users who weren't logged in when they viewed the page.
The Quicksilver SDK empowers developers to move beyond static payment structures by defining programmable products. These products encapsulate pricing models, service level guarantees, and even multi-agent workflows, allowing for highly sophisticated and automated commerce interactions. This page demonstrates how to define and purchase such products using the SDK's fluent Domain-Specific Language (DSL).
client.product()The client.product() method is the entry point for defining any programmable service or offering within Quicksilver. It returns a ProductBuilder instance, which provides a fluent interface to specify the product's characteristics. This approach leverages the Builder Pattern to make complex product definitions intuitive and type-safe.
For basic services, you can define a per-unit charge and include guarantees:
.charge(rate, unit, currency?)): Sets a fixed rate per a defined unit (e.g., per_word, per_line, per_transaction)..guarantee(object)): Specifies service level agreements (SLAs) or quality metrics for the product.For services involving multiple steps or agents, you can define a workflow:
.stage(name, config)): Breaks down the product into sequential stages, each delegating to a specific agent and potentially incurring its own charge. This is ideal for orchestrating AI agents or human teams.For continuous services, you can define a streaming pricing model:
.stream(rate, unit, currency?)): Sets a continuous payment rate per time unit (e.g., per_second, per_minute).account.purchase()Once a product is defined, any Account can "purchase" it using the purchase() method available on the active Account model. This action typically initiates a transaction, with the product's defined pricing, guarantees, and workflows automatically applied.
The purchase() method takes the Product (the ProductBuilder instance) and an options object containing any parameters specific to that purchase (e.g., word_count for a translation service, topic for a blog post pipeline).
The following example demonstrates the full flow of creating accounts, defining various types of programmable products (simple, complex workflow, streaming), and then purchasing them.