bma-sdk
GitHub ↗สำหรับ: แอปที่เรียก API ของแพลตฟอร์ม
- เอเจนต์ เซสชัน สตรีมเหตุการณ์ SSE
- ไฟล์ อาร์ติแฟกต์ คอมพิวเตอร์ เดสก์ท็อป เทอร์มินัล
- SSE ต่อเนื่องได้ · idempotency key · ข้อผิดพลาดแบบมีชนิด
$
npm install @beeos-ai/bma-sdkimport { BmaClient } from "@beeos-ai/bma-sdk";
const client = new BmaClient({ apiKey: process.env.BMA_API_KEY!, baseURL: process.env.BMA_BASE_URL! });
const session = await client.beta.sessions.create({ agent: agentId, environment_id: environmentId });
// Open the stream first, then send: an interrupted stream resumes with Last-Event-ID.
const stream = await client.beta.sessions.events.stream(session.id);
await client.beta.sessions.events.send(session.id, {
events: [{ type: "user.message", content: [{ type: "text", text: "Plan my week." }] }],
});
for await (const ev of stream) {
if (ev.type === "agent.message") console.log(ev.content);
if (ev.type === "session.status_idle") break;
}