Skip to content

App 开发者概览

Nimi 为 App 开发者提供了统一的 runtime 和单一的 SDK(@nimiplatform/sdk),同时支持本地和云端 AI 模型。只需编写一次集成代码,即可在设备端推理和远程 Provider 之间自由切换,无需修改应用代码。

前置条件

  • Nimi 已安装并运行 -- 使用 nimi start 启动 runtime。
  • Node.js(v18+),SDK 运行所需。

快速上手

1. 安装 SDK

bash
npm install @nimiplatform/sdk

2. 创建 platform client

ts
import { createPlatformClient } from '@nimiplatform/sdk';

const { runtime } = await createPlatformClient({
  appId: 'docs.app-dev.quickstart',
});

3. 生成文本

ts
const result = await runtime.generate({ prompt: 'What is Nimi?' });
console.log(result.text);

最小可运行示例

ts
import { createPlatformClient } from '@nimiplatform/sdk';

const { runtime } = await createPlatformClient({
  appId: 'docs.app-dev.minimal',
});
const result = await runtime.generate({ prompt: 'What is Nimi?' });
console.log(result.text);

后续步骤

Released under Apache-2.0 (runtime, sdk, proto) / MIT (desktop, nimi-mods, web) / CC-BY-4.0 (docs)