NPC Interaction
Base URL: https://loremind.peekgames.dev/api/loremind/v1
Last verified against LoreMind v1.0.67 (August 2026).
The runtime NPC endpoint is the stable integration surface for your game — call it from your backend with a Server Key. Want to try it first? See the API Quickstart.
POST /npc/interact
Generate an NPC response to player input. This is the primary endpoint for NPC interactions.
Authentication: Server Key (sk_server_*)
Request Body
{
// Required
text: string; // Player's message (max 2,000 chars)
entityMindId: string; // Entity Mind ID (provides name, personality, knowledge filters)
playerId: string; // Your player identifier (max 255 chars; used for rate limiting,
// memory, and conversation tracking)
// Optional
context?: {
location?: string; // Current location name
locationDetails?: string; // Location description
timeOfDay?: string; // "morning", "evening", etc.
weather?: string; // Weather conditions
atmosphere?: string; // Scene mood ("peaceful", "tense", ...)
situation?: string; // Interaction type ("shopping", "combat", ...)
npcMood?: string; // NPC's current mood
npcActivity?: string; // What the NPC is doing
playerAppearance?: string; // How player looks to NPC
playerReputation?: string; // How the NPC views the player
playerVisibleItems?: string[]; // Notable items the player carries
nearbyCharacters?: string[]; // Other characters present
nearbyObjects?: string[]; // Notable objects present
recentEvents?: string[]; // Recent world events
custom?: string; // Freeform game-specific context (max 500 chars)
};
memory?: {
retrieve?: boolean; // Retrieve past memories for this player (default: false)
};
activeKnowledgeTags?: string[]; // Narrow which lore the NPC can reference (by tag name).
// Max 50 tags, 100 chars each. Can only restrict the
// Entity Mind's configured tags, never expand them.
conversationHistory?: Array<{ // Max 50 messages, 10,000 chars per message.
role: "user" | "assistant"; // The server keeps the most recent messages up to the
content: string; // project's max session length.
}>;
}The request schema is strict: unknown fields are rejected with a 400 error. String fields inside context are capped at 200 characters (500 for custom), arrays at 10 items (100 characters per item), and the context block at 2,000 characters overall.
Response
{
success: true;
response: string; // NPC's response text
character: string; // Character name
metadata: {
memoryCheckpoint?: boolean; // True when session hit max length and memories were auto-saved
warnings?: string[]; // Non-fatal notices (e.g. ignored knowledge tags)
};
}Example Request
curl -X POST https://loremind.peekgames.dev/api/loremind/v1/npc/interact \
-H "Authorization: Bearer sk_server_your_key" \
-H "Content-Type: application/json" \
-d '{
"text": "What can you tell me about the dragon?",
"entityMindId": "em_abc123",
"playerId": "steam_76561198012345678",
"context": {
"location": "Blacksmith Shop",
"timeOfDay": "evening",
"weather": "rainy"
},
"memory": {
"retrieve": true
},
"activeKnowledgeTags": ["dragon-war", "village-history"]
}'Example Response
{
"success": true,
"response": "The dragon? Aye, I've heard the rumors. Spotted near the old watchtower, they say. If you're thinking of going after it, you'll need better steel than what you're carrying.",
"character": "Grom the Blacksmith",
"metadata": {}
}Error Responses
| Status | Error | Description |
|---|---|---|
| 400 | Missing or empty text | No player message provided |
| 400 | Text too long | Message exceeds 2,000 characters |
| 400 | Missing entityMindId | entityMindId is required |
| 400 | Missing playerId | playerId is required for API key authentication |
| 400 | Unknown field(s) | Request contains fields not in the schema |
| 400 | Entity Mind has no knowledge tags configured | Configure knowledge tags in the dashboard first |
| 401 | Invalid API key | API key is missing, malformed, or revoked |
| 402 | Insufficient credits | Team balance too low |
| 403 | Invalid authentication | Editor keys cannot be used; use a Server Key |
| 404 | Project not found | Invalid project or key |
| 404 | Entity Mind not found | Invalid entityMindId |
| 429 | Rate limit exceeded | Too many requests (see Retry-After header and retryAfter field) |
| 503 | Generation failed | LLM error (retry) |
Rate limit defaults and 429 behavior are covered in Errors & Rate Limits.
Next Steps
- API Quickstart - Try this endpoint with curl
- Server Integration - Production patterns for Nakama, PlayFab, Node.js, and Mirror
- Runtime Context - What each context field does
- Long-Term Memory - How memory retrieval works
Last updated on