How-to guide
How to Choose Which Turns Show Ads in Vercel AI SDK (Next.js)
This guide shows how to choose which turns show ads in a Vercel AI SDK (Next.js) 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 Vercel AI SDK (Next.js) produces and streams responses.
Overview
Not every turn in a Vercel AI SDK (Next.js) 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.
Vercel AI SDK (Next.js) apps are usually built for streaming chat UIs, Next.js AI apps, and edge/serverless LLM routes, 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 Vercel AI SDK (Next.js)
Vercel's streamText() exposes a textStream of plain strings. Wrap it in an async generator that yields { content: text } and pass that into sdk.inject(); then stream the injected tokens back in your Route Handler Response. Both APIs are documented, so this is a direct fit.
Because Monetzly's inject() accepts any async token stream, the Vercel AI SDK (Next.js) side of this task is just mapping your output to it, no rewrite of your Vercel AI SDK (Next.js) model call.
Steps
- Decide your policy: which Vercel AI SDK (Next.js) 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.