Smarter Node.js SDK
The Smarter Node.js SDK is the official JavaScript and TypeScript library of the
Smarter API. It is to Smarter what the openai package is to the OpenAI API:
one npm install gives your Node.js software typed, complete access to your own Smarter platform,
whether it runs on your laptop or on Kubernetes.
Use it to build custom software that is tightly integrated with your Smarter resources, without customizing or forking the Smarter platform: a web back end that chats with your LLMClients, a CI/CD job that applies your manifests, a serverless function that loads documents into a Vectorstore, or a service that calls the tools of your MCP servers.
npm install @smarter.sh/api
import { Smarter } from "@smarter.sh/api";
const client = new Smarter(); // SMARTER_API_KEY, or the smarter cli's ~/.smarter/config.yaml
const llmclient = await client.llmClients.find("customer_support");
const response = await client.llmClients.prompt(llmclient.id, "Where is my order #1234?");
console.log(response.text);
The package is @smarter.sh/api on npm, in the
@smarter.sh scope beside the Smarter Chat
component, and is the npm counterpart of the Python SDK’s smarter-api on PyPI. It is written in TypeScript, ships its type declarations, and
runs on every Node.js release that is not end-of-life (22 and later). Its source is
github.com/smarter-sh/smarter-nodejs.
It has the same features as the Smarter Python SDK, which is the reference
implementation of every Smarter SDK: the same resources, the same verbs and the same errors, with
camelCase names (client.llmClients, exampleManifest()), promises, and for await streams.
The SDK or the CLI?
The SDK and the Smarter CLI manage the same resources, through the same API. The difference is how you use them.
Smarter Node.js SDK |
Smarter CLI |
|---|---|
A library that you import into your own software. |
A program that you install on your computer. |
|
|
Returns typed, validated objects, and throws typed errors. |
Prints JSON or YAML in a terminal window. |
For applications, services, serverless functions, tests and automation. |
For people at a keyboard, and shell scripts. |
The SDK reads the CLI’s configuration file, so a developer who has run smarter configure needs
no other setup.
What It Covers
Every resource kind, through the same brokered manifest API that the CLI uses:
apply,validate,get,describe,delete,deploy,undeployandlogs.Prompts and conversations: prompt an LLMClient, hold a multi-turn chat that keeps its session, and stream a prompt’s progress as it runs, exactly as Smarter Chat does.
Resource actions: evaluate a Guardrail, call an MCP server’s tools, add documents to and search a Vectorstore, plan and deploy an LLMHost, discover open-weight models, read the chat history and the Smarter Journal, and call an LLM provider through a Proxy.
The platform’s own models: a TypeScript type of every manifest kind, generated from the platform’s JSON Schemas, and Zod schemas of the Smarter Chat API contract, the Smarter Journal contract, the Django-React integration contract and every REST response.
Where to Start
If you want to… |
Read |
|---|---|
Connect to your platform: api keys, urls, environments, timeouts |
|
Create, change and delete resources from Node.js |
|
Prompt an LLMClient, chat with it, or stream its progress |
|
Use Guardrails, MCP clients, Vectorstores, LLMHosts and the other resources |
|
Build manifests in code, or read the API’s contracts as typed objects |
|
Handle errors, retries, timeouts, cancellation and logging |
|
Contribute to the SDK |
|
Look up a class or method |
Smarter Node.js SDK