Skip to main content
Save a preference for user_123, search it, and use it in a model prompt. You will create a database (a separate workspace for your data) and write to a collection (a named group inside it) for this user.

Install and initialize

Get an API key from app.hydradb.com, then set it in the terminal where you run the examples:
Choose Python, TypeScript, or cURL and keep using that tab below. For TypeScript, use a Node.js project that supports top-level await. The cURL examples also require jq to read JSON responses. Install the SDK with the command shown in its tab; keep the initialized client for the next step.

Save and retrieve a memory

Use an unused database name, or skip the create call if you already have a database. Writing the memory creates user_123 automatically. Checking indexing means waiting until HydraDB has processed the memory and made it searchable.

Check the result

The query returns passages from your saved memory, not a generated answer. The SDK examples print formatted context; cURL prints the passage text. Both should include the preference you stored:
The same collection on ingest, status, and query keeps the steps pointed at user_123. Your backend must select the collection for the authenticated user; the name itself does not authenticate them.

Use the memory in a model prompt

Continue from the results above. The SDK helper formats the returned passages and any relationships into a string, which you can add to the messages you send to your model:
Send messages to the chat model your application uses. It now has the user’s preferences available when answering the editor question. For raw HTTP response formatting and complete model-call examples, see How to Use API Results. Database creation and indexing run in the background, which is why the example waits for both. When adding more data, reuse the database and save each user’s memories in their own collection.

Where to go next

Stuck? Reach out at founders@hydradb.com.