Build with the API / Connect the SDK
Connect the SDK
Use the SDK when your application needs several semantic operations with the same connection, timeout, and error handling.
Add the workspace package#
@superb/sdk is a package in this source workspace, not a published npm package. Its implementation and TypeScript declarations live in packages/sdk. Add it as a workspace dependency or consume the source package in your own build; do not expect npm install @superb/sdk to fetch a public release.
Create one client#
import { Superb, SuperbError } from '@superb/sdk';
const superb = new Superb({
baseUrl: 'http://localhost:4173',
timeoutMs: 15000,
});
try {
const result = await superb.compareClaims({
a: 'Some users benefited.',
b: 'All users benefited.',
});
console.log(result.relation);
} catch (error) {
if (error instanceof SuperbError) {
console.error(error.status, error.message);
} else throw error;
}
Use your deployment origin outside local development. Browser calls should remain same-origin where possible. An operator API key belongs in a server environment, not a public frontend bundle.
Choose a method#
| Goal | Method | Guide |
|---|---|---|
| Resolve an expression | resolve |
Contextual resolution |
| Compare two usages | compare |
Compare senses |
| Inspect several occurrences | illuminate |
Illuminate |
| Compare propositions | compareClaims |
Claims |
| Structure messages | analyzeArgument |
Arguments |
| Inspect source fit | evaluateEvidence |
Evidence |
Cancel requests#
Pass { signal: controller.signal } as the second argument to a method. The client combines caller cancellation with its configured timeout. Keep a cancelled request distinct from an unavailable provider in your UI.
Next: Authentication and errors. For every method signature, download the SDK contract.