@shaarai/sdk
v0.1.0
Published
ShaarAI SDK - The AI Revenue Control Plane. Track AI vendor attribution and ROI.
Maintainers
Readme
@shaarai/sdk
The AI Revenue Control Plane - Track which AI vendor actually drives your revenue.
Install
npm install @shaarai/sdkQuick Start
const { ShaarClient } = require('@shaarai/sdk');
// Initialize with your API key from https://shaar.ai
const client = new ShaarClient({ apiKey: 'shaar_your_key_here' });
// 1. Get offers to show in your AI chatbot
const offers = await client.getOffers({
aiVendor: 'openai', // or 'anthropic', 'gemini'
category: 'saas',
model: 'gpt-4-turbo',
usage: { inputTokens: 1200, outputTokens: 500 }
});
// 2. Show offers to users (tracking_url includes attribution)
offers.forEach(o => console.log(`${o.name}: ${o.tracking_url}`));
// 3. Report conversions when users take action
await client.reportConversion({
token: 'shaar_token_from_tracking_url',
conversionType: 'purchase',
value: 99.00
});OpenAI Function Calling
const OpenAI = require('openai');
const { ShaarClient } = require('@shaarai/sdk');
const openai = new OpenAI();
const shaar = new ShaarClient({ apiKey: 'shaar_...' });
// Get the tool schema
const toolSchema = await shaar.getToolSchema('openai');
// Use it with OpenAI
const response = await openai.chat.completions.create({
model: 'gpt-4-turbo',
messages: [{ role: 'user', content: 'Find me a CRM tool' }],
tools: [toolSchema],
tool_choice: 'auto',
});What ShaarAI Tracks
| Metric | Description | |--------|-------------| | Impressions | How many users saw each AI-powered offer | | Conversions | How many users took action (purchase, signup, etc.) | | ROI | Return on AI investment per vendor | | CPA | Cost per acquisition by AI vendor | | ROAS | Return on AI spend |
