How-to guide
How to Choose Which Turns Show Ads in LlamaIndex.TS
This guide shows how to choose which turns show ads in a LlamaIndex.TS app, the goal being to control ad placement and frequency across a conversation. It builds on the Monetzly server SDK, so the approach is specific to how LlamaIndex.TS produces and streams responses.
Overview
Not every turn in a LlamaIndex.TS conversation should carry an ad. Placement and frequency shape both revenue and user experience: too many ads erodes trust, too few leaves revenue on the table.
You control this by deciding which responses you route through injection — for example, skipping very short replies or the first turn, and allowing ads on substantive answers where a recommendation is genuinely useful.
LlamaIndex.TS apps are usually built for RAG over private docs, knowledge-base search, and structured data QA, so choose which turns show ads typically comes up while a user is mid-conversation, the moment where monetization has to be additive rather than disruptive.
How this works on LlamaIndex.TS
Use the TypeScript edition (LlamaIndex.TS) so you stay in the Node runtime the SDK requires. A streaming chat/query engine yields response chunks; map each chunk's text to { content } and pass into sdk.inject(). Confirm the chunk field name against your LlamaIndex.TS version.
Because Monetzly's inject() accepts any async token stream, the LlamaIndex.TS side of this task is just mapping your output to it, no rewrite of your LlamaIndex.TS model call.
Steps
- Decide your policy: which LlamaIndex.TS turns are ad-eligible (e.g. skip trivial or first replies).
- Route only eligible turns through the injection call.
- Measure revenue and engagement, then adjust frequency.
Frequently asked questions
Start monetizing in about 5 minutes
Wrap your existing LLM response stream with the Monetzly SDK and earn on every session, no paywall required.