POST
/
v1
/
prompt_engine
/
run
import { JigsawStack } from "jigsawstack";

const jigsaw = JigsawStack({ apiKey: "your-api-key" });

const response = await jigsaw.prompt_engine.run_prompt_direct({
  "prompt": "Tell me a story about {about}",
  "inputs": [
        {
              "key": "about",
              "optional": true,
              "initial_value": "Leaning Tower of Pisa"
        }
  ],
  "return_prompt": "Return the result in a markdown format",
  "prompt_guard": [
        "sexual_content",
        "defamation"
  ],
  "input_values": {
        "about": "Santorini"
  }
})
{
  "success": true,
  "result": "Okay, here's a story about Santorini, formatted in Markdown:\n\n# The Whispers of Oia\n\nThe Aegean Sea, a sapphire canvas stretched taut beneath the fiery kiss of the setting sun, lapped gently against the volcanic shores of Santorini. Eleni, a young woman with eyes the color of the deep sea and hair like spun moonlight, sat perched on the edge of the caldera in Oia. The year was 2025, and while the world had changed, the timeless beauty of Santorini remained, a beacon of serenity in a turbulent world.\n\nEleni wasn't just admiring the view; she was listening. Listening to the whispers of Oia. Her grandmother, Yaya Sofia, had taught her to hear them. \"The stones remember,\" Yaya Sofia would say, her voice raspy with age and wisdom. \"They remember the Minoan eruption, the centuries of fishermen, the artists who came seeking inspiration. They whisper their stories to those who listen.\"\n\nEleni had always been skeptical, but tonight, the whispers seemed louder, clearer. She felt a pull, a connection to the past that resonated deep within her soul. She closed her eyes, letting the salty breeze caress her face.\n\n* * *\n\nThe whispers began to coalesce into a vision. She saw a young woman, her name was Ariadne, standing on the same spot, but centuries ago. Ariadne was a Minoan priestess, her face etched with worry. The earth trembled beneath her feet, and the air crackled with an unnatural energy. She knew, with a chilling certainty, that the volcano was about to unleash its fury.\n\nAriadne clutched a small, intricately carved obsidian amulet, a gift from her grandfather, a master craftsman. It was said to hold the spirit of the island, a protector against the forces of nature. She prayed to the gods, begging them to spare her people.\n\nThe vision shifted. Eleni saw the eruption, a cataclysmic event that reshaped the island forever. She felt the heat, the terror, the utter devastation. But amidst the chaos, she saw Ariadne, holding the amulet aloft, her face resolute.\n\n* * *\n\nEleni gasped, opening her eyes. The sun had dipped below the horizon, painting the sky in hues of orange, pink, and purple. The whispers faded, leaving her breathless and shaken.\n\nShe looked down at her own hand. Unconsciously, she had reached into her pocket and was clutching a small, smooth stone. It was obsidian, and as she held it, she felt a faint warmth, a connection to the vision she had just experienced.\n\nEleni knew then that Yaya Sofia was right. The stones did remember. And they were calling to her.\n\nOver the next few weeks, Eleni delved into the history of Santorini, poring over ancient texts and archaeological reports. She learned about the Minoan civilization, the eruption, and the enduring spirit of the island. She realized that the obsidian amulet Ariadne had held was more than just a trinket; it was a symbol of hope, a reminder that even in the face of unimaginable destruction, life could find a way.\n\nOne day, while exploring a hidden cove near Akrotiri, Eleni stumbled upon a small, crumbling shrine. It was overgrown with weeds and almost completely forgotten. As she cleared away the debris, she noticed a small indentation in the stone altar, perfectly sized for the obsidian amulet.\n\nEleni knew what she had to do. She took the obsidian stone from her pocket and placed it in the indentation. As she did, a wave of energy washed over her. She felt a sense of peace, a feeling of connection to the island and its history.\n\nThe whispers of Oia were no longer just whispers. They were a song, a celebration of resilience, a testament to the enduring power of the human spirit. Eleni, the young woman who had listened, had become a part of the story, a guardian of the island's secrets, forever bound to the whispers of Santorini. She knew her purpose now: to protect the island's history and share its stories with the world, ensuring that the whispers of Oia would never be silenced.\n",
  "message": "It is recommended to store the prompt engine and execute it using the ID rather than running it directly for the best performance and reliability. Learn more: https://jigsawstack.com/docs/api-reference/prompt-engine/create",
  "_usage": {
        "input_tokens": 67,
        "output_tokens": 1053,
        "inference_time_tokens": 6718,
        "total_tokens": 7838
  }
}
🎉 Exciting News! We’ve enhanced Prompt Engine with powerful new capabilities. Meet Interfaze - our advanced LLM that takes your AI workflows to the next level, built for debvelopers, with improved performance better organization, and enhanced features.
x-api-key
string
required
Your JigsawStack API key
Run Prompt Direct is ideal for one-time prompt usage.
For prompts that will be used multiple times, it is recommended to first Create a Prompt and then Run the Prompt for better reliability.

Header

x-api-key
string
required
Your JigsawStack API key

Body

prompt
string
required
The prompt. Maximum character limit is 500000. Prompt supports dynamic inputs. See example below.
inputs
array<object>
The prompt inputs. See example below.
return_prompt
string | array | object
How the prompt result should be returned or formatted. See examples below
prompt_guard
array<string>
Include this to guard against unsafe inputs from users. Supported values:
  • defamation
  • privacy
  • hate
  • sexual_content
  • elections
  • code_interpreter_abuse
  • indiscrimate_weapons
  • specialized_advice
input_values
object
Key-value pair for dynamic prompt variables. Each input value has a 500000 character limit
stream
boolean
If set, partial message chunk will be sent.
use_internet
boolean
Include this to allow prompt engine to use the internet.

