Client SDK
The Modem Client SDK connects your application to a Modem project. A CustomerClient acts for one customer. It holds the customer’s session, and the gateway meters its requests against that customer’s product. These pages describe Client SDK 0.9.3.
Before you begin
You need:
- Node.js 20 or later.
- A Modem project ID.
- A product connected to at least one provider account.
- A usage limit on that product that covers the model you want to call.
- A way to sign in the customer.
See Create a project, Configure a product, and Configure a provider account.
Install the SDK
The package is on GitHub Packages (https://npm.pkg.github.com) with restricted access. Point the @preternatural-js scope at that registry, then install:
bun add @preternatural-js/client-sdkWhat the client provides
createCustomerClient() returns a CustomerClient with one property for each area:
sessionholds the customer’s session. See Authentication.chatsends chat completions. See Chat completions.usagereads the customer’s allowances. See Get customer usage.gatewayreturns the gateway address and headers. See Get gateway configuration.productsreads the customer’s current product and handles product upgrades.checkoutSessionscreates Stripe Checkout Sessions that the customer uses to buy a product.modelslists the models in the gateway catalog, or the models configured for a product.customServersigns in customers through the project’s own authentication server.
To create the client, see Configure the Client SDK.