npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

replicate-token-verification

v1.0.1

Published

CLI to check whether a Replicate API token can be directly used

Readme

replicate-token-verification

一个基于主流 CLI 库的 Node.js 中文命令行工具,用来快速判断给定的 Replicate API Token 当前能不能直接使用。

支持两种使用方式:

  • 交互式启动后手动输入 Token
  • 一键执行,直接通过参数或环境变量传入 Token

环境要求

  • Node.js 20.12+

安装

在当前目录下直接运行:

node ./bin/replicate-token-verification.js
node ./bin/replicate-token-verification.js --token r8_xxx

或者安装为全局命令:

npm install -g .
rtv

发布到 npm 后,也可以直接全局安装:

npm install -g replicate-token-verification
rtv

基本用法

rtv
rtv --token <token>
rtv <token>
rtv --token-from-env REPLICATE_API_TOKEN

可用选项

--json      输出 JSON,适合脚本调用
--quiet     仅输出最终结果
--no-loop   交互模式下只校验一次后退出
--token-from-env <name>   从指定环境变量读取 Token
--no-model-test   跳过调用测试,只检查认证状态和账号状态

交互模式

直接运行:

rtv

CLI 会提示你输入 Token,输入后按回车即可开始校验。 输入过程会明文显示 Token,每次校验完成后会询问是否继续校验下一个 Token。

如果你只想交互校验一次:

rtv --no-loop

一键执行

rtv --token r8_xxx
rtv r8_xxx
REPLICATE_API_TOKEN=r8_xxx rtv --token-from-env REPLICATE_API_TOKEN
rtv --token r8_xxx --quiet

脚本调用

如果你希望给脚本或 CI 使用:

rtv --token r8_xxx --json

如果你明确希望从环境变量取值:

REPLICATE_API_TOKEN=r8_xxx rtv --token-from-env REPLICATE_API_TOKEN

--json 模式下会输出这些核心字段:

  • usabilityStatus:当前 Token 是否可直接使用
  • authStatus:认证是否通过
  • accountStatus:账号状态
  • modelStatus:调用测试结果

如果你更偏向直接执行,也可以这样:

npx replicate-token-verification --token r8_xxx

如果你只想检查认证状态和账号状态,不做调用测试:

rtv --token r8_xxx --no-model-test

返回码说明

  • 当前 Token 可直接使用:退出码 0
  • 当前 Token 不可直接使用:退出码 1
  • 请求失败、结果未知或缺少 Token:退出码 1

校验原理

CLI 默认会执行两段校验:

  1. 请求 GET /v1/account 判断认证是否通过,以及账号当前是否可用
  2. 使用 replicate/hello-world 做一次最小调用测试,判断这个 Token 是否具备实际调用模型的能力

返回结果会区分:

  • 可直接使用:可直接使用 / 不可直接使用 / 大概率可直接使用 / 未知
  • 认证状态:已通过 / 未通过 / 未知
  • 账号状态:可用 / 账单受限 / 未知
  • 调用测试:可调用 / 已接受调用 / 因账号账单问题不可调用 / 无权限调用 / 未执行 / 未知

说明:

  • 默认会进行真实调用测试,这可能触发一次实际的 Replicate 模型请求
  • 如果你不希望执行调用测试,可以加 --no-model-test
  • 普通终端输出会使用颜色高亮状态:通过/可用为绿色,未通过/不可用为红色,未知为黄色
  • 返回详情默认按原始返回内容展示;如果接口返回的是 JSON,会以格式化 JSON 形式展示

发布到 npm

这个项目已经具备标准 npm CLI 包结构:

  • bin 字段已配置全局命令 rtv
  • files 仅发布必要文件
  • publishConfig.access 已设为 public

发布时直接执行:

npm publish