gamemantra.aigamemantra.ai|Developer Docs

Developer Documentation · Getting Started

Client Init

Integrate the gamemantra SDK with a single initialisation call. The SDK handles offer delivery, economy telemetry, and UI rendering — no additional setup required beyond this.

📦

Zero-Friction Integration Package

New

Download a pre-configured ZIP from the dashboard — api_key, game_id, and base_url are injected automatically. Drag the folder into Unity or Unreal and press Play. No copy-paste required.

👤

Player identity (gamemantra_config.json)

auto_login, player_id_source (device, advertising_id, custom, jwt) — same text as GameMantraConfig.cs in your download.

Prerequisites

  • API key from the dashboard — gm_live_sk_* (production) or gm_test_sk_* (sandbox)
  • Game UUID from Dashboard → Games
  • Platform: Unity (C#), Unreal (C++), or Flutter (Dart)
  • Android arm64 — Phase 1 target only
1

Initialise the SDK

Call once on game launch — before any scene or UI loads. The SDK connects to the backend, fetches your kill-switch state, and registers player callbacks.

gamemantra_init.cpp
#include <gamemantra.h>

// 1. Build the config JSON
const char* config = R"({
  "api_key":     "gm_live_sk_YOUR_KEY",
  "game_id":     "YOUR_GAME_UUID",
  "environment": "production",
  "base_url":    "https://api.gamemantra.ai"
})";

// 2. Initialise the SDK (call once on game launch)
GM_Result result = GM_Init(config);

if (result != GM_OK) {
  // Handle error — see GM_Result enum
}
2

Start a Session

After GM_Init succeeds, start a session with a player ID and session UUID. This fires a session_start telemetry event and enables the offer pipeline.

session_start
// Called automatically by GM_Init — fires session_start event
// and fetches the current kill-switch level from the server.
GM_InitSession(
  game_id,    // UUID string
  player_id,  // your player's external ID
  session_id, // UUID for this session
  api_key
);
3

Verify Initialisation

Check the device log for the boot sequence. All 7 Dart callbacks must register within ~100ms of engine start.

adb logcat -s FlutterUnity:V
GM_Init: result=0 ← 0=GM_OK
GMApiClient: GET /v1/sdk/status/... → http=200
setDartFunctionPtr: 'GM_Dart_OnSDKReady' registered
setDartFunctionPtr: 'GM_Dart_OnOfferReceived' registered
setDartFunctionPtr: 'GM_Dart_OnBalanceUpdate' registered
setDartFunctionPtr: 'GM_Dart_OnInventoryUpdate' registered
setDartFunctionPtr: 'GM_Dart_OnNoOffer' registered
setDartFunctionPtr: 'GM_Dart_OnKillSwitchChanged' registered
setDartFunctionPtr: 'GM_Dart_OnConfigUpdated' registered
[CB] present #1 *** FIRST FRAME *** — render pipeline active
4

Shadow Mode (Auto-enabled)

After initialisation, your game automatically enters Shadow Mode. The AI computes offers silently — no offer is shown to players until you promote to Assisted mode from the dashboard.

Shadow

AI runs silently. No player impact.

Weeks 1–8

Assisted

Every offer needs your approval.

Weeks 9–16

Autonomous

AI acts within your guardrail bounds.

Week 17+