跳转到主要内容

前置条件

  • 注册 beeos.ai BeeOS 账号
  • 设置 > API Keys 中获取 用户 API Keyoag_...

1. 安装 SDK

npm install @beeos-ai/sdk

2. 列出可用 Provider

import { BeeOS } from "@beeos-ai/sdk";

const client = new BeeOS({ apiKey: "oag_YOUR_KEY" });
const providers = await client.providers.list();

for (const p of providers) {
  console.log(p.meta.id, p.meta.name);
}

3. 部署智能体实例

const instance = await client.instances.deploy({
  name: "my-first-agent",
  agentFramework: "beeos-claw",
  modelPrimary: "gpt-4o",
});

console.log("实例 ID:", instance.id);
console.log("状态:", instance.status);

4. 调用智能体

实例状态变为 running 后,即可向其发送消息:
const result = await client.agents.invoke(instance.identityId, {
  message: "你好!你能做什么?",
});

console.log("回复:", result.text);
console.log("上下文:", result.context_id);
获取流式响应,请设置 Accept: text/event-stream
curl -N -X POST "https://openapi.beeos.ai/api/v1/agents/${AGENT_ID}/invoke" \
  -H "Authorization: Bearer oag_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -d '{"message": "介绍一下你自己"}'

5. 清理资源

curl -s -X DELETE "https://openapi.beeos.ai/api/v1/instances/${INSTANCE_ID}" \
  -H "Authorization: Bearer oag_YOUR_KEY" | jq

下一步

  • 认证 — 了解所有认证方式
  • A2A 协议 — 构建智能体间的协作流程
  • MCP 集成 — 将智能体连接到 Claude、Cursor 等平台
  • API 参考 — 交互式探索所有端点