Pricing

Integration · SDK

kt

Kotlin

The Kotlin client ships on Maven Central as ai.metapolicy:sdk. JVM 11+ for backend, Android API 21+ for mobile. Coroutines-native; the suspend functions slot directly into your existing ViewModel scope or backend handler.

The contract

What flows in

  • Decide requests as suspend functions returning Result
  • Reward events emitted through a single suspend function call
  • Network handled by OkHttp; you can supply your own client if your app already does

What flows out

  • Assignment payload + propensity logged at the call site
  • Errors typed: network, auth, schema validation

Setup

  1. 01Add ai.metapolicy:sdk to your build.gradle.kts dependencies
  2. 02Initialise the client in your Application onCreate / backend bootstrap with an environment-scoped key
  3. 03Call client.decide(experiment, userId, context) from any coroutine scope
  4. 04Emit rewards via client.reward(userId, experiment, rewardSpec, value)
  5. 05Optional: wire the Compose-friendly @Composable rememberDecision(...) helper for declarative paywall UIs

Android specifics

Decisions are cached in a process-local LRU keyed on (experiment, userId, contextHash). The cache is invalidated on app foregrounding by default, which keeps the propensity honest after long pauses.

Network calls go through OkHttp by default. If your app already runs OkHttp with custom interceptors (e.g. for tracing), you can supply that client instance at init time.

Wire Kotlin in a 30-minute call.

We pair with your engineer, ship the integration live, and run the first decision on your stack.

Book the call