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

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

const response = await jigsaw.prompt_engine.run_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 sun, a molten coin in the sky, beat down on Eleni's whitewashed balcony in Oia. Below, the caldera shimmered, a sapphire canvas dotted with the sails of tiny boats. Eleni, her face etched with the wisdom of seventy summers, clutched a string of worry beads, their click-clack a rhythmic counterpoint to the distant crash of waves.\n\nShe wasn't worried about the tourists, though their numbers swelled each year, their cameras snapping at the iconic blue domes and the fiery sunsets. Eleni loved the energy they brought, the life they breathed into the ancient stones. No, her worry was older, deeper, woven into the very fabric of Santorini.\n\nIt was the whispers.\n\nThey started subtly, a faint hum in the wind, a rustle in the olive trees that sounded like voices. At first, she dismissed them as the tricks of an aging mind. But they grew louder, more insistent, carrying fragments of forgotten stories, echoes of the Minoan eruption that had birthed the caldera millennia ago.\n\nEleni's grandmother, a woman steeped in the island's lore, had warned her about the whispers. \"The volcano remembers,\" she'd said, her eyes wide with a fear that transcended generations. \"It sleeps, but it never forgets. And sometimes, it speaks.\"\n\nThe whispers spoke of a time before the tourists, before the vineyards, before the whitewashed houses. They spoke of Akrotiri, the thriving Minoan city buried beneath layers of ash, a city frozen in time, waiting to be awakened.\n\nOne day, a young archaeologist named Nikos arrived in Oia. He was researching the Minoan civilization, drawn to Santorini by the promise of uncovering new secrets. Eleni, hesitant at first, found herself drawn to his passion, his respect for the island's history.\n\nShe told him about the whispers, about her grandmother's warnings. Nikos, initially skeptical, listened with growing interest. He had noticed anomalies in his readings, subtle shifts in the earth's magnetic field, unexplained tremors that the official reports dismissed as minor seismic activity.\n\nTogether, they began to investigate. They explored hidden caves, deciphered ancient symbols carved into the volcanic rock, and listened to the whispers, trying to understand their meaning.\n\nThey discovered that the whispers were not a warning of another eruption, but a plea. The spirit of Akrotiri, trapped beneath the ash, yearned to be remembered, to share its story with the world.\n\nNikos, using his modern technology, amplified the whispers, broadcasting them in a way that others could hear. He created an immersive exhibit at the Akrotiri archaeological site, allowing visitors to experience the city as it once was, to hear the voices of its people.\n\nThe exhibit was a sensation. Tourists flocked to Akrotiri, not just to see the ruins, but to connect with the past, to hear the whispers of a lost civilization.\n\nEleni, standing on her balcony, listened to the murmur of voices rising from the site below. The whispers were still there, but they were different now. They were no longer filled with sorrow and longing, but with a sense of peace, of fulfillment.\n\nThe volcano still slept, but the spirit of Akrotiri had finally awakened, its story echoing across the caldera, carried on the Aegean wind, a testament to the enduring power of memory and the whispers of Santorini. The sun dipped below the horizon, painting the sky in hues of orange and purple, a breathtaking spectacle that Eleni had witnessed countless times. But tonight, it felt different, more profound, as if the island itself was breathing a sigh of relief. The whispers had been heard.\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": 995,
        "inference_time_tokens": 5670,
        "total_tokens": 6732
  }
}
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.

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.

import { JigsawStack } from "jigsawstack";

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

const response = await jigsaw.prompt_engine.run_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 sun, a molten coin in the sky, beat down on Eleni's whitewashed balcony in Oia. Below, the caldera shimmered, a sapphire canvas dotted with the sails of tiny boats. Eleni, her face etched with the wisdom of seventy summers, clutched a string of worry beads, their click-clack a rhythmic counterpoint to the distant crash of waves.\n\nShe wasn't worried about the tourists, though their numbers swelled each year, their cameras snapping at the iconic blue domes and the fiery sunsets. Eleni loved the energy they brought, the life they breathed into the ancient stones. No, her worry was older, deeper, woven into the very fabric of Santorini.\n\nIt was the whispers.\n\nThey started subtly, a faint hum in the wind, a rustle in the olive trees that sounded like voices. At first, she dismissed them as the tricks of an aging mind. But they grew louder, more insistent, carrying fragments of forgotten stories, echoes of the Minoan eruption that had birthed the caldera millennia ago.\n\nEleni's grandmother, a woman steeped in the island's lore, had warned her about the whispers. \"The volcano remembers,\" she'd said, her eyes wide with a fear that transcended generations. \"It sleeps, but it never forgets. And sometimes, it speaks.\"\n\nThe whispers spoke of a time before the tourists, before the vineyards, before the whitewashed houses. They spoke of Akrotiri, the thriving Minoan city buried beneath layers of ash, a city frozen in time, waiting to be awakened.\n\nOne day, a young archaeologist named Nikos arrived in Oia. He was researching the Minoan civilization, drawn to Santorini by the promise of uncovering new secrets. Eleni, hesitant at first, found herself drawn to his passion, his respect for the island's history.\n\nShe told him about the whispers, about her grandmother's warnings. Nikos, initially skeptical, listened with growing interest. He had noticed anomalies in his readings, subtle shifts in the earth's magnetic field, unexplained tremors that the official reports dismissed as minor seismic activity.\n\nTogether, they began to investigate. They explored hidden caves, deciphered ancient symbols carved into the volcanic rock, and listened to the whispers, trying to understand their meaning.\n\nThey discovered that the whispers were not a warning of another eruption, but a plea. The spirit of Akrotiri, trapped beneath the ash, yearned to be remembered, to share its story with the world.\n\nNikos, using his modern technology, amplified the whispers, broadcasting them in a way that others could hear. He created an immersive exhibit at the Akrotiri archaeological site, allowing visitors to experience the city as it once was, to hear the voices of its people.\n\nThe exhibit was a sensation. Tourists flocked to Akrotiri, not just to see the ruins, but to connect with the past, to hear the whispers of a lost civilization.\n\nEleni, standing on her balcony, listened to the murmur of voices rising from the site below. The whispers were still there, but they were different now. They were no longer filled with sorrow and longing, but with a sense of peace, of fulfillment.\n\nThe volcano still slept, but the spirit of Akrotiri had finally awakened, its story echoing across the caldera, carried on the Aegean wind, a testament to the enduring power of memory and the whispers of Santorini. The sun dipped below the horizon, painting the sky in hues of orange and purple, a breathtaking spectacle that Eleni had witnessed countless times. But tonight, it felt different, more profound, as if the island itself was breathing a sigh of relief. The whispers had been heard.\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": 995,
        "inference_time_tokens": 5670,
        "total_tokens": 6732
  }
}