Skip to Content
Client SDKOverview

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-sdk

What the client provides

createCustomerClient() returns a CustomerClient with one property for each area:

  • session holds the customer’s session. See Authentication.
  • chat sends chat completions. See Chat completions.
  • usage reads the customer’s allowances. See Get customer usage.
  • gateway returns the gateway address and headers. See Get gateway configuration.
  • products reads the customer’s current product and handles product upgrades.
  • checkoutSessions creates Stripe Checkout Sessions that the customer uses to buy a product.
  • models lists the models in the gateway catalog, or the models configured for a product.
  • customServer signs in customers through the project’s own authentication server.

To create the client, see Configure the Client SDK.