Get Prompt Template by ID
curl --request POST \
--url https://api.promptlayer.com/prompt-templates/{identifier} \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"version": 1,
"workspace_id": 123,
"label": "<string>",
"input_variables": {},
"metadata_filters": {},
"model": "<string>",
"model_parameter_overrides": {}
}
'import requests
url = "https://api.promptlayer.com/prompt-templates/{identifier}"
payload = {
"version": 1,
"workspace_id": 123,
"label": "<string>",
"input_variables": {},
"metadata_filters": {},
"model": "<string>",
"model_parameter_overrides": {}
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
version: 1,
workspace_id: 123,
label: '<string>',
input_variables: {},
metadata_filters: {},
model: '<string>',
model_parameter_overrides: {}
})
};
fetch('https://api.promptlayer.com/prompt-templates/{identifier}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.promptlayer.com/prompt-templates/{identifier}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'version' => 1,
'workspace_id' => 123,
'label' => '<string>',
'input_variables' => [
],
'metadata_filters' => [
],
'model' => '<string>',
'model_parameter_overrides' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.promptlayer.com/prompt-templates/{identifier}"
payload := strings.NewReader("{\n \"version\": 1,\n \"workspace_id\": 123,\n \"label\": \"<string>\",\n \"input_variables\": {},\n \"metadata_filters\": {},\n \"model\": \"<string>\",\n \"model_parameter_overrides\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.promptlayer.com/prompt-templates/{identifier}")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"version\": 1,\n \"workspace_id\": 123,\n \"label\": \"<string>\",\n \"input_variables\": {},\n \"metadata_filters\": {},\n \"model\": \"<string>\",\n \"model_parameter_overrides\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.promptlayer.com/prompt-templates/{identifier}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"version\": 1,\n \"workspace_id\": 123,\n \"label\": \"<string>\",\n \"input_variables\": {},\n \"metadata_filters\": {},\n \"model\": \"<string>\",\n \"model_parameter_overrides\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"prompt_name": "<string>",
"prompt_template": {
"content": [
{
"text": "<string>",
"type": "text",
"id": "<string>",
"annotations": [
{
"type": "url_citation",
"title": "<string>",
"url": "<string>",
"start_index": 123,
"end_index": 123,
"cited_text": "<string>",
"encrypted_index": "<string>"
}
],
"thought_signature": "<string>"
}
],
"input_variables": [],
"template_format": "f-string",
"type": "completion"
},
"metadata": {
"model": {
"provider": "<string>",
"name": "<string>",
"model_config_display_name": "<string>",
"base_model": "<string>",
"parameters": {},
"display_params": {},
"api_type": "<string>"
}
},
"commit_message": "<string>",
"llm_kwargs": {},
"version": 123
}{
"success": false,
"message": "<string>",
"error": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Prompt Templates
Get Prompt Template
POST
/
prompt-templates
/
{identifier}
Get Prompt Template by ID
curl --request POST \
--url https://api.promptlayer.com/prompt-templates/{identifier} \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"version": 1,
"workspace_id": 123,
"label": "<string>",
"input_variables": {},
"metadata_filters": {},
"model": "<string>",
"model_parameter_overrides": {}
}
'import requests
url = "https://api.promptlayer.com/prompt-templates/{identifier}"
payload = {
"version": 1,
"workspace_id": 123,
"label": "<string>",
"input_variables": {},
"metadata_filters": {},
"model": "<string>",
"model_parameter_overrides": {}
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
version: 1,
workspace_id: 123,
label: '<string>',
input_variables: {},
metadata_filters: {},
model: '<string>',
model_parameter_overrides: {}
})
};
fetch('https://api.promptlayer.com/prompt-templates/{identifier}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.promptlayer.com/prompt-templates/{identifier}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'version' => 1,
'workspace_id' => 123,
'label' => '<string>',
'input_variables' => [
],
'metadata_filters' => [
],
'model' => '<string>',
'model_parameter_overrides' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.promptlayer.com/prompt-templates/{identifier}"
payload := strings.NewReader("{\n \"version\": 1,\n \"workspace_id\": 123,\n \"label\": \"<string>\",\n \"input_variables\": {},\n \"metadata_filters\": {},\n \"model\": \"<string>\",\n \"model_parameter_overrides\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.promptlayer.com/prompt-templates/{identifier}")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"version\": 1,\n \"workspace_id\": 123,\n \"label\": \"<string>\",\n \"input_variables\": {},\n \"metadata_filters\": {},\n \"model\": \"<string>\",\n \"model_parameter_overrides\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.promptlayer.com/prompt-templates/{identifier}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"version\": 1,\n \"workspace_id\": 123,\n \"label\": \"<string>\",\n \"input_variables\": {},\n \"metadata_filters\": {},\n \"model\": \"<string>\",\n \"model_parameter_overrides\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"prompt_name": "<string>",
"prompt_template": {
"content": [
{
"text": "<string>",
"type": "text",
"id": "<string>",
"annotations": [
{
"type": "url_citation",
"title": "<string>",
"url": "<string>",
"start_index": 123,
"end_index": 123,
"cited_text": "<string>",
"encrypted_index": "<string>"
}
],
"thought_signature": "<string>"
}
],
"input_variables": [],
"template_format": "f-string",
"type": "completion"
},
"metadata": {
"model": {
"provider": "<string>",
"name": "<string>",
"model_config_display_name": "<string>",
"base_model": "<string>",
"parameters": {},
"display_params": {},
"api_type": "<string>"
}
},
"commit_message": "<string>",
"llm_kwargs": {},
"version": 123
}{
"success": false,
"message": "<string>",
"error": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Retrieve a prompt template using either the
prompt_name or prompt_id. Optionally, specify version (version number) or label (release label like “prod”) to retrieve a specific version. If not specified, the latest version is returned.
PromptLayer will try to read the model provider from the parameters you attached to the prompt template. You can optionally pass in a provider to override the one set in the Prompt Registry. This will return LLM-specific arguments that can be passed directly into your LLM client. To format the template with input variables, use input_variables.
Provider-Specific Schema NoticeThe
llm_kwargs object in the response is provider-specific and its structure may change without notice as LLM providers update their APIs (e.g., Provider’s system message format changing from string to an array).For stable, provider-agnostic prompt data, use prompt_template instead of llm_kwargs. Do not hard-code assumptions about llm_kwargs structure in production applications.Path Parameters
Body
application/json
Optional dictionary of model parameter overrides to use with the prompt template. This will override the parameters at runtime for the specified model and will try to make sure the model supports these parameters. For example, if you supply maxOutputTokens for OpenAI, it will be converted to max_completion_tokens.
Response
Successful Response
When you optionally specify provider in the body, llm_kwargs will be returned for that specific provider and you can pass these kwargs to the provider's API directly. Important: This object's structure is provider-specific and may change without notice as LLM providers update their APIs. For stable, provider-agnostic prompt data, use prompt_template instead.
Was this page helpful?

