How-to guide
How to Combine Ads With a Subscription in Streamlit
This guide shows how to combine ads with a subscription in a Streamlit app, the goal being to run ads on the free tier and a paid ad-free tier together. It builds on the Monetzly gRPC service (no Python SDK exists for this stack), so the approach is specific to how Streamlit produces and streams responses.
Overview
Ads and subscriptions are not mutually exclusive for a Streamlit 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 Streamlit app's user state.
Streamlit apps are usually built for AI demos, internal LLM tools, and chat prototypes with st.chat_message, 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 Streamlit
Streamlit is Python, so there is no native SDK. Drive the shipped tps_alter.proto gRPC service from Python (or a Node sidecar) and render the injected tokens with st.write_stream. Confirm the non-JS auth handshake before publishing.
Since Streamlit is a Python stack with no official SDK, this task runs through the shipped tps_alter.proto gRPC service (or a Node sidecar); the auth handshake for a direct client is still TODO_VERIFY.
Steps
- Determine the user's tier from your Streamlit app's auth/session state.
- Run ad injection for free-tier sessions.
- 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.