Query your users’ data using natural language
HYPERSPELL_API_KEY
environment variable and omit the api_key
parameter when initializing the client. An app token allows you to insert and query data for any user of your app. Please refer to the Generating Tokens section for more information on how to generate user tokens that are specific to a single user instead.
poems
(if it doesn’t exist, it will be created automatically) — that lets us query for all poems later.
resource_id
returned will be the ID of the memory. You can use this ID to retrieve the original document later. Some types of documents may take several seconds to process, so you may need to wait for the document to be processed before you can query it.
Once you have added a memory, you can query it using the search
method.
search
method takes a query
string, and a sources
parameter that lists the sources you want to query. In this example, we used vault
as a source, which contains all documents added manually with the /memories/add
endpoint.
Each data source comes with different options when querying data. In this example, we used the vault
source, so in the options
field we will find a key with the name of the source (vault
) which contains all the options. In this case, we only have one option, which is the collection
parameter. Note that if we didn’t set this parameter, the entire vault will be searched.
/memories/query
endpoint is designed to always return a result to the best of Hyperspell’s ability, even if some of the data sources might produce errors.
Each response from this endpoint contains an errors
field, which contains a list of errors that occurred while querying the data sources. If no errors occurred, this field will be empty.
errors
field for any errors that occurred — during development, we recommend logging the errors as warnings.
search
will return the most relevant documents (or parts of documents) that match the query. Documents contain both structured data that you can use ie. in your UI to show results, and an LLM-summary that you can use for retrieval-augmented generation.
Of course, you can also use Hyperspell to answer questions about your document directly. To do so, simply include the answer
parameter in your query:
sources
parameter.
slack
and gmail
sources. Both sources are queried at the same time, and the results are merged together. You can use Hyperspell Connect to let your users securely connect their accounts to Hyperspell, and then query their data.
answer_model
parameter to the search
method.
Value | Name | Use Case |
---|---|---|
llama-3.1 | Meta Llama 3.1 8B | General-purpose, fast, high-accuracy model that balances performance and efficiency for most English-language RAG queries. |
gemma2 | Google Gemma 2 | Lightweight, fast model ideal for fast inference without sacrificing too much quality. |
qwen-qwq | Alibaba Qwen QWQ | Multilingual or code-heavy queries where Chinese-language support or reasoning over technical content is important. |
mistral-saba | Mistral Saba | Small, open-weight model with strong performance in structured reasoning or concise summarization tasks. |
llama-4-scout | Meta Llama 4 Scout | State-of-the-art reasoning and nuanced understanding for complex or ambiguous queries. |
deepseek-r1 | DeepSeek R1 | Use this when your query involves math, code, or scientific reasoning. |
max_results
parameter to query options:
true
.
weight
parameter to query option for each data source :
gmail
source will be weighted three times more than the slack
source. The weights will be used internally by the re-ranker to influence which documents are returned and used for answering the query.