npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ilyashik/ai-ad-sdk

v2.3.0

Published

Contextual advertising SDK for AI applications

Readme

AI Ad SDK

Contextual advertising SDK for AI applications. Show relevant ads based on conversation context.

Quick Start

npm install ai-ad-sdk

One-line widget (zero UI code)

import { createAdNetwork } from 'ai-ad-sdk';

const ads = createAdNetwork({ apiKey: 'your-api-key' });

// After each AI response — renders ad automatically:
await ads.mount('#ad-container', { userMessage, aiResponse });
<div id="ad-container"></div>

That's it. The SDK fetches the ad, renders a styled block with "Sponsored" label, and tracks impressions and clicks automatically.

Manual control (custom UI)

const ad = await ads.getAd(userMessage, aiResponse);
if (ad) {
  console.log(ad.title, ad.text, ad.url);
  ads.trackClick(ad); // call when user clicks
}

Via script tag

<script src="https://api.kontezza.com/static/ai-ad-sdk.umd.js"></script>
<script>
  const ads = createAdNetwork({ apiKey: 'your-api-key' });
  ads.mount('#ad-container', { userMessage, aiResponse });
</script>

API

createAdNetwork(options)

| Option | Type | Required | Description | |-----------|---------|----------|--------------------------------| | apiKey | string | yes | Your API key | | baseUrl | string | no | Custom backend URL | | debug | boolean | no | Enable console logging |

ads.mount(container, context, options)

All-in-one: fetches an ad and renders it into the container. Returns the ad object or null.

await ads.mount('#ad-slot', {
  userMessage: 'Помоги с презентацией',
  aiResponse: 'Рекомендую использовать шаблоны...'
}, {
  type: 'relevant',  // "relevant" | "vector" | "banner"
  lang: 'ru',        // "ru" | "en"
  showScore: false,   // show relevance score badge
  linkText: 'Подробнее →'
});

ads.renderAd(container, ad, options)

Render a previously fetched ad object into a container. Useful when you want to control when/how the ad is fetched.

const ad = await ads.getAd(userMessage, aiResponse);
if (ad) {
  ads.renderAd('#ad-slot', ad, { lang: 'en', linkText: 'Learn more →' });
}

ads.getAd(userMessage, aiResponse)

Returns a relevant ad based on conversation context, or null. Impression is tracked automatically.

ads.getVectorAd(userMessage, aiResponse)

Direct vector search (BGE-M3, no LLM summarization). Faster, good for high-frequency calls.

ads.getBanner()

Returns a random banner ad from the active banner campaign, or null.

ads.trackClick(ad)

Track a click event. Called automatically when using renderAd/mount and user clicks the link. Call manually if using custom UI.

Ad Object

{
  id: string;
  campaignId: string;
  title: string;
  text: string;
  url: string;
  imageUrl: string;
  category: string;
  score: number | null;
  adType: 'relevant' | 'banner' | 'vector';
  design: {
    bgColor: string;     // publisher's bg color
    borderColor: string;  // publisher's accent color
  };
}

Design Customization

Ad colors are controlled by the publisher in the Kontezza dashboard. The renderAd/mount methods automatically apply design.bgColor and design.borderColor. Text color adapts to light/dark backgrounds.

TypeScript

Full TypeScript definitions included (index.d.ts).

import { createAdNetwork, Ad, RenderOptions } from 'ai-ad-sdk';