Skip to content

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.

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",
});

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.

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",
});
const search = await client.search([1, 0, 0], {
topK: 3,
includeMetadata: true,
filter: { category: "news" },
});

You will get:

  • results: vector matches
  • session: current session state
  • stats: MRHI index stats
  • metrics: timing information such as searchMs, dbOpenMs, and requestLatencyMs

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");

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.

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.