Skip to content

Perform API

The Perform API allows you to interact with NPCs (Non-Player Characters) and execute their capabilities. This API is essential for creating dynamic and interactive experiences within your application.

The Perform Request object

json
{
  "npcId": "string", // The unique identifier of the NPC
  "history": [
    {
      "role": "player", // The role of the message sender ["player" | "npc"]
      "content": "string" // The content of the message
    }
  ]
}

The Perform Response object

The response is an array of NPC actions, which can be either text messages or function calls.

json
[
  {
    "type": "text",
    "content": "string" // The text content of the NPC's response
  },
  {
    "type": "function",
    "name": "string", // The name of the function to be called
    "input": {} // An object containing the function's input parameters
  }
]

Perform an NPC interaction

POST https://api.mindforge.ai/perform

This endpoint allows you to interact with an NPC, providing the conversation history and receiving the NPC's response.

Example

sh
curl -X POST https://api.mindforge.ai/perform \
  -H "Content-Type: application/json" \
  -d '{
    "npcId": "npc_SLDCt7dkq16AG0w7",
    "history": [
      {
        "role": "player",
        "content": "Hello, can you help me?"
      }
    ]
  }'

Response

The API will return an array of NPC actions, which can include text responses and function calls based on the NPC's capabilities.

json
[
  {
    "type": "npc.text",
    "content": "Of course! I'd be happy to help. What do you need assistance with?"
  }
]

Understanding the Perform API

  1. NPC Identification: Each request requires an npcId to identify which NPC the player is interacting with.

  2. Conversation History: The history array allows you to provide context for the interaction, including both player and NPC messages.

  3. Dynamic Responses: The NPC can respond with text messages or trigger function calls based on its capabilities.

  4. Capability Integration: The API automatically integrates the NPC's capabilities as potential actions it can take during the interaction.