Cannot import Trieve KB
# support
m
Hello, there I’ve created a Trieve KB and I’m trying to import it in VAPI through; re = requests.post(url="https://api.vapi.ai/knowledge-base", headers={"Authorization": "Bearer <>"}, data={"name": "criteria-dataset", "provider": "trieve", "searchPlan": { "scoreThreshold": 0.2, "searchType": "semantic" }, "createPlan": { "type": "import", "providerId": "8565779d-7729-4123-b895-f993a5a518a7" }}) And I’m getting; {'message': ['searchPlan.nested property searchPlan must be either object or array', 'searchPlan.nested property searchPlan must be either object or array', 'createPlan must be an object', 'createPlan must be one of these objects: TrieveKnowledgeBaseCreate, TrieveKnowledgeBaseImport'], 'error': 'Bad Request', 'statusCode': 400} Any thoughts?
v
It looks like you're encountering a formatting issue with your JSON payload when trying to import your Trieve KB into VAPI. The error messages indicate that the
searchPlan
and
createPlan
properties are not structured correctly. Here's how you can adjust your code: 1. **Use
json
instead of `data`**: When sending JSON data in a POST request, you should use the
json
parameter instead of
data
. This ensures that the payload is correctly formatted as JSON. 2. **Ensure the structure is correct**: The
searchPlan
and
createPlan
should be properly formatted as objects. Here’s a revised version of your code:
Copy code
python
import requests

re = requests.post(
    url="https://api.vapi.ai/knowledge-base",
    headers={"Authorization": "Bearer <your_token_here>"},
    json={
        "name": "criteria-dataset",
        "provider": "trieve",
        "searchPlan": {
            "scoreThreshold": 0.2,
            "searchType": "semantic"
        },
        "createPlan": {
            "type": "import",
            "providerId": "8565779d-7729-4123-b895-f993a5a518a7"
        }
    }
)
Make sure to replace
<your_token_here>
with your actual authorization token. If you still encounter issues, double-check that the
providerId
is valid and that your Trieve dataset is correctly set up. Let me know if you need further assistance! 😊 Sources: - [Importing Trieve KB into VAPI](https://docs.vapi.ai/knowledge-base/integrating-with-trieve) - [Troubleshooting 'Bad Request' Error in VAPI API](https://discord.com/channels/1211482211119796234/1211483291191083018/1343853917322350703)
m
If I convert it to json, I get that the providerId is not found…but it exists
any thoughts @Nick K - CEO @ Trieve ? Thanks
n
Have you added your Trieve API key to the provider keys in Vapi?
m
yes - just refreshed it now and getting the same
n
Hmmm
Not sure, can debug on a call if you would like - https://cal.com/nick.k
m
thanks a lot. I’ve sent an invite. if anyone else has an idea where to look at please 🙂
I resolved it. I was copying the wrong api key from Trieve - mixing the Id with the api key
k
Marking this ticket as Solved ✅