Skip to Content
DocsLoremind SdkGetting Started

Getting Started

This guide covers two paths:

  1. Quick prototype - Get an NPC talking in 10 minutes using Direct Client mode
  2. Production / multiplayer - Integrate through your game server using Server Mediated mode

Prerequisites


Quick Prototype (Direct Client)

Use this to test NPC behavior quickly. For production games, use Server Mediated mode instead.

Step 1: Create an Entity Mind

  1. Go to loremind.peekgames.dev 
  2. Click Entity Minds > Create
  3. Fill in:
    • Name: Innkeeper Garrick
    • Personality: Friendly tavern keeper who loves gossip. Knows everyone in town.
  4. Click Create

Step 2: Add the Component

  1. Create a new empty GameObject in Unity
  2. Name it Innkeeper
  3. Add Component > LoreMind NPC
  4. Select Innkeeper Garrick from the Entity Mind dropdown

Step 3: Talk to Your NPC

Create TalkToNPC.cs:

using UnityEngine; using Peek.LoreMind; public class TalkToNPC : MonoBehaviour { [SerializeField] private LoreMindNPC npc; void Start() => TestNPC(); async void TestNPC() { Debug.Log("Asking NPC a question..."); var response = await npc.RespondAsync("Hello! What's your name?"); if (response != null && response.success) { Debug.Log($"NPC says: {response.response}"); } else { Debug.LogError($"Error: {response?.message ?? "No response"}"); } } }

Press Play and check the Console. You should see a response.

Adding Context

NPCs give better responses with context:

npc.SetLocation("The Rusty Anvil Tavern", "Crowded and noisy"); npc.Context.timeOfDay = "evening"; var response = await npc.RespondAsync("Is it always this busy?"); // NPC responds knowing they're in a busy tavern

When to Use Direct Client

  • Prototypes and proof of concept
  • Single-player games without player accounts
  • Quick testing during development

Direct Client has built-in safeguards (short-lived tokens, per-device rate limits) but no player identity.


Production / Multiplayer (Server Mediated)

For production multiplayer games, integrate LoreMind through your game server.

Benefits:

BenefitDescription
Full controlYour server decides who can interact and when
Your auth systemIntegrate with Steam, Epic, custom accounts
Player identityTie interactions to authenticated players
Custom logicAdd your own validation, logging, limits
Secure key storageAPI key stays on your server

Note: Long-term memory requires Server Mediated mode with playerId. The client can’t be trusted to honestly identify itself.

Architecture Overview

Step 1: Create Server API Key

  1. Go to loremind.peekgames.dev 
  2. Navigate to Projects > Your Project > API Keys
  3. Create a Server Key
  4. Store securely (environment variable, secrets manager)

Step 2: Implement Server Endpoint

Example in C# (ASP.NET Core):

[ApiController] [Route("api/npc")] public class NPCController : ControllerBase { private readonly HttpClient _http; private readonly IGameStateService _gameState; public NPCController(IHttpClientFactory factory, IGameStateService gameState) { _http = factory.CreateClient("LoreMind"); _gameState = gameState; } [HttpPost("interact")] [Authorize] // Your auth - Steam, Epic, custom public async Task<IActionResult> Interact([FromBody] NPCRequest req) { var playerId = User.GetPlayerId(); var gameContext = await _gameState.GetContext(playerId, req.LocationId); var payload = new { text = req.Message, entityMindId = req.EntityMindId, playerId = playerId, memory = new { retrieve = true }, context = new { location = gameContext.Location.Name, timeOfDay = gameContext.TimeOfDay, playerReputation = gameContext.PlayerReputation, recentEvents = gameContext.RecentEvents } }; var response = await _http.PostAsJsonAsync("npc/interact", payload); var result = await response.Content.ReadFromJsonAsync<LoreMindResponse>(); return Ok(new { dialogue = result.Response }); } }

Configure the HttpClient:

services.AddHttpClient("LoreMind", client => { client.BaseAddress = new Uri("https://loremind.peekgames.dev/api/loremind/v1/"); client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}"); });

Step 3: Unity Client

The Unity client calls your server, not LoreMind directly:

public class NPCClient : MonoBehaviour { [SerializeField] private string serverUrl = "https://api.yourgame.com"; public async Task<string> TalkToNPC(string entityMindId, string message) { var request = new { entityMindId, message, locationId = Player.CurrentLocation }; using var webRequest = UnityWebRequest.Post( $"{serverUrl}/api/npc/interact", JsonUtility.ToJson(request), "application/json"); webRequest.SetRequestHeader("Authorization", $"Bearer {PlayerAuth.Token}"); await webRequest.SendWebRequest(); if (webRequest.result != UnityWebRequest.Result.Success) { return null; } var response = JsonUtility.FromJson<NPCResponse>(webRequest.downloadHandler.text); return response.dialogue; } }

Step 4: Rate Limiting (Your Control)

Implement rate limiting in your server:

// In your controller if (!await _rateLimiter.TryAcquire(playerId)) { return StatusCode(429, "Too many requests"); }

See the Server Integration Guide for complete patterns including:

  • Conversation session management
  • Error handling and fallbacks
  • Cost monitoring
  • Deployment configuration

Next Steps

For Prototyping

For Production

Creating Content

Last updated on