@formio/uag-grok

中文文档
2.0.0发布于 2026/11/13MITCommonJS构建来源已验证近 30 天下载 2098

Grok engine for the Form.io Universal Agent Gateway (UAG): xAI's models, for structured extraction with research over read-only tools.

原始使用文档
文档目录5 节
  1. Settings
  2. Instances
  3. Choosing a model
  4. How it works
  5. Using it in your own server

@formio/uag-grok

Form.io UAG › Engines › this page

The Grok agent engine for the UAG Agent API: xAI's models, through xAI's OpenAI-compatible API. It extracts and generates open values (dates, amounts, names, free text) with structured outputs. When a task lists read-only tools in uagTools, it researches with them first.

It is included in the formio/uag Docker image. With the UAG installed from npm, install it next to it:

npm install @formio/uag-grok

Enable it by naming it, and set its key and model:

UAG_ENGINES=grok
XAI_API_KEY=...
XAI_MODEL=<a Grok model ID>

Its tasks are Agentic Formflow, so on a self-hosted project the UAG also needs a LICENSE_KEY that includes the UAG for the project's endpoint (see Licensing); a project on Form.io's hosted service needs none. A form's chat needs no license on Form.io Open Source or a hosted project.

Settings

SettingVariablesDefault
apiKeyUAG_ENGINE_<NAME>_API_KEY, XAI_API_KEYrequired (secret)
modelUAG_ENGINE_<NAME>_MODEL, XAI_MODELrequired; there is no default
baseURLUAG_ENGINE_<NAME>_BASE_URLhttps://api.x.ai/v1
structuredOutputUAG_ENGINE_<NAME>_STRUCTURED_OUTPUTjson_schema; json_object or prompt if a model refuses strict schemas

<NAME> is the instance name, upper-cased with - as _. An instance's own variable wins over the shared one.

Instances

A fast Grok model for routine values next to Claude for the rest:

UAG_ENGINES=jev,fast:grok,claude
XAI_API_KEY=...
UAG_ENGINE_FAST_MODEL=<a fast Grok model ID>
CLAUDE_API_KEY=...

Routing lists, and a field's uagEngine property, name the instances, for example routing.value: ["fast", "claude"].

Choosing a model

There is no default model: set model to a specific model ID from xAI's documentation, not an alias that moves. Answers differ between models, so compare them on your own labeled examples before switching (uag-eval measures decision engines only).

How it works

It is the OpenAI engine's agent kind with xAI's endpoint and key built in: one chat completion with a strict JSON schema per extraction, and a function-calling loop over the task's read-only tools for research, ending in the same structured answer. A refusal, a truncated answer or an answer that is not JSON is an engine failure, and the UAG falls back to the next engine.

Each field's format (such as date) and pattern are written into its description, not sent as schema constraints. Grok enforces constraints strictly, and every field is required in a strict schema, so it would otherwise invent a value that fits the pattern for a field the input does not state. The UAG validates every value either way.

Grok has no decision API, and current Grok models return no token probabilities, so this is an agent engine only. Decision fields routed to it are answered as extraction and reported calibrated: false.

Data residency: each request sends xAI the task's criteria, its input (or, without an input, the whole submission except the fields being answered), its uagContext values and today's date, and, for a task that researches, what its tools return.

Using it in your own server

const server = new UAGServer({ engines: [{ name: 'grok', type: 'grok', options: { model: '<a Grok model ID>' } }] });

License: MIT.

版本与发布记录

@formio/uag-grok 共发布 13 个版本,首次发布于 2026/10/30;过去 12 个月发布了 13 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.0.0latest2026/11/132 天前
2.0.0-rc.11rc2026/11/105 天前
2.0.0-rc.102026/11/087 天前
2.0.0-rc.92026/11/079 天前
2.0.0-rc.82026/11/069 天前
2.0.0-rc.72026/11/0610 天前

关于 @formio/uag-grok 的常见问题

@formio/uag-grok 是什么?

Grok engine for the Form.io Universal Agent Gateway (UAG): xAI's models, for structured extraction with research over read-only tools.

如何安装 @formio/uag-grok?

在项目目录运行 npm install @formio/uag-grok,或使用 pnpm add / yarn add / bun add。

@formio/uag-grok 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/formio__uag-grok 是否存在。

@formio/uag-grok 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@formio/uag-grok 需要什么版本的 Node.js?

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

@formio/uag-grok 可以商用吗?

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

@formio/uag-grok 的下载量有多少?

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

@formio/uag-grok 还在维护吗?

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