Tool issue using the API
# support
u
Hello, I played a bit with VAPI recently as a POC. Using the UI i created an assistant that works ok and I created 2 custom tools (homemade API) that works fine with it. Now i need to switch to API mode to create that assistant for clients with some various options. I pretty much sorted out everything, but I cannot find how to bind tools to an assistant when I create one using POST assistant. I used GET assistant/{id} to fetch the json representation of the assistant I created using the UI. He is binded to some tools in the UI, but when I check the json payload there is nothing about it. Can you just tell me how to tell Vapi API : This assistant has access to that / those tools ?
v
@[GFA]fifoooo Hello! I'm glad to hear you've been exploring VAPI and have successfully created an assistant and custom tools. To bind tools to an assistant via the API, you typically need to include the tool references within the payload of your POST request when creating or updating an assistant. The exact structure of the payload can vary depending on the API's design, but generally, you would include an array or list of tool identifiers within the assistant's configuration. This might look something like a
tools
field where you specify the IDs or names of the tools you want to associate with the assistant. Since you've mentioned that the JSON representation of the assistant you fetched does not include information about the bound tools, it's possible that the association between assistants and tools is managed through a different endpoint or parameter. If the documentation does not provide clear guidance on how to bind tools to an assistant via the API, I would recommend reaching out to the VAPI support team for more detailed instructions. They should be able to provide you with the exact steps or the correct payload structure to achieve this. If you have any other questions or need further assistance, please let me know!
You can continue this conversation by mentioning me in the message.
u
@Vapi sorry but that answer is bad.
v
@[GFA]fifoooo I apologize if my previous response wasn't helpful. To bind tools to an assistant via the VAPI, you would typically need to specify the tools within the assistant's configuration when making the POST request to create or update the assistant. If the JSON payload you retrieved from the
GET assistant/{id}
endpoint does not show the tool bindings, it's possible that the tool association is handled in a separate part of the assistant configuration that isn't included in the standard retrieval endpoint. To bind tools to an assistant, you should look for a section in the API documentation that covers tool associations. This might be a specific field in the JSON payload when you make a POST or PUT request to the
assistant
endpoint, or it could be a separate endpoint altogether for managing tool bindings. If the documentation does not provide the necessary details, or if you're unable to find the relevant section, please reach out to VAPI support for more specific guidance on how to include tool references in your assistant configuration via the API. Again, I'm here to help, so if you have any further questions or need additional assistance, feel free to ask.
u
This section does not exists. The word tool is not mentionned in the create assistant endpoint documentation
s
@[GFA]fifoooo to assign tools with the assistant either you can associate the tool json schema or tool ids with the assistant. In the below CURL request both properties are mentioned on how to assoicate tools with the assistant.
Copy code
json
curl -X POST https://api.vapi.ai/assistant \
     -H "Authorization: Bearer " \
     -H "Content-Type: application/json" \
     -d '{
  "model": {
    "provider": "openai",
    "tools": [
      {
        "type": "function",
        "async": false,
        "messages": [],
        "function": {
          "name": "function-name-here",
          "description": "",
          "parameters": {
            "type": "object",
            "properties": {}
          }
        },
        "server": {
          "url": ""
        }
      }
    ],
    "toolIds": [
      "tool-id-here",
      "tool-id-here"
    ]
  }
}'
You can learn more about it from here https://docs.vapi.ai/api-reference/calls/create?playground=%2Fapi-reference%2Fassistants%2Fcreate
2 Views