@getmetal/metal-sdk

中文文档
7.7.1发布于 2023/11/10Apache 2.0TypeScriptESM + CJS近 30 天下载 2.9万

Metal SDK

原始使用文档
文档目录9 节
  1. Install
  2. Retrieval Usage
  3. Setup
  4. Indexing
  5. Searching
  6. Memory Usage
  7. Setup
  8. Add Memory
  9. Get Memory

🤘 Metal Node SDK

Developer Documentation

Install

  npm install @getmetal/metal-sdk
  # or
  yarn add @getmetal/metal-sdk

Retrieval Usage

Setup

import { Metal } from '@getmetal/metal-sdk'
const metal = new Metal('pk_123', 'ci_123', 'idx_123')

Indexing

import { Metal } from '@getmetal/metal-sdk'

const metal = new Metal('api-key', 'client-id', 'index-id')

// Index Text
await metal.index({
  id: '666', // Id is optional <> if not provided, Metal will generate one
  text: 'Ozzy Osbourne',
  metadata: { band: 'Black Sabbath' },
})

// Index Image from URL
await metal.index({ imageUrl: 'https://image.png' })
// Index Image from Base64
await metal.index({ imageBase64: '<base-64-str>' })

Searching

import { Metal } from '@getmetal/metal-sdk'

const metal = new Metal('api-key', 'client-id', 'index-id')

// Search Text
await metal.search({
  text: 'Who is the lead singer of Black Sabbath?',
  limit: 1,
})

await metal.search({ imageUrl: 'search-by-image.png' })

// Filtered Search
await metal.search({
  text: 'Heavy Metal',
  filters: [{ field: 'band', value: 'Black Sabbath' }],
})

Memory Usage

Setup

import { Motorhead } from '@getmetal/metal-sdk'
const motor = new Motorhead({ apiKey: 'pk_123', clientId: 'ci_123' })

Add Memory

const memoryPayload = {
  messages: [
    { role: 'Human', content: 'Who is the best vocalist of all time?' },
    { role: 'AI', content: 'Ozzy!' },
  ],
  context: 'User ask what can he eat in Colombia. The AI responds arepas are really nice',
}

await motorhead.addMemory('session-id', memoryPayload)

Get Memory

await motorhead.getMemory('session-id')

View the full documentation on https://docs.getmetal.io/sdks/node

版本与发布记录

@getmetal/metal-sdk 共发布 45 个版本,首次发布于 2023/02/06;过去 12 个月发布了 0 个版本。

版本发布日期距今
7.7.1latest2023/11/103 年前
7.7.02023/11/013 年前
7.6.02023/10/233 年前
7.4.12023/10/103 年前
7.3.12023/10/103 年前
7.3.02023/09/273 年前

关于 @getmetal/metal-sdk 的常见问题

@getmetal/metal-sdk 是什么?

Metal SDK

如何安装 @getmetal/metal-sdk?

在项目目录运行 npm install @getmetal/metal-sdk,或使用 pnpm add / yarn add / bun add。

@getmetal/metal-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@getmetal/metal-sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@getmetal/metal-sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@getmetal/metal-sdk 可以商用吗?

@getmetal/metal-sdk 使用 Apache 2.0 许可。声明的许可为 Apache 2.0,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@getmetal/metal-sdk 的下载量有多少?

根据 npm 官方下载统计,@getmetal/metal-sdk 在 2026/10/17 – 2026/11/15 这 30 天内被下载 29,024 次,日均约 967 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@getmetal/metal-sdk 还在维护吗?

最新版本 7.7.1 发布于 2023/11/10(3 年前);至今共发布 45 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/02/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。