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": false,
              "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 shimmering sapphire under the relentless Grecian sun, lapped gently against the black volcanic sand of Perissa beach. Eleni, a young woman with eyes the color of the deep sea and hair like spun moonlight, traced patterns in the sand with her bare toes. She wasn't a tourist, though she could easily pass for one. Eleni was a daughter of Santorini, her roots intertwined with the island's volcanic soil and its ancient, whispered secrets.\n\nHer grandmother, Yaya Irini, lived in Oia, the village perched precariously on the caldera's edge, a cascade of whitewashed houses clinging to the cliff face. Yaya Irini was a keeper of stories, tales passed down through generations, tales of the Minoan eruption that shaped the island, tales of gods and heroes, and tales of the island's enduring spirit.\n\nEleni visited Yaya Irini every week. Today, she carried a basket filled with fresh figs and a bottle of local Vinsanto wine. The climb to Oia was arduous, a winding path that snaked upwards, past vibrant bougainvillea and the ever-present scent of thyme. But the view, oh, the view! It was a panorama of breathtaking beauty, a constant reminder of the island's dramatic past and its vibrant present.\n\nReaching Yaya Irini's house, Eleni found her grandmother sitting on her small balcony, overlooking the caldera. Her face, etched with wrinkles like the ancient maps of the island, was turned towards the setting sun.\n\n\"Yaya,\" Eleni greeted, kissing her cheek.\n\nYaya Irini smiled, her eyes twinkling. \"Eleni mou, you are here. Come, sit. The sun is painting the sky with fire.\"\n\nThey sat in comfortable silence, watching the sun dip below the horizon, painting the whitewashed houses in hues of orange, pink, and purple. As the first stars began to appear, Eleni asked, \"Yaya, tell me a story. Tell me about the whispers of Oia.\"\n\nYaya Irini took a sip of her Vinsanto. \"Oia,\" she began, her voice raspy but strong, \"is a place where the past and present dance together. The stones themselves remember the eruption, the Minoan civilization swallowed by the sea. Sometimes, if you listen closely, you can hear their whispers on the wind.\"\n\nShe continued, \"They say that after the eruption, the survivors clung to the highest point of the island, seeking refuge. They rebuilt their lives, brick by brick, dream by dream. They learned to live with the volcano, to respect its power, and to draw strength from its resilience.\"\n\n\"And the whispers?\" Eleni prompted.\n\n\"The whispers are the echoes of their lives,\" Yaya Irini said, her gaze fixed on the darkening caldera. \"They are the laughter of children playing in the narrow streets, the songs of fishermen returning with their catch, the prayers of women hoping for safe passage for their loved ones. They are the stories of love and loss, of joy and sorrow, woven into the very fabric of Oia.\"\n\nShe paused, then added, \"But the whispers also carry a warning. A reminder that the volcano sleeps, but it never forgets. We must always be mindful of its power, and we must always cherish the beauty and fragility of this island.\"\n\nAs the night deepened, Eleni listened to her grandmother's stories, feeling a deep connection to her ancestors and to the island that had shaped them. She understood that the whispers of Oia were not just echoes of the past, but also a guide for the future. They were a reminder to live with passion, to embrace beauty, and to never forget the power of the earth beneath their feet.\n\nLeaving Yaya Irini's house, Eleni walked through the silent streets of Oia, the stars her only companions. She listened closely, and for a moment, she thought she could hear the faintest of whispers, carried on the wind, a chorus of voices telling the story of Santorini, a story of resilience, beauty, and the enduring power of the human spirit. The whispers of Oia, she knew, would stay with her forever.\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": 68,
        "output_tokens": 1070,
        "inference_time_tokens": 5935,
        "total_tokens": 7073
  }
}
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": false,
              "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 shimmering sapphire under the relentless Grecian sun, lapped gently against the black volcanic sand of Perissa beach. Eleni, a young woman with eyes the color of the deep sea and hair like spun moonlight, traced patterns in the sand with her bare toes. She wasn't a tourist, though she could easily pass for one. Eleni was a daughter of Santorini, her roots intertwined with the island's volcanic soil and its ancient, whispered secrets.\n\nHer grandmother, Yaya Irini, lived in Oia, the village perched precariously on the caldera's edge, a cascade of whitewashed houses clinging to the cliff face. Yaya Irini was a keeper of stories, tales passed down through generations, tales of the Minoan eruption that shaped the island, tales of gods and heroes, and tales of the island's enduring spirit.\n\nEleni visited Yaya Irini every week. Today, she carried a basket filled with fresh figs and a bottle of local Vinsanto wine. The climb to Oia was arduous, a winding path that snaked upwards, past vibrant bougainvillea and the ever-present scent of thyme. But the view, oh, the view! It was a panorama of breathtaking beauty, a constant reminder of the island's dramatic past and its vibrant present.\n\nReaching Yaya Irini's house, Eleni found her grandmother sitting on her small balcony, overlooking the caldera. Her face, etched with wrinkles like the ancient maps of the island, was turned towards the setting sun.\n\n\"Yaya,\" Eleni greeted, kissing her cheek.\n\nYaya Irini smiled, her eyes twinkling. \"Eleni mou, you are here. Come, sit. The sun is painting the sky with fire.\"\n\nThey sat in comfortable silence, watching the sun dip below the horizon, painting the whitewashed houses in hues of orange, pink, and purple. As the first stars began to appear, Eleni asked, \"Yaya, tell me a story. Tell me about the whispers of Oia.\"\n\nYaya Irini took a sip of her Vinsanto. \"Oia,\" she began, her voice raspy but strong, \"is a place where the past and present dance together. The stones themselves remember the eruption, the Minoan civilization swallowed by the sea. Sometimes, if you listen closely, you can hear their whispers on the wind.\"\n\nShe continued, \"They say that after the eruption, the survivors clung to the highest point of the island, seeking refuge. They rebuilt their lives, brick by brick, dream by dream. They learned to live with the volcano, to respect its power, and to draw strength from its resilience.\"\n\n\"And the whispers?\" Eleni prompted.\n\n\"The whispers are the echoes of their lives,\" Yaya Irini said, her gaze fixed on the darkening caldera. \"They are the laughter of children playing in the narrow streets, the songs of fishermen returning with their catch, the prayers of women hoping for safe passage for their loved ones. They are the stories of love and loss, of joy and sorrow, woven into the very fabric of Oia.\"\n\nShe paused, then added, \"But the whispers also carry a warning. A reminder that the volcano sleeps, but it never forgets. We must always be mindful of its power, and we must always cherish the beauty and fragility of this island.\"\n\nAs the night deepened, Eleni listened to her grandmother's stories, feeling a deep connection to her ancestors and to the island that had shaped them. She understood that the whispers of Oia were not just echoes of the past, but also a guide for the future. They were a reminder to live with passion, to embrace beauty, and to never forget the power of the earth beneath their feet.\n\nLeaving Yaya Irini's house, Eleni walked through the silent streets of Oia, the stars her only companions. She listened closely, and for a moment, she thought she could hear the faintest of whispers, carried on the wind, a chorus of voices telling the story of Santorini, a story of resilience, beauty, and the enduring power of the human spirit. The whispers of Oia, she knew, would stay with her forever.\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": 68,
        "output_tokens": 1070,
        "inference_time_tokens": 5935,
        "total_tokens": 7073
  }
}