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

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

const response = await jigsaw.prompt_engine.create({
  "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"
  ]
})
{
  "success": true,
  "prompt_engine_id": "27e9ca8a-a6a5-4c21-8ef3-4a95b9050ee3",
  "optimized_prompt": "Create an engaging and imaginative story centered around the theme of {about}, incorporating vivid descriptions and compelling characters.",
  "_usage": {
        "input_tokens": 58,
        "output_tokens": 59,
        "inference_time_tokens": 1390,
        "total_tokens": 1507
  }
}

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
optimize_prompt
boolean

Include this to optimize the prompt for best results. True by default.

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,
        initial_value: "Leaning Tower of Pisa",
      },
    ],
    return_prompt: "Return the result in a markdown format",
    "prompt_guard": ["sexual_content", "defamation"]
  }
  • 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"]
  }
  • 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"]
  }
x-api-key
string
required

Your JigsawStack API key

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.create({
  "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"
  ]
})
{
  "success": true,
  "prompt_engine_id": "27e9ca8a-a6a5-4c21-8ef3-4a95b9050ee3",
  "optimized_prompt": "Create an engaging and imaginative story centered around the theme of {about}, incorporating vivid descriptions and compelling characters.",
  "_usage": {
        "input_tokens": 58,
        "output_tokens": 59,
        "inference_time_tokens": 1390,
        "total_tokens": 1507
  }
}