@ai-matrx/api

中文文档
0.1.105发布于 2026/10/30MITTypeScriptESM + CJS近 30 天下载 4.9万

The one way every app talks to every AI Matrx server: generated from the server contract, split by domain so an app loads only the requests it calls. Transport, five credential kinds, organization binding, streams, job follow. No screens, app state or dat

原始使用文档

@ai-matrx/api

The one way every app talks to every AI Matrx server. Generated from the server contract and split by area, so an app only loads the requests it calls. It never holds screens, app state or database code.

import { createApi } from "@ai-matrx/api";
import { listAssets } from "@ai-matrx/api/files";

const api = createApi({ credentials: { kind: "api_key", apiKey: process.env.MATRX_API_KEY! }, organizationId });
const page = await listAssets(api, { query: { limit: 50 } });
  • Credentials — one setting: a credential, a getter, or a CredentialsPort (user, guest, api_key, service, scoped).
  • Organization — bound once; sent per each operation's contract rule (required / optional / exempt).
  • Routing — each operation knows which deployment answers; override with baseUrls or resolveBaseUrl.
  • Streams — NDJSON/SSE operations return an async iterable; *_or_json operations return { kind: "json" } | { kind: "stream" }.
  • Sections — @ai-matrx/api/<domain> per domain, /schemas, /types (type-only components/paths view), /stream, /net, /credentials. Importing one domain loads no other domain's code.

Regenerate after a server contract change: node scripts/generate.mjs (input: aidream api-contract/). --check fails on drift.

Gates

pnpm check:package runs the generator --check, the build, exports agreement, publint and the section probe (scripts/section-probe.mjs: no domain section loads another domain's code; one imported operation bundles exactly one operation descriptor).

版本与发布记录

@ai-matrx/api 共发布 107 个版本,首次发布于 2026/10/09;过去 12 个月发布了 107 个版本。

版本发布日期距今
0.1.105latest2026/10/306 天前
0.1.1042026/10/297 天前
0.1.1032026/10/298 天前
0.1.1022026/10/288 天前
0.1.1012026/10/289 天前
0.1.1002026/10/289 天前

关于 @ai-matrx/api 的常见问题

@ai-matrx/api 是什么?

The one way every app talks to every AI Matrx server: generated from the server contract, split by domain so an app loads only the requests it calls. Transport, five credential kinds, organization binding, streams, job follow. No screens, app state or dat

如何安装 @ai-matrx/api?

在项目目录运行 npm install @ai-matrx/api,或使用 pnpm add / yarn add / bun add。

@ai-matrx/api 支持 TypeScript 吗?

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

@ai-matrx/api 支持 ESM 还是 CommonJS?

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

@ai-matrx/api 需要什么版本的 Node.js?

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

@ai-matrx/api 可以商用吗?

@ai-matrx/api 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ai-matrx/api 的下载量有多少?

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

@ai-matrx/api 还在维护吗?

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