Skip to main content
This page follows one user message from your client to the ad that appears next to the answer. For the terms, see Core concepts.

The request flow

  1. The user sends a message. Your client calls gravityContext() to collect the session and device data, and sends it to your server with the message.
  2. Your server starts the ad request with gravity.getAds() at the same time as the model call. In the SDK examples, the server streams the model response first and waits for the ad only at the end, so the ad request does not hold up the answer.
  3. The Gravity engine compares the conversation with active campaigns, runs an auction, and returns the winning ad.
  4. Your server appends the ad to the stream, and your client shows it.
The engine gives each ad request up to 4 seconds. If it can’t finish in that time, it returns 204 No Content (no ad), and the SDKs return an empty ads list. The SDKs also apply their own client timeout, which you can change.

Contextual matching

Gravity matches on context, not keywords. What the engine uses: Publishers set the relevancy threshold: a higher value shows fewer, closer matches.

How publishers earn

Publishers earn revenue on a CPM or CPC basis, depending on the campaign. The rate is not fixed. Your effective CPM (eCPM) depends on what advertisers pay for the ads you show, which Payouts and analytics explains. Gravity counts an impression when the ad’s impUrl is loaded. The SDK components load it for you once the ad is on screen (for example, the React components wait until the ad enters the viewport). If you draw ads yourself, load impUrl once when you show the ad.

Next steps

Build the integration with the publisher quickstart, or look up a term in Core concepts.