The PromptBid SDK runs alongside your AI call. One import, one function call, one render hook. If no sponsored suggestion matches, nothing shows. This guide covers setup, rendering, and going live.
PromptBid currently documents the JavaScript Publisher SDK for AI Builder integrations. Initialize once, request ads in parallel with your AI call, and render with built-in tracking.
Install with @promptbid/sdk and use it in browser apps, frontend AI products, and server-rendered JavaScript stacks.
Load the SDK directly in the browser with an ES module import when you want a lightweight HTML-first integration.
Use renderAd for fast rollout or render the ad object yourself and call the tracking hooks manually.
Three lines in your existing message handler. The ad request fires in parallel with your AI call — no added latency.
Create a PromptBid client with your API key and call newConversation() when a chat session starts. One-time setup.
Call requestAd alongside your AI call using Promise.all. If no match, ad is null — nothing renders.
Wrap in if (ad). Use renderAd for automatic tracking, or render the ad object yourself and call the hooks manually.
Reference implementations for the JavaScript Publisher SDK.
import PromptBid from '@promptbid/sdk';
const pb = new PromptBid({ apiKey: 'pk_live_xxx' });
pb.newConversation();
let previousAIResponse = null;
async function onUserMessage(userMessage) {
const [aiResponse, ad] = await Promise.all([
askAI(userMessage),
pb.requestAd('after-response', {
userMessage,
assistantMessage: previousAIResponse,
topics: ['travel', 'hotels'],
}),
]);
renderResponse(aiResponse);
previousAIResponse = aiResponse;
if (ad) {
pb.renderAd(ad, document.getElementById('ad-slot'));
}
}
if (ad) {
const el = document.createElement('div');
const label = document.createElement('p');
label.textContent = `Sponsored · ${ad.displayUrl ?? ad.advertiser}`;
el.appendChild(label);
const headline = document.createElement('p');
headline.textContent = ad.headline;
el.appendChild(headline);
const cta = document.createElement('a');
cta.href = ad.ctaUrl;
cta.rel = 'noopener sponsored';
cta.textContent = ad.ctaText;
cta.addEventListener('click', () => pb.reportClick(ad.impressionId));
el.appendChild(cta);
document.getElementById('ad-slot').replaceChildren(el);
pb.reportImpression(ad.impressionId);
}
Three things to keep in place before going live.
Always render a visible "Sponsored" label. PromptBid's renderAd does this automatically. Transparency builds user trust and keeps your app compliant.
if (ad)When no match is found, requestAd returns null. Wrap your render logic in a null check and your chat will never show an empty slot or broken layout.
Call pb.reportImpression(ad.impressionId) when the suggestion becomes visible. This is how we count a view and how your revenue is recorded.
The SDK is designed to be invisible when it has nothing to show.
The ad request fires alongside your AI call via Promise.all. If PromptBid is unreachable, your response still arrives on time.
Suggestions match the conversation topic — no cookies, no user profiles, no device fingerprinting. Only the current query is used.
The SDK limits suggestions per conversation automatically. You can override the defaults from your dashboard.
Join the closed beta. Live in minutes.