mboaai-sdk
v1.0.18
Published
Lightweight JavaScript SDK for calling MboaAI agents
Readme
MboaAI JavaScript SDK
Tiny, framework-agnostic helper to talk to MboaAI agents from Node, React, Vue, Angular, Svelte or plain-browser JS.
- ✅ One-line
init({ apiKey }) - ✅
await T.translate(text, targetLang, type?) - ✅ Graceful fallback → returns original text when the agent fails
- ✅ UMD and ESM builds (works with
importorrequire) - ✅ TypeScript types included
🛠 Installation
npm i mboaai-sdk # or yarn add mboaai-sdk / pnpm add …🚀 Quick start
import { T } from "mboaai-sdk";
await T.init({
apiKey: "yourKey", // ← required
defaultType: "website", // optional: default pipeline
});
const de = await T.translate("Bonjour tout le monde", "DE"); // uses defaultType
console.log(de); // → „Hallo zusammen“
const it = await T.translate("Hello!", "IT", "standard"); // override pipeline
console.log(it); // → „Ciao!“Node (CommonJS)
const { T } = require("mboaai-sdk");
(async () => {
await T.init({ apiKey: process.env.MBOAAI_KEY });
console.log(await T.translate("Salut", "EN"));
})();Plain browser (UMD script tag)
<script src="https://cdn.jsdelivr.net/npm/mboaai-sdk"></script>
<script>
(async () => {
await MboaAI.T.init({ apiKey: "yourKey" });
const es = await MboaAI.T.translate("Wie geht's?", "ES");
console.log(es);
})();
</script>📚 API
| Method | Description |
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| await T.init(opts) | Establishes SSE connection and stores your API key. Call once. |
| await T.translate(text, lang, type?) | Returns translated string, or original text on error. type defaults to the value given in init() (else "standard"). |
TranslateType
"standard"|"website"| any string Future pipelines (e.g."legal","marketing") are accepted automatically.
📝 Example – Straight-up translation
import { T } from "mboaai-sdk";
(async () => {
/* 1) Initialise once */
await T.init({
apiKey : "yourKey", // your secret key
defaultType : "website", // optional
});
/* 2) Translate a French marketing line into English (defaultType = "website") */
const fr = "Découvrez nos nouvelles chaussures de sport éco-responsables !";
const en = await T.translate(fr, "EN"); // → uses “website” pipeline
console.log("English:", en);
/* 3) Translate the same line into Italian using the “standard” pipeline */
const it = await T.translate(fr, "IT", "standard");
console.log("Italian:", it);
})();
⚠️ Error handling
- If the agent returns malformed JSON or network fails, the SDK logs
a warning and returns the original
textunchanged so your UI never breaks.
📦 Bundle details
| File | Format | Usage |
| ------------------------ | ------ | ------------------------------------ |
| dist/mboaai-sdk.esm.js | ESM | modern bundlers, Node ≥16 import |
| dist/mboaai-sdk.umd.js | UMD | <script> tag, CommonJS require() |
The build is minified with Terser and ships its TypeScript typings
(index.d.ts).
🛡 License
MIT © 2025 MboaAI.
