v1
latestOpenAPI 3.0.02026-07-268285163.6 KBAssistant Tools
Create a new assistant tool
Create a new custom assistant tool
post/assistantTool
Request body
Example request
{
"name": "Weather Lookup",
"definition": "{\n \"name\": \"get_weather_forecast\",\n \"description\": \"Retrieves the weather forecast for a specific location.\",\n \"strict\": true,\n \"parameters\": {\n \"type\": \"object\",\n \"required\": [\"location\"],\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city or location for which to fetch the weather forecast.\"\n }\n },\n \"additionalProperties\": false\n }\n}",
"function": "let location = {{location}};\nlet response = '';\nif(location) {\n response = `Weather for ${location}: Sunny, 22°C`;\n} else {\n response = 'Location is required';\n}\noutput.answer = response;\ncallback(output);",
"icon_url": "assets/img/integrations/custom-tool.png"
}Response
Tool created successfully
Example response
{
"tool": {
"_id": "60a1b2c3d4e5f6g7h8i9j0k1",
"name": "Weather Lookup",
"icon_url": "assets/img/integrations/custom-tool.png",
"definition": "{\n \"name\": \"get_weather_forecast\",\n \"description\": \"Retrieves the weather forecast for a specific location.\",\n \"strict\": true,\n \"parameters\": {\n \"type\": \"object\",\n \"required\": [\n \"location\"\n ],\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city or location for which to fetch the weather forecast.\"\n },\n \"days\": {\n \"type\": \"integer\",\n \"description\": \"Number of days for the forecast (1-7).\",\n \"minimum\": 1,\n \"maximum\": 7\n }\n },\n \"additionalProperties\": false\n }\n}",
"function": "// Available nodejs environment with pre-installed libraries\n// https://docs.example.com/custom-code\nlet location = {{location}};\nlet days = {{days}} || 3;\nlet response = '';\n\nif(location) {\n response = `Weather forecast for ${location} for ${days} days: Sunny with temperatures between 20-25°C`;\n} else {\n response = 'Location parameter is required';\n}\n\noutput.answer = response;\ncallback(output);",
"user_id": "5a1b2c3d4e5f6g7h8i9j0k11",
"type": "custom",
"createdAt": "2024-03-15T10:30:00.000Z",
"updatedAt": "2024-03-15T10:30:00.000Z"
}
}