Quick Start
The fastest way to try the public demo is the hosted JavaScript SDK:
import { createMRHIDemoClient } from "https://mrhisearch.com/api/demo/sdk.js";The public demo API base URL is https://mrhisearch.com/api/demo.
1. Create a client
Section titled “1. Create a client”Pick your dimensions up front if you already know them:
const client = createMRHIDemoClient({ baseUrl: "https://mrhisearch.com/api/demo", dimensions: 3,});You can also pass a previously saved token:
const client = createMRHIDemoClient({ baseUrl: "https://mrhisearch.com/api/demo", dimensions: 3, token: "mrhi_demo__saved_token",});2. Get and save a token
Section titled “2. Get and save a token”Every session uses an anonymous token:
const token = await client.getToken();console.log("Save this token:", token);Save that token somewhere appropriate for your app. Reusing the same token reuses the same temporary index until the session expires.
3. Add vectors
Section titled “3. Add vectors”The first successful add initializes the session’s dimensions and metric.
await client.addMany([ { id: "doc-1", vector: [1, 0, 0], metadata: { category: "news" } }, { id: "doc-2", vector: [0.9, 0.1, 0], metadata: { category: "news" } }, { id: "doc-3", vector: [0, 1, 0], metadata: { category: "sports" } },]);If you want to choose the metric explicitly:
await client.addMany(vectors, { metric: "cosine",});4. Search
Section titled “4. Search”const search = await client.search([1, 0, 0], { topK: 3, includeMetadata: true, filter: { category: "news" },});You will get:
results: vector matchessession: current session statestats: MRHI index statsmetrics: timing information such assearchMs,dbOpenMs, andrequestLatencyMs
5. Reuse the token later
Section titled “5. Reuse the token later”Create a new client with a saved token:
const client = createMRHIDemoClient({ baseUrl: "https://mrhisearch.com/api/demo", token: "mrhi_demo__saved_token",});Or load it into an existing client:
client.useToken("mrhi_demo__saved_token");6. Change dimensions later
Section titled “6. Change dimensions later”If you want to keep the token but switch to a different dimension, fully reset the index first:
await client.resetIndex();client.setDimensions(5);After that, the next add() or addMany() call can use a new dimension.
Full quick start example
Section titled “Full quick start example”import { createMRHIDemoClient } from "https://mrhisearch.com/api/demo/sdk.js";
const client = createMRHIDemoClient({ baseUrl: "https://mrhisearch.com/api/demo", dimensions: 3,});
const token = await client.getToken();console.log("Save this token:", token);
await client.addMany([ { id: "doc-1", vector: [1, 0, 0], metadata: { category: "news" } }, { id: "doc-2", vector: [0.9, 0.1, 0], metadata: { category: "news" } }, { id: "doc-3", vector: [0, 1, 0], metadata: { category: "sports" } },]);
const search = await client.search([1, 0, 0], { topK: 3, includeMetadata: true, filter: { category: "news" },});
console.log(search.results);console.log(search.metrics);If your code is running anywhere other than mrhisearch.com, keep baseUrl explicit like the examples above so the client does not fall back to your page’s own origin.
If you want to work directly over HTTP instead, use REST API.
Continue with JavaScript SDK or REST API.