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
{
"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.
[
{
"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
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.
[
{
"type": "npc.text",
"content": "Of course! I'd be happy to help. What do you need assistance with?"
}
]
Understanding the Perform API
NPC Identification: Each request requires an
npcId
to identify which NPC the player is interacting with.Conversation History: The
history
array allows you to provide context for the interaction, including both player and NPC messages.Dynamic Responses: The NPC can respond with text messages or trigger function calls based on its capabilities.
Capability Integration: The API automatically integrates the NPC's capabilities as potential actions it can take during the interaction.