Skip to main content

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.

Kontext serves contextually relevant ads inside text-based AI apps — chat, search, and any interface where users talk to a model. Your app feeds the SDK the messages of a conversation as they happen; the SDK contacts our ad server in the background and renders the winning ad in the slot you mount in your UI.

The flow

  1. Create a session. Your app instantiates one Session per chat conversation, supplying your publisherToken, a stable userId, and a conversationId. The SDK calls /init in the background to fetch server-controlled flags (whether the session is enabled, the preload timeout, telemetry toggles).
  2. Feed messages to the SDK. As the user and the assistant exchange messages, the app calls session.addMessage(...) for each one. This is the only signal the SDK needs to do its work.
  3. The SDK preloads ads in the background. Each addMessage triggers a debounced POST /preload carrying the conversation context. The server returns one or more ads for the preload. The SDK pairs each ad to the latest assistant message id (see Displaying ads for the pairing rules) and emits a filled event for each id that got an ad, or no-fill otherwise.
  4. Mount an ad slot in your UI. When the assistant’s reply is on screen, your app renders <InlineAd messageId="..." /> (the component name differs per SDK). The component is a renderer — it does not fetch — it simply looks up the cached ad for that messageId and renders the creative inside an iframe.
  5. Render-time events flow back to your app. As the ad loads, becomes visible, or is clicked, the SDK emits viewed, clicked, and error events. Subscribe to them alongside filled / no-fill to drive your own UI — for example, to reveal an assistant bubble only once the ad has resolved.

What you provide vs. what the SDK handles

You provideThe SDK handles
publisherToken (issued during onboarding)/init, /preload, /error, /debug network calls
userId, conversationId (stable IDs you generate)Ad cache, message-id matching, TTL
The list of messages, via addMessageDebounce, retries, request cancellation
The placement: where <InlineAd /> is mountedIframe rendering, viewability tracking
Optional regulatory signals (see Compliance)TCF auto-collection from the standard CMP storage

Where to next

Pick your SDK

Install an SDK, initialize a session, mount one component, see an ad — every SDK page is its own quickstart.

Concepts

The mental model behind every Kontext integration: sessions, IDs, messages, events, and more.

Best practices

Pre-launch checklist — what to set up, what to monitor, how to get the highest fill rate.

Demos

Runnable example apps for every SDK — clone, drop in your publisher token, and run.