JavaScript Guide
Use the first-party JavaScript helper client in this repo to call store, ingest, batch ingest, and the source-specific wrapper routes with one class.
Base URL
https://api.neuralbase.cloudSetup
Install the package from npm, import the client once, and reuse it across your app.
javascript
npm install @neuralbase-org/js
import { NeuralBaseClient } from "@neuralbase-org/js";
const nb = new NeuralBaseClient({
apiKey: "nb_live_...",
baseUrl: "https://api.neuralbase.cloud",
});POST
/v1/ingest/chat— Ingest a conversationUse the wrapper method when you already have messages and want Neuralbase to normalize them for memory search.
javascript
const queued = await nb.ingestConversation(
{
userId: "user_123",
source: "intercom",
externalId: "conv_987",
data: {
title: "Refund request",
messages: [
{ role: "user", content: "I need help with a refund." },
{ role: "assistant", content: "Refund review started." },
],
},
},
{ idempotencyKey: "conv_987-v1" },
);
console.log(queued.memoryId);POST
/v1/ingest/batch— Batch ingestYou can send mixed connector types in one call and attach one idempotency key to the whole batch.
javascript
const batch = await nb.ingestBatch(
[
{
type: "event",
userId: "user_123",
data: {
name: "checkout_completed",
description: "User upgraded to pro",
},
},
{
type: "profile",
userId: "user_123",
data: {
summary: "Enterprise buyer",
attributes: { plan: "enterprise" },
},
},
],
{ idempotencyKey: "batch-user-123-1" },
);
console.log(batch.accepted, batch.failedCount);GET
/v1/memories/:id/status— Poll memory statusAll ingest helpers return a queued memory id immediately. Poll the status endpoint until the memory completes.
javascript
const status = await nb.getMemoryStatus("mem_abc123");
if (status.status === 'complete') {
console.log('ready');
}