Embed Minds in your product, configure with the CLI first, then wire the same Builder API into your Node backend with full TypeScript types.
@animocabrands/minds-client-lib is how you wrap and embed Minds in your application or product. Most builders start with the Minds CLI , list Minds, inspect detail, monitor cognition, manage circles, browse the Bazaar, then move here when they are ready to ship. The library exposes the same Builder API with TypeScript types: messaging, waitForReply, SSE events, and the account operations you already ran from the terminal.
Add the package to the server side of your project. Your UI, branding, and user flows stay yours; the client handles typed HTTP and streaming to api.build. Complete Account setup , validate your Mind with the CLI, then wire the examples below, or hand them to a coding agent once configuration is done.
Install
Requires Node 22+.
npm install @animocabrands/minds-client-lib
Authentication
Pass your Builder API key for account and messaging calls. The library sends X-Api-Key only on authenticated requests (≥0.1.2). X-Access-Key is deprecated, do not use it. Env name remains MINDS_BUILDER_API_KEY.
import { BUILDER_API_KEY_ENV, BUILDER_API_KEY_HEADER, createMindsClient,} from "@animocabrands/minds-client-lib";const builderApiKey = process.env[BUILDER_API_KEY_ENV];if (!builderApiKey) throw new Error(`${BUILDER_API_KEY_ENV} is not set`);const client = createMindsClient({ builderApiKey });
createMindsClient({}) is valid for the public Bazaar catalog only (client.bazaar.*). Auth methods throw MindsApiError with code missing_builder_api_key at call time if no key was provided, not at construction.
Create a Mind
Mind names are unique. Call checkMindName first (public, no Builder API key) to see whether a name is already taken, then awakenMind (requires a key).id selects the type of pre-built Mind to create. The package does not export the catalog. Run minds mind awaken --help in the Minds CLI to list each type with a short description. The same list is in the API reference . If the name is taken or id is not valid, awakenMind throws MindsApiError.The example is a sales Mind named J-Belfort. Sell me this pen.
Per-Mind cognition usage and balance mirror the CLI commands. Minds consume cognition when they reason, run tools, and carry out autonomous tasks, not only in conversation. Both take a mindId (UUID) and an optional AbortSignal.Cognition powers a Mind's reasoning, tool use, and autonomous work. Use getCognitionUsage and getCognitionUsageByTool for usage over time and per tool. Use getCognitionBalance for the remaining cognition balance:
The two usage methods accept different interval values: getCognitionUsage accepts 1m, 5m, 15m, 1h, 1d, 1w, 1M; getCognitionUsageByTool accepts hour, day, week, month only. Optional startTime and endTime (ISO date-time) bound the window on both.
A Mind's circle is its set of collaborators - humans and other Minds. getCircle returns a CircleMember[] array directly; addCircleMembers and removeCircleMembers return a CircleMutationResult envelope with per-email outcomes and a best-effort summary:
Human emails can be any address; Mind emails end in @hellominds.ai. listCirclesForAccount() is a convenience that calls listMinds() then getCircle() for each Mind in parallel; use it for account-wide overviews rather than hot paths.
Bazaar catalog
The public Bazaar catalog is available as client.bazaar, no API key required. Use Bazaar for ID discovery (skillId, appId), then equip those IDs with the Mind equip methods below. Route shapes are in the API reference Bazaar and Minds tags; the CLI exposes the same catalog via minds bazaar.List items may include equippedCount, how many Minds have equipped that item platform-wide. That is popularity across the platform. Use listEquippedSkills / listEquippedApps for the per-Mind equipped set.
Apps use appId and appName (not name). collectSearchResults auto-paginates up to scanMax, applies client-side sort/filter, and reports truncated when the scanned set exceeds max. sort: "equipped" orders by equippedCount descending (platform popularity), not per-Mind equip status.
Equip skills and apps
List, equip, or unequip skills and apps on a Mind (requires a Builder API key). Bodies use { ids: string[] }; mutations return { results: [...] } with skillId / appId, isEquipped, and changed (app results may also include appVersionId and version):
Discover IDs via client.bazaar first when you need catalog browse.Equipped skills include source: mind for catalog / Mind-authored skills, system for platform skills (e.g. Skill Architect).
Conversations
Bind a stable alias (e.g. main) to a Mind before messaging:
await client.ensureConversation("main", mindId);
ensureConversation is idempotent, if the alias already exists for that Mind, the existing conversation is returned.Lower-level helpers when you manage aliases yourself:
getHistory returns the full human + Mind transcript, newest-first. Rows use senderType (1 = human, 0 = Mind). The SDK cursor (and deprecated after) is sent as query before - exclusive next older page. The same senderType field appears on SSE events from subscribeEvents / eventsIterator / waitForReply.sendMessage requires alias and messageText. Optional attachments accept outbound objects, prefer a public HTTPS url with fileName and mimeType:
await client.sendMessage({ alias: "main", messageText: "Summarize this PDF in one sentence.", attachments: [ { url: "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf", fileName: "dummy.pdf", mimeType: "application/pdf", extension: "pdf", }, ],});
Image URLs use the same shape (mimeType: "image/png", etc.). Mind replies on getHistory, waitForReply, and SSE events may include inbound artifacts, for example:
// One attachment on a Mind reply (PDF; artifact body truncated){ artifactId: "7388b65d-144a-49ff-a4dc-cb7c23ded982", slug: "whale_watchtower_skill_artifact_1_0_5", logicalType: "document", mimeType: "application/pdf", extension: "pdf", artifact: "JVBERi0xLjQK...",}
Outbound send uses content for inline payloads; inbound replies use artifact for the same role. slug and logicalType are optional strings, treat values as hints, not a fixed enum. See the API reference for field details.getLatestHistoryFingerprint returns the fingerprint of the newest message. Pass it as afterFingerprint to waitForReply so you only accept replies that arrived after you sent. The first getHistory page (no cursor) is already the newest window - do not pass that fingerprint as cursor expecting newer rows.
for await (const event of client.eventsIterator({ alias: "main" })) { console.log(event.fingerprint, event.messageText);}
Pass signal on iterator or subscribe options to cancel when your process shuts down.
Errors
Failed HTTP calls throw MindsApiError with status, code, and message. Calling an auth method without builderApiKey throws missing_builder_api_key at call time. Map 401/403 to a missing or revoked Builder API key; 429 may include retry guidance.