@2kw/ai

中文文档
8.2.1发布于 2026/11/10SEE LICENSE IN LICENSETypeScriptES Module近 30 天下载 1.1万

CLI for 2kw.ai — schema-driven document extraction, an OpenAI-compatible EU LLM gateway, transcription, prompts, datasets, and experiments from your terminal or agentic workflows. Ships as 2kw, backbone, and bb.

原始使用文档
文档目录9 节
  1. Installation
  2. Quick Start
  3. Authentication
  4. Contexts
  5. Commands
  6. Global Options
  7. Why 2kw.ai
  8. Related
  9. License

2kw.ai CLI

The command-line interface for 2kw.ai — the EU-hosted AI integration platform. Run schema-driven document extraction, route LLM calls through an OpenAI-compatible gateway, transcribe audio, and manage prompts, datasets, and experiments — from your terminal or inside agentic workflows.

Installs three equivalent binaries: 2kw, backbone, and bb.

Installation

# Latest stable release
npm install -g @2kw/ai

# Pre-release (dev channel)
npm install -g @2kw/ai@dev

The CLI notifies you when a newer version is available.

Quick Start

# Authenticate — opens your browser, no API key needed (7-day free trial)
2kw auth login

# Define a schema and run an extraction
2kw schemas create -n "Invoice"
2kw extractions create --schema <id> -m gpt-4o --text "Invoice #123, Total: €500"

# Convert and transcribe
2kw convert file report.docx --format md
2kw transcribe call.mp3 --format srt

# Chat through the gateway
2kw ai chat -m gpt-4o --message "Draft a summary of this quarter's extraction volume"

All commands work identically as bb for quick access — e.g. bb schemas list.

Authentication

Sign in via the browser (recommended):

2kw auth login

This opens your browser, asks you to confirm a short code, and signs the CLI in with your user account — no API key to copy. Your session lasts 7 days of inactivity and renews itself while you keep using the CLI. If you belong to several organizations you pick one at login, and can switch any time with 2kw context set-org — no re-login needed. 2kw auth logout clears the local credentials and signs the session out server-side (best-effort).

For CI, scripts, or air-gapped machines, store an org API key instead (create one under Settings → API Keys in the web app):

2kw auth login --api-key sk_...   # save a key directly
2kw auth login --manual           # prompted setup (legacy flow)

Explicit API keys always take priority over a stored browser session (highest priority first):

MethodExample
CLI flags--api-key sk_... --base-url https://...
Environment variablesAI_2KW_API_KEY, AI_2KW_BASE_URL (legacy: BACKBONE_*)
Local .2kw fileJSON file in the current directory (legacy: .backbone)
Config storeSet via 2kw auth login (browser session or saved key)
2kw auth status    # Verify credentials (works for both auth types)
2kw auth logout    # Clear credentials and send a server-side sign-out

Note: config get apiKey --json returns a masked value — stored secrets do not round-trip through stdout by default. Scripts needing the raw key pass --reveal (config get apiKey --reveal) or use AI_2KW_API_KEY.

Contexts

kubectl-style contexts switch between organizations and environments:

2kw context list              # List all contexts
2kw context use acme-corp     # Switch active context
2kw context create staging --base-url https://api.staging.example   # Create a context, sign in through the browser
2kw context create ci --api-key sk_...   # Or store an API key instead

2kw config set memory true makes an API-key context send X-Backbone-Memory: enabled on ai respond and agents run calls, which opts those runs into agent memory; AI_2KW_MEMORY=true|false overrides it per shell. Runs from a browser-login (session) context are always eligible for agent memory regardless of this setting, so memory false only affects API-key contexts.

Commands

CommandDescription
authLogin, logout, and check auth status
configGet, set, and list configuration values
contextManage contexts for multiple orgs/environments
schemasManage schemas, versions, labels, validation, and testing
promptsVersioned prompt management, labels, compilation, testing
extractionsCreate extractions (text, file, images), list, re-run, estimate tokens
convertConvert PDF, DOCX, XLSX, images, and 20+ formats to Markdown/text/HTML/JSON
aiChat completions, Responses (agent or direct model), and model listing via the OpenAI-compatible gateway
transcribeTranscribe audio (FLAC, MP3, MP4, OGG, WAV, WebM)
datasetsBuild datasets and dataset versions for evaluation
experimentsRun experiments against datasets
evaluatorsManage evaluator templates
scoresRecord and inspect quality scores
tracingInspect request traces and tracing settings
memoryYour agent memory files (list, read, write, delete, forget); member totals and erasure for admins
providersManage BYOK AI providers
analyticsUsage analytics: operations, tokens, quality, providers, errors
billingCheck subscription tier and usage limits
agentsRun agents and answer paused runs (approvals and relayed tool calls); apply, export and scaffold agent.yaml; manage versions, labels, approvals and tool catalogs
skillsImport and export SKILL.md bundles; manage skill versions and labels
pluginsInstall plugin repositories, sync them, and inspect their reports
conversationsCreate and manage conversations and their items
knowledgeManage knowledge bases, documents, search, and citations
filesUpload, download, and manage files
installationsManage surface installations, keys, origins, and pairing
docsBrowse API documentation from the terminal

Global Options

FlagDescription
--api-key <key>Override the API key
--base-url <url>Override the base URL (defaults to the 2kw.ai cloud API)
--jsonOutput raw JSON instead of formatted tables — built for scripting and agents
--no-colorDisable colored output

Why 2kw.ai

  • EU data residency — built-in models run GDPR-compliant and EU-hosted, operated by Manfred Kunze Development GmbH (Germany)
  • Grounding scores — every extracted value links back to where it came from in the source document
  • One platform — gateway, extraction, transcription, and observability share one API and one bill

License

Proprietary — see LICENSE for details.

版本与发布记录

@2kw/ai 共发布 196 个版本,首次发布于 2026/04/27;过去 12 个月发布了 196 个版本。

版本发布日期距今
8.2.1latest2026/11/10今天
8.3.0-dev.4dev2026/11/09今天
8.3.0-dev.32026/11/09今天
8.2.02026/11/091 天前
8.2.0-dev.112026/11/091 天前
8.2.0-dev.102026/11/073 天前

关于 @2kw/ai 的常见问题

@2kw/ai 是什么?

CLI for 2kw.ai — schema-driven document extraction, an OpenAI-compatible EU LLM gateway, transcription, prompts, datasets, and experiments from your terminal or agentic workflows. Ships as 2kw, backbone, and bb.

如何安装 @2kw/ai?

在项目目录运行 npm install @2kw/ai,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 bb、2kw、backbone,可以用 npx bb 直接运行。

@2kw/ai 支持 TypeScript 吗?

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

@2kw/ai 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@2kw/ai 需要什么版本的 Node.js?

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

@2kw/ai 可以商用吗?

@2kw/ai 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@2kw/ai 的下载量有多少?

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

@2kw/ai 还在维护吗?

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