1
Install the SDK
Terminal
npx @zerocost/sdkInstalls package and creates your Zerocost config file automatically.
2
Configure & run
Set up your SDK with consent, ads, and role-targeting rules.
src/zerocost.ts
import { ZerocostSDK } from "@zerocost/sdk";
export const zc = new ZerocostSDK({
appId: "your_app_id",
apiKey: "zc_live_...",
appName: "My App",
debug: true,
llm: {
llmPath: "/chat",
collectData: true
},
ads: {
enabled: true,
roleTargeting: {
enabled: true,
allowedRoles: ["free", "basic"]
}
},
consent: {
required: true,
showSettingsButton: true,
primaryColor: "#10b981",
privacyPolicyUrl: "https://yoursite.com/privacy"
}
});
// Identify user tier before initialization
zc.identify("user_123", { role: "free" });
zc.init().catch(console.error);Done. Import this in your entry point (e.g. main.ts) and you are live.
3
Updating
Terminal
npm install @zerocost/sdk@latest