Sample Prompt Payload

  • String return_prompt
{
    prompt: "Tell me a story about {about}",
    inputs: [
      {
        key: "about",
        optional: false,
      },
    ],
    return_prompt: "Return the result in a markdown format",
    "prompt_guard": ["sexual_content", "defamation"]
    "input_values": {
      "about": "Santorini",
    }
  }
  • Array<object> return_prompt

{
    prompt: "Tell me a story about {about}",
    inputs: [
      {
        key: "about",
        optional: false,
        initial_value: "Leaning Tower of Pisa",
      },
    ],
    return_prompt: [{ excerpt: "short story text", summary: "summary of story" }],
    "prompt_guard": ["sexual_content", "defamation"],
    "input_values": {
      "about": "Santorini",
    }
  }
  • Object return_prompt
{
    prompt: "Tell me a story about {about}",
    inputs: [
      {
        key: "about",
        optional: false,
        initial_value: "Leaning Tower of Pisa",
      },
    ],
    return_prompt: { excerpt: "short story text", summary: "summary of story" },
    "prompt_guard": ["sexual_content", "defamation"],
    "input_values": {
      "about": "Santorini",
    }
  }

Response

success
boolean
Indicates whether the call was successful.
_usage
object
Usage information for the API call.
import { JigsawStack } from "jigsawstack";

const jigsaw = JigsawStack({ apiKey: "your-api-key" });

const response = await jigsaw.prompt_engine.run_prompt_direct({
  "prompt": "Tell me a story about {about}",
  "inputs": [
        {
              "key": "about",
              "optional": true,
              "initial_value": "Leaning Tower of Pisa"
        }
  ],
  "return_prompt": "Return the result in a markdown format",
  "prompt_guard": [
        "sexual_content",
        "defamation"
  ],
  "input_values": {
        "about": "Santorini"
  }
})
{
  "success": true,
  "result": "Okay, here's a story about Santorini, formatted in Markdown:\n\n# The Whispers of Oia\n\nThe Aegean Sea, a sapphire canvas stretched taut beneath the fiery kiss of the setting sun, lapped gently against the volcanic shores of Santorini. Eleni, a young woman with eyes the color of the deep sea and hair like spun moonlight, sat perched on the edge of the caldera in Oia. The year was 2025, and while the world had changed, the timeless beauty of Santorini remained, a beacon of serenity in a turbulent world.\n\nEleni wasn't just admiring the view; she was listening. Listening to the whispers of Oia. Her grandmother, Yaya Sofia, had taught her to hear them. \"The stones remember,\" Yaya Sofia would say, her voice raspy with age and wisdom. \"They remember the Minoan eruption, the centuries of fishermen, the artists who came seeking inspiration. They whisper their stories to those who listen.\"\n\nEleni had always been skeptical, but tonight, the whispers seemed louder, clearer. She felt a pull, a connection to the past that resonated deep within her soul. She closed her eyes, letting the salty breeze caress her face.\n\n* * *\n\nThe whispers began to coalesce into a vision. She saw a young woman, her name was Ariadne, standing on the same spot, but centuries ago. Ariadne was a Minoan priestess, her face etched with worry. The earth trembled beneath her feet, and the air crackled with an unnatural energy. She knew, with a chilling certainty, that the volcano was about to unleash its fury.\n\nAriadne clutched a small, intricately carved obsidian amulet, a gift from her grandfather, a master craftsman. It was said to hold the spirit of the island, a protector against the forces of nature. She prayed to the gods, begging them to spare her people.\n\nThe vision shifted. Eleni saw the eruption, a cataclysmic event that reshaped the island forever. She felt the heat, the terror, the utter devastation. But amidst the chaos, she saw Ariadne, holding the amulet aloft, her face resolute.\n\n* * *\n\nEleni gasped, opening her eyes. The sun had dipped below the horizon, painting the sky in hues of orange, pink, and purple. The whispers faded, leaving her breathless and shaken.\n\nShe looked down at her own hand. Unconsciously, she had reached into her pocket and was clutching a small, smooth stone. It was obsidian, and as she held it, she felt a faint warmth, a connection to the vision she had just experienced.\n\nEleni knew then that Yaya Sofia was right. The stones did remember. And they were calling to her.\n\nOver the next few weeks, Eleni delved into the history of Santorini, poring over ancient texts and archaeological reports. She learned about the Minoan civilization, the eruption, and the enduring spirit of the island. She realized that the obsidian amulet Ariadne had held was more than just a trinket; it was a symbol of hope, a reminder that even in the face of unimaginable destruction, life could find a way.\n\nOne day, while exploring a hidden cove near Akrotiri, Eleni stumbled upon a small, crumbling shrine. It was overgrown with weeds and almost completely forgotten. As she cleared away the debris, she noticed a small indentation in the stone altar, perfectly sized for the obsidian amulet.\n\nEleni knew what she had to do. She took the obsidian stone from her pocket and placed it in the indentation. As she did, a wave of energy washed over her. She felt a sense of peace, a feeling of connection to the island and its history.\n\nThe whispers of Oia were no longer just whispers. They were a song, a celebration of resilience, a testament to the enduring power of the human spirit. Eleni, the young woman who had listened, had become a part of the story, a guardian of the island's secrets, forever bound to the whispers of Santorini. She knew her purpose now: to protect the island's history and share its stories with the world, ensuring that the whispers of Oia would never be silenced.\n",
  "message": "It is recommended to store the prompt engine and execute it using the ID rather than running it directly for the best performance and reliability. Learn more: https://jigsawstack.com/docs/api-reference/prompt-engine/create",
  "_usage": {
        "input_tokens": 67,
        "output_tokens": 1053,
        "inference_time_tokens": 6718,
        "total_tokens": 7838
  }
}