Retrieval Calls
Learn how to make retrieval calls to your vaults using the laive API.
Making a Retrieval Call
Section titled “Making a Retrieval Call”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 })});Request Parameters
Section titled “Request Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| vault_id | string | Yes | The unique identifier of the vault to search in |
| query | string | Yes | The search query to find relevant information |
| top_k | integer | No | Maximum number of results to return (default: 4) |
Response Format
Section titled “Response Format”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 ]}