Regardless of which SDK you use, all platforms follow the same workflow and share the same basic requirements. Our ads can be integrated into many types of apps, but the most common scenario is companion apps, where long conversations take place between a user and an assistant (chatbot, character). When the user sends a message, the companion app generates a reply — and immediately beneath that reply, our SDK displays an ad.Documentation Index
Fetch the complete documentation index at: https://docs.kontext.so/llms.txt
Use this file to discover all available pages before exploring further.
Two Phases: Preload and Stream
The full ad workflow consists of two distinct phases: preload and stream.Preload Phase
The preload phase begins immediately after the user sends a message, before the assistant’s response is generated. During this phase, the SDK calls the Preload API to:- analyze the latest conversation context
- request ads from DSPs
- select the best ad for the user and conversation
Stream Phase
Once the assistant message is generated, the SDK enters the stream phase. Here, the SDK takes the previously selected ad and streams it under the assistant’s message inside an HTML iframe.Flow
- The user sends a message.
- Two things start simultaneously:
- The app begins generating the assistant’s response.
- The SDK enters the preload phase, calling the Preload API with all necessary parameters.
- The assistant’s message is generated and displayed in the app.
- Once preload finishes, the SDK moves to the stream phase and begins streaming the ad.
What We Need to Generate Great Ads
To serve high-quality, high-performing ads, the publisher must provide several key parameters.1. Messages
We support two message roles:- user: what the user types
- assistant: AI-generated replies
2. User ID
You must provide a persistent unique ID for each user of your app. The format does not matter, but the ID must remain the same across conversations. This is important for:- retargeting
- frequency capping
- distinguishing new vs returning users
3. IDFA, GAID, IDFV
These are standard device identifiers used across the advertising ecosystem. They help advertisers recognize users across apps and platforms and dramatically increase the number and quality of available ads. Providing them significantly improves:- fill rate
- revenue
- ad relevance
4. Character Parameters
In companion apps, the character is the bot the user talks to. Providing character details (at minimum: id, name, avatarUrl) enables us to generate interstitial rewarded ads, which are currently the highest-performing ad format.5. Regulatory Parameters
While not strictly mandatory, it is strongly recommended to send regulatory and consent data, such as:- GDPR
- COPPA
- GPP
- US Privacy (CCPA/LSPA)
- full compliance
- maximum advertiser demand
- no blocked traffic due to missing consent signals