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 guides use the Client SDK 9.2 API. Check your installed package version before copying an example. Version availability distinguishes the supported package baseline from current source additions.
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
Complete package access and registry setup first, then install the customer SDK:
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 public or product-filtered model catalog.customServersigns in customers through your own authentication server.oauthstarts and completes hosted GitHub sign-in.
To create the client, see Configure the Client SDK.
Choose an integration
Use the chat helpers for text chat, provider SDKs for native request shapes, or the speech client for ElevenLabs and Rime AI. Your own app server can relay customer requests and offer resumable streams. See the gateway API matrix before choosing a modality.