Skip to main content
POST
/
api
/
public
/
v2
/
tool-registry
Create Tool Registry
curl --request POST \
  --url https://api.promptlayer.com/api/public/v2/tool-registry \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: <api-key>' \
  --data '
{
  "name": "<string>",
  "tool_definition": {},
  "description": "<string>",
  "folder_id": 123,
  "commit_message": "<string>",
  "external_ids": [
    {
      "source": "<string>",
      "external_id": "<string>"
    }
  ],
  "execution": {
    "type": "code",
    "code": "<string>"
  }
}
'
import requests

url = "https://api.promptlayer.com/api/public/v2/tool-registry"

payload = {
"name": "<string>",
"tool_definition": {},
"description": "<string>",
"folder_id": 123,
"commit_message": "<string>",
"external_ids": [
{
"source": "<string>",
"external_id": "<string>"
}
],
"execution": {
"type": "code",
"code": "<string>"
}
}
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({
name: '<string>',
tool_definition: {},
description: '<string>',
folder_id: 123,
commit_message: '<string>',
external_ids: [{source: '<string>', external_id: '<string>'}],
execution: {type: 'code', code: '<string>'}
})
};

fetch('https://api.promptlayer.com/api/public/v2/tool-registry', 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/api/public/v2/tool-registry",
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([
'name' => '<string>',
'tool_definition' => [

],
'description' => '<string>',
'folder_id' => 123,
'commit_message' => '<string>',
'external_ids' => [
[
'source' => '<string>',
'external_id' => '<string>'
]
],
'execution' => [
'type' => 'code',
'code' => '<string>'
]
]),
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/api/public/v2/tool-registry"

payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"tool_definition\": {},\n \"description\": \"<string>\",\n \"folder_id\": 123,\n \"commit_message\": \"<string>\",\n \"external_ids\": [\n {\n \"source\": \"<string>\",\n \"external_id\": \"<string>\"\n }\n ],\n \"execution\": {\n \"type\": \"code\",\n \"code\": \"<string>\"\n }\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/api/public/v2/tool-registry")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"tool_definition\": {},\n \"description\": \"<string>\",\n \"folder_id\": 123,\n \"commit_message\": \"<string>\",\n \"external_ids\": [\n {\n \"source\": \"<string>\",\n \"external_id\": \"<string>\"\n }\n ],\n \"execution\": {\n \"type\": \"code\",\n \"code\": \"<string>\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.promptlayer.com/api/public/v2/tool-registry")

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 \"name\": \"<string>\",\n \"tool_definition\": {},\n \"description\": \"<string>\",\n \"folder_id\": 123,\n \"commit_message\": \"<string>\",\n \"external_ids\": [\n {\n \"source\": \"<string>\",\n \"external_id\": \"<string>\"\n }\n ],\n \"execution\": {\n \"type\": \"code\",\n \"code\": \"<string>\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "external_ids": [
    {
      "source": "<string>",
      "external_id": "<string>"
    }
  ],
  "success": true,
  "tool_registry": {},
  "version": {}
}
{
"success": false,
"message": "<string>",
"error": "<string>"
}
{
"message": "<string>",
"success": false
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}
Create a new tool in the Tool Registry with an initial version. The tool definition should be in OpenAI function-calling format. Tool names must be unique within a workspace. The initial version is created with version number 1. Pass an optional execution payload to attach a sandbox-executable body. PromptLayer will run it between LLM turns whenever a prompt references the tool. See Auto Tool Execution for the body model and conventions.

Authorizations

X-API-KEY
string
header
required

Body

application/json
name
string
required

Tool name (unique per workspace)

tool_definition
object
required

Tool definition in OpenAI function-calling format

description
string | null

Optional human-readable description of the tool

folder_id
integer | null

Folder ID to place tool in

commit_message
string | null

Commit message for the initial version

external_ids
ExternalId · object[]

Identifiers from other systems.

execution
object | null

Optional sandbox-executable body for the tool. When set, PromptLayer auto-runs the body between LLM turns. See the Auto Tool Execution feature page.

Response

Tool created

external_ids
ExternalId · object[]
required

External ID mappings for the tool.

success
boolean
tool_registry
object
version
object