How to add ads to an AI app
You can add ads to an AI app with one JavaScript integration, and your AI coding tool can write it for you from the Adgentek docs. The Adgentek Ad Server decides which prompts should carry an ad, and your app keeps control over where and when one appears.
This guide is for builders shipping AI apps, chatbots, agents, image and video generators, and coding tools with a UI. An AI app has no page and no fixed slot the way a website does. It has a prompt, and the prompt says what the person wants right now. The Adgentek Ad Server reads the intent of that turn and decides whether an ad belongs there at all. Your code passes the conversation in and renders what comes back. Every method name below comes from the public docs, so it matches what your coding agent will read.
What you need before you add ads to an AI app
You need two values: an Adgentek API key and a Placement ID for each surface where ads will render. Sign in at app.adgentek.ai. The API key is under Inventory, API Keys. The Placement ID is under Inventory, AI Surfaces, where you create a surface, choose its type, pick the allowed ad formats, and set the floor eCPM and disclosure.
The SDK sends the Placement ID as the slot ID. Pick a stable one and keep it. Changing it after launch splits your reporting history and detaches the policies tied to that surface.
If you want the business side before the code, the AI surfaces page covers how monetization works for apps like yours, and how conversational ads work shows what your users will see.
How to have your AI coding tool write the integration
The fastest path is to point your AI coding tool at docs.adgentek.ai and let it read before it writes. Every page on the docs site is served as clean Markdown, and docs.adgentek.ai/llms.txt indexes all of them. A coding agent that reads them gets the real method names and tracking rules instead of guessing from training data.
Paste this prompt from the docs introduction into your coding agent:
I want to set up Adgentek. Read https://docs.adgentek.ai/skill.md and follow its instructions.
The skill file walks the agent through the Web SDK workflow and ends with a verification checklist. Ask the agent to run that checklist against its own code before you test anything. Most revenue-losing mistakes are about where the impression pixel fires, and the checklist catches them.
How to add the Adgentek JavaScript integration step by step
The Web SDK integration is a script tag, a container element, one init call, and one call after each AI response. Here is the sequence from the docs quickstart, so you can check what your agent wrote.
- Add the SDK before the closing body tag.
<script src="https://api.adgentek.ai/storage/v1/object/public/sdk/sdk.js"></script> - Add a container where the ad should render, usually right after the AI response. The SDK does not create this element and does not look for slots on its own.
<div id="adgentek-ad"></div> - Initialize once on page load with your API key and Placement ID.
The init call only stores configuration. Nothing is requested or rendered yet.AdgentekAds.init({ apiKey: 'YOUR_API_KEY', slotId: 'YOUR_SLOT_ID', containerId: 'adgentek-ad' // optional, this is the default }); - After each AI response, pass the turn to the SDK.
Theawait AdgentekAds.showAd([ { role: 'user', content: userMessage }, { role: 'assistant', content: aiResponse } ]);showAd()call requests and renders an ad in your container, then fires its tracking pixels. It resolves to the ad object, or tonullwhen nothing matched. A null is normal, because the Ad Server returns no fill on support questions and low-confidence turns on purpose. - Check it in DevTools. Open the Network tab, ask about something commercial (the docs suggest mattresses or SUVs), and confirm that a get-ad request fires and that an impression pixel request fires from the page when the ad renders.
Messages also accept a system role. If you want frequency capping to follow a conversation across reloads, pass a stable sessionId in the options; otherwise the SDK generates one per browser tab and reuses it. Building in React? Load the same Web SDK script and mount the placement inside a useEffect.
Which AI surfaces can run ads
Any AI surface that runs in a real browser and takes a prompt can run ads through the Web SDK. That covers far more than chat windows, because the prompt is the turn wherever it is typed.
| Surface | What the prompt tells the Ad Server | Where the ad renders | Setting to check |
|---|---|---|---|
| Chatbot or assistant | The question and any constraints stated in it | Right after the AI response | Minimum conversation turn |
| AI search | Research or comparison intent | Below the answer | Per-intent rules |
| Agent with a chat front end | The task the person handed off | After a step result | Minimum relevance threshold |
| Coding tool with a UI | The stack and the problem being solved | In the chat panel after a response | Brand safety categories |
| Image generator | Subject and style, often with the use case | In the output area while the image renders | Wait-state surface, minimum turn 0 |
| Video generator | Scene and length, often with the use case | In the output area while the video renders | Wait-state surface, minimum turn 0 |
Image and video generators get their own surface type. In the dashboard, create the surface as a wait state, pass the prompt to showAd() as the user turn when generation starts, and render the container where the output will appear. The person is already looking at that spot while the render finishes. Wait-state surfaces have no conversation turns, so the docs say to keep their minimum turn setting at 0.
The reason this inventory is worth monetizing is the intent in it. AI assistants reach 800M+ weekly users, and a prompt says more about what someone wants than any page category. The Ad Server sorts every turn into one of nine intent buckets, from Purchase and Comparison to Support and Entertainment, and the bucket decides which demand is eligible and which format renders. The intent data from AI ads page covers what those signals are worth to a buyer.
Spark, the conversational ad format, is available now for AI apps that run the Adgentek Ad Server. It is an interactive Q&A unit with guided questions, free-text questions matched to answers, the answers themselves, and a CTA, all inside the conversation the person is already having. Spark sessions average 3.2 interactions.
How your app controls when an ad appears
Your code controls placement, and your dashboard policies control eligibility. In code, you decide where the container sits and which turns call showAd(). If a screen or a moment in your product should never carry an ad, do not call the SDK there.
In the dashboard, policies live under Inventory, Ad Policies, as an account default or attached to one AI Surface. These are the controls most builders reach for:
- Minimum Relevance Threshold excludes matches below the score you set.
- Minimum Conversation Turn holds ads back until the conversation reaches a set depth.
- Per-intent rules require a minimum score for a given bucket, then either block low-scoring matches or reduce their floor.
- Brand safety runs at a preset level or as a Custom policy that can block content categories, block advertiser domains, block brands by name, and restrict serving by language.
The Strict preset blocks every category in the sensitive-category registry, which can shrink eligible demand a lot, so review the list before you turn it on. The docs are direct about one limit: dashboard configuration is not by itself proof of enforcement. Confirm with Adgentek before you rely on a control for contractual or regulatory compliance. For the wider policy picture, see brand safety in AI advertising.
If you run other demand and want to compare before rendering, use getAd() instead of showAd(). It returns the ad object, including bid_price as a CPM in USD, and renders nothing. It also fires nothing. Once you render the ad yourself, you must call fireDeferredTrackers(ad, containerElement), or the impression is never recorded and you are not paid for it.
Why client-side tracking decides which demand you earn
Impression-priced demand only serves where the impression can be verified from the user's browser. The Web SDK runs in a real browser and fires pixels from there, which makes all four demand tiers eligible: direct, programmatic, CPC, and CPA.
| Path | Direct CPM | Programmatic CPM | CPC | CPA | Impression tracking |
|---|---|---|---|---|---|
Web SDK with showAd() | Yes | Yes | Yes | Yes | Automatic, client-side |
Web SDK with getAd() | Yes | Yes | Yes | Yes | You call fireDeferredTrackers() after render |
An impression fired from a backend or a worker comes from datacenter IP space. Verification vendors classify it as general invalid traffic, and it is discarded unbilled. If you ever handle a pixel by hand, the docs give the correct form:
// Correct: fires from the user's browser, no CORS involvement
new Image().src = ad.impression_url;
Clicks follow the same logic. Make the clickable element an anchor whose href is ad.click_url. The redirect through that URL is where the click is recorded and where click-quality filtering runs, and a button with a JavaScript handler records nothing. Conversational ads draw 3 to 8x higher engagement than display, so clicks deserve the same care as impressions; AI advertising vs display covers that comparison.
Products with no browser UI, such as headless agents, voice surfaces, and backend services, are set up directly rather than through the SDK. Email hello@adgentek.ai.
How to test ads before you go live
Put the placement in test mode, confirm the impression pixel fires from the browser, then ask Adgentek to take it live. Nothing in your code changes between test and live. Running a real pilot on live traffic, with a holdout and the numbers to judge it by, is its own job, and how to test ads in your AI app walks through it. For finished placements, browse the industry examples.
Getting started
Adgentek gives AI app builders an ad server built for prompts, with docs written so a coding agent can do the integration. Create a free account at app.adgentek.ai, point your AI coding tool at docs.adgentek.ai, have it run the docs checklist, and put your placement in test mode. When you want it live, or want Spark running on your surface, email hello@adgentek.ai.
