adding a tool to an assistant via api
# support
r
how can i add a tool i have created to an existing assistant using the vapi sdk or the api
a
HeyRaju Thank you for creating the ticket! A member of our team will reach out to you shortly.
v
message has been deleted
@Raju To add a tool you've created to an existing assistant using the VAPI SDK or the API, you'll need to follow the specific instructions provided in the VAPI documentation. Generally, this process involves updating the assistant's configuration to include your new tool. If you're using the VAPI SDK, you would typically update the assistant's configuration in your codebase and then deploy the changes. Here's a high-level overview of the steps you might take: 1. Update the assistant's configuration file or code to include the new tool. 2. Test the integration of the new tool in a development or staging environment to ensure it works as expected. 3. Deploy the updated assistant to your production environment. If you're using the API directly, you would send an HTTP request to the appropriate endpoint to update the assistant's configuration. The request would include the details of the new tool you want to add. Here's a general example of how you might send a POST request to update the assistant's configuration:
Copy code
http
POST /api/assistant/{assistant_id}/tools
Authorization: Bearer your-api-token
Content-Type: application/json

{
  "tool_name": "your_new_tool",
  "tool_config": {
    // ... configuration details for your tool ...
  }
}
Replace
{assistant_id}
with the ID of your assistant,
your-api-token
with your actual API token, and the JSON payload with the appropriate configuration for your tool. Please note that the actual endpoint, HTTP method, and request payload can vary based on the VAPI's API design. You should consult the VAPI documentation for the exact details on how to add a tool to an assistant. If you need further assistance or specific instructions, please let me know, and I can provide more detailed guidance.
You can continue this conversation by mentioning me in the message.
s
@Raju You need to make an UPDATE /assistant/:id request to update your assistant config to attach the required tool ids. Ref: https://docs.vapi.ai/api-reference/assistants/update?playground=%2Fapi-reference%2Fassistants%2Fupdate Make sure to provide all used properties again inside the model property such as system prompt.
example
Copy code
curl -X PATCH https://api.vapi.ai/assistant/id \
     -H "Authorization: Bearer 00a037c8-3c5e-4228-ac46-c855d9b3e201" \
     -H "Content-Type: application/json" \
     -d '{
  "model": {
    "provider": "openai",
    "model": "gpt-4o",
    "toolIds": [
      "inert-tool-id-here"
    ]
  }
}'
19 Views