@licenseos/sdk
v0.1.0
Published
TypeScript SDK for the LicenseOS IP licensing + AI-compliance API.
Downloads
26
Maintainers
Readme
@licenseos/sdk
Typed TypeScript client for the LicenseOS IP licensing + AI-compliance API.
npm install @licenseos/sdkimport { LicenseOS } from "@licenseos/sdk";
const client = new LicenseOS({
apiKey: process.env.LICENSE_OS_API_KEY!,
baseUrl: "https://licenseos.vercel.app", // origin only; the SDK appends /api/v1
});
// Preflight — is this proposed use allowed?
const decision = await client.checkLicense({
ipPropertyId: "moonberry-grove",
useCase: "low_volume_commercial",
prompt: "A cozy birthday scene with Momo the Moon Fox",
outputType: "image",
distributionChannel: "ios_app",
commercialIntent: true,
expectedMonthlyUsers: 500,
expectedRevenue: 1500,
});
if (decision.approved) {
// ship it — attribution + limits are attached, decision is logged
} else if (decision.decision === "require_review") {
// pending the rights holder's review queue
} else {
// show the restriction to the user (decision.violatedRules / decision.flags)
}
// Postflight — review an actual output
await client.reviewOutput({
ipPropertyId: "moonberry-grove",
outputType: "image",
imageDescription: "Momo waving on a starry background",
});
// Report usage (drives quotas + royalties)
await client.reportUsage({ ipPropertyId: "moonberry-grove", eventType: "generation", revenueAmount: 4.99 });
// Validate the token / see what it allows
const status = await client.getStatus();
// Subscribe to lifecycle events
await client.registerWebhook({ url: "https://your-app/webhooks/licenseos", events: ["license.revoked"] });Errors
Failed requests throw LicenseOSError with .code (unauthorized, token_revoked, forbidden, invalid_request, rate_limited, …), .status, and .detail.
import { LicenseOSError } from "@licenseos/sdk";
try {
await client.checkLicense(input);
} catch (e) {
if (e instanceof LicenseOSError && e.code === "token_revoked") {
// the rights holder revoked this license — stop using the IP
}
}Build
npm run build # tsc -> dist/