SDKs

JavaScript SDK

Install via script tag and request ads with a single unified requestAd method. No dashboard configuration required.

Prompt for coding agents

I want to set up Koah's JavaScript SDK. Read https://docs.koahlabs.com/SKILL.md and follow its instructions.

Prerequisites

Install

1

Add the script tag

Copy the snippet below and replace <YOUR_PUBLISHER_ID> with your actual publisher ID. Add it within the <head> tags of your HTML file.

<script async src="https://app.koah.ai/js?token=<YOUR_PUBLISHER_ID>"></script>
2

Add a target element

Add an empty <div> (or any element) where you want the ad to render:

<div id="ad-slot"></div>
3

Request an ad

Call window.koah.requestAd with the target element and a context describing the content on the page. Koah ranks, selects, and renders the ad directly into the target.

await window.koah.requestAd({
  target: document.getElementById('ad-slot'),
  context: {
    type: 'conversation',
    question: userMessage,
    answer: aiResponse,
  },
})

It returns a Promise<AdResult> describing the outcome — { filled: boolean; fromCache?: boolean }.

4

Style & size your adsOptional

Theme ads to match your brand and bound each slot's size from one place — see theming and sizing.

Next Steps

  • Appearance — Customize ad appearance
  • Use Cases — How to request ads for a variety of application types and contexts
  • Ad Mediation — Waterfall between Koah and fallback ad networks
  • Visitor Attributes — Share anonymous signals like age range, gender, and income bracket
Was this helpful?