Skip to content

Retrieval Calls

Learn how to make retrieval calls to your vaults using the laive API.

To retrieve information from a vault, you’ll need to make a POST request to the retrieval endpoint with your API key and the necessary parameters. Here’s an example of how to do this using JavaScript’s Fetch API:

const response = await fetch('https://api.laive.ai/api/v1/retriever/query', {
method: 'POST',
headers: {
'X-API-KEY': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
vault_id: 'your-vault-id',
query: 'your-search-query',
top_k: 5
})
});
ParameterTypeRequiredDescription
vault_idstringYesThe unique identifier of the vault to search in
querystringYesThe search query to find relevant information
top_kintegerNoMaximum number of results to return (default: 4)

The API will return a JSON response containing the retrieved information:

{
"sources": [
{
"page_content": "Example content from document",
"metadata": {
"page": 1,
"total_pages": 10,
"source_url": "url-to-source-if-loaded-from-connector",
"source_name": "name-of-source",
"source_type": "type-of-source",
"vault_id": 1,
"type": "type-of-source",
"file_id": 123,
},
"score": 0.95,
},
// ... more results
]
}