Using Templates

Jasper's Templates endpoint is a powerful tool for generating content from over 70 default templates as well as any custom templates built exclusively for your organization.

This guide will walk you through the process of retrieving template data and running a template to get your desired AI output.


Retrieving Template Data

Before running a template you will first need to retrieve the ID and fields related to the template you would like to run.

You can retrieve all templates in bulk with their corresponding metadata or if you know your template's id, you can retrieve data for an individual template.

For example, if you are retrieving data from the Product Description template you would call the Retrieve a Template by ID endpoint using the templateId skl_32AFF124B6404DA09CD27EE3ACC0D733.

Your response body should look like this:

{
			"id": "skl_32AFF124B6404DA09CD27EE3ACC0D733",
			"name": "Product Description",
			"description": "Create compelling product descriptions to be used on websites, emails and social media.",
			"inputSchema": [
				{
					"id": "productName",
					"component": "text",
					"type": "string",
					"label": "Company/Product Name",
					"required": true,
					"placeholder": "Pushpress",
					"maxLength": 80
				},
				{
					"id": "productDescription",
					"component": "textarea",
					"type": "string",
					"label": "Tell us about the product",
					"required": true,
					"placeholder": "Gym software that helps gym owners manage their gym with less stress and make more money.",
					"maxLength": 800
				},
				{
					"id": "tone",
					"component": "text",
					"type": "string",
					"label": "Tone of voice",
					"required": false,
					"placeholder": "Witty",
					"maxLength": 80
				}
			]
		},

Running a Template

You will need three pieces of information to run a template:

  1. Your templateId (explained in the previous section)
  2. The inputSchema that corresponds to the fields of the template
  3. The variationCount you would like to include in your request that correspond to how many AI outputs you will be generating

Understanding Input Schema

Using the response body from the Product Description above as an example, review the inputSchema section:

"inputSchema": [
				{
					"id": "productName",
					"component": "text",
					"type": "string",
					"label": "Company/Product Name",
					"required": true,
					"placeholder": "Pushpress",
					"maxLength": 80
				},
				{
					"id": "productDescription",
					"component": "textarea",
					"type": "string",
					"label": "Tell us about the product",
					"required": true,
					"placeholder": "Gym software that helps gym owners manage their gym with less stress and make more money.",
					"maxLength": 800
				},
				{
					"id": "tone",
					"component": "text",
					"type": "string",
					"label": "Tone of voice",
					"required": false,
					"placeholder": "Witty",
					"maxLength": 80
				}
			]

Rows 3, 12, and 21 (the "id" key in each object) show the id of the fields that will be used later as input parameters

  • productName
  • productDescription
  • tone

Rows 6, 15, and 24 (the "label" key in each object) show the names of the fields associated with the template.

  • Company/Product Name
  • Tell us about the product
  • Tone of voice

Each field also includes an accompanying set of metadata such as the type of field (component), whether it is required (required), and importantly the maximum length of the field (maxLength).

In considering the type of the field, whether it is required, and maximum field length, you will then input the IDs of these fields as part of the request parameters when running the template.

More specifically when using the Run template endpoint, you will input each field's ID as a newKey with its corresponding value.

Your body parameters would look something like this for this example using the Product Description template:

πŸ“˜

In Summary

The inputSchema found in a response from getting a template need to be used as inputs in the body parameter of your request to run a given template.


Understanding Output Variations

Now that you have your template ID and your required input fields, you now need to define your outputCount. This field indicates how many variations you would like to generate as AI outputs.

πŸ’‘

Important note

outputCount is set to 1 variation by default with a maximum of up to 10 variations.

Now that you know the ID, the fields, and the output count of your template, you are ready to run your template and enjoy the power of generative AI.