@agent-relay/credential-proxy

中文文档
7.1.1发布于 2026/05/25TypeScriptES Module构建来源已验证近 30 天下载 3991

JWT-authenticated credential proxy for upstream LLM providers

原始使用文档
文档目录4 节
  1. What it is
  2. Environment variables
  3. Usage
  4. Development

@agent-relay/credential-proxy

JWT-authenticated credential proxy for upstream LLM providers. Lets sandboxed agents call provider APIs (OpenAI, Anthropic, OpenRouter) without being given raw provider credentials — the proxy holds the keys, agents present per-session JWTs, and the proxy enforces per-credential token budgets.

What it is

A Hono app plus a handful of helpers:

  • createCredentialProxyApp(options) — mounts the HTTP router (/health, /usage, and a catch-all provider-forwarding route under *). Use it directly in Node (via @hono/node-server) or bind it inside a Cloudflare Worker.
  • mintProxyToken(...) / verifyProxyToken(...) — JWT helpers built on jose. HS256 by default, audience relay-llm-proxy.
  • MeteringCollector + checkBudget — in-memory usage accounting with pessimistic reservations so concurrent requests can't bypass the declared budget.
  • Provider adapters under providers/ — translate incoming JWT claims to the correct upstream HTTP request for OpenAI / Anthropic / OpenRouter.

Environment variables

Required at runtime (the host of the proxy):

VariablePurpose
CREDENTIAL_PROXY_JWT_SECRETHS256 secret the proxy uses to verify per-session JWTs.
CREDENTIAL_PROXY_ADMIN_JWT_SECRETSecret for admin-scoped tokens (e.g. the /usage endpoint).
CREDENTIAL_PROXY_ADMIN_AUDIENCEAudience claim the proxy requires on admin tokens.
OPENAI_API_KEYUpstream credential for the OpenAI provider adapter.
ANTHROPIC_API_KEYUpstream credential for the Anthropic provider adapter.
OPENROUTER_API_KEYUpstream credential for the OpenRouter provider adapter.

Only the provider keys you actually forward to need to be set — missing keys surface as 502 credential_unavailable on the relevant route.

The agent side (whichever process mints tokens and launches the sandboxed CLI) uses CREDENTIAL_PROXY_JWT_SECRET to sign tokens and puts them into the agent's environment as CREDENTIAL_PROXY_TOKEN (alias: RELAY_LLM_PROXY_TOKEN) plus RELAY_LLM_PROXY / RELAY_LLM_PROXY_URL so the SDK's proxy-env helpers can wire up per-CLI OPENAI_BASE_URL / ANTHROPIC_BASE_URL overrides.

Usage

import { serve } from '@hono/node-server';
import { createCredentialProxyApp } from '@agent-relay/credential-proxy';

const app = createCredentialProxyApp({
  // Defaults to process.env.CREDENTIAL_PROXY_JWT_SECRET / ADMIN_JWT_SECRET.
});

serve({ fetch: app.fetch, port: Number(process.env.PORT ?? 3001) });

For the SDK-side wiring that lets workflow agents use the proxy transparently, see @agent-relay/sdk/workflows's proxy-env module and the credentialProxy field on SwarmConfig.

Development

npm run build      # tsc → dist/
npm run test       # vitest
npm run dev        # builds then runs the proxy on PORT (default 3001)

版本与发布记录

@agent-relay/credential-proxy 共发布 48 个版本,首次发布于 2026/04/22;过去 12 个月发布了 48 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
7.1.1latest2026/05/255 个月前
7.1.02026/05/235 个月前
7.0.12026/05/225 个月前
6.3.62026/05/225 个月前
7.0.02026/05/225 个月前
6.3.52026/05/225 个月前

关于 @agent-relay/credential-proxy 的常见问题

@agent-relay/credential-proxy 是什么?

JWT-authenticated credential proxy for upstream LLM providers

如何安装 @agent-relay/credential-proxy?

在项目目录运行 npm install @agent-relay/credential-proxy,或使用 pnpm add / yarn add / bun add。

@agent-relay/credential-proxy 支持 TypeScript 吗?

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

@agent-relay/credential-proxy 支持 ESM 还是 CommonJS?

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

@agent-relay/credential-proxy 可以商用吗?

@agent-relay/credential-proxy 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@agent-relay/credential-proxy 的下载量有多少?

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

@agent-relay/credential-proxy 还在维护吗?

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