monetzly
My knees hurt after a run
Ice them, then try Recovery Gel
↑ contextual placement · sponsored
Weaving ads into the conversation…
monetzly
ProductHow it WorksPricing
Login
Join waitlist
  1. Home
  2. How-to
  3. Combine Ads With a Subscription in Vercel AI SDK (Next.js)

How-to guide

How to Combine Ads With a Subscription in Vercel AI SDK (Next.js)

This guide shows how to combine ads with a subscription in a Vercel AI SDK (Next.js) app, the goal being to run ads on the free tier and a paid ad-free tier together. It builds on the Monetzly server SDK, so the approach is specific to how Vercel AI SDK (Next.js) produces and streams responses.

Overview

Ads and subscriptions are not mutually exclusive for a Vercel AI SDK (Next.js) app. A common setup runs Monetzly ads on the free tier and offers a paid, ad-free tier for power users — capturing revenue from casual and committed users alike.

Implementation is a branch on the response path: enable injection for free-tier sessions and skip it for paying users, based on your own Vercel AI SDK (Next.js) app's user state.

Vercel AI SDK (Next.js) apps are usually built for streaming chat UIs, Next.js AI apps, and edge/serverless LLM routes, so combine ads with a subscription 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

  1. Determine the user's tier from your Vercel AI SDK (Next.js) app's auth/session state.
  2. Run ad injection for free-tier sessions.
  3. Skip injection (return the plain stream) for paying, ad-free users.

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.

Get startedCompare models

Related

Vercel AI SDK (Next.js) monetization guide
All how-to guides
Combine Ads With a Subscription in LangChain
Combine Ads With a Subscription in OpenAI Assistants API
Combine Ads With a Subscription in LlamaIndex.TS
Set Up the Monetzly SDK in Vercel AI SDK (Next.js)
Inject Ads Into a Streaming Response in Vercel AI SDK (Next.js)
Pass Session Context to Ads in Vercel AI SDK (Next.js)
monetzly

Monetization for AI-native apps.

PRODUCT
OverviewHow it WorksUse CasesPricingFor Advertisers
RESOURCES
DocsGuidesFree ToolsChangelogStatus
COMPANY
AboutBlogContact
SOCIAL
Twitter / XLinkedIn
© 2026 Monetzly, Inc. All rights reserved.