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

@light-ling/ai-test

v1.0.0

Published

OpenAI-compatible AI connectivity test CLI with .env defaults and command-line overrides.

Readme

ai-test

@light-ling/ai-test 是一个基于 OpenAI 兼容接口 的 AI 连通性测试工具。

它适合用来快速验证:

  • 接口地址是否可达
  • API Key 是否有效
  • 模型是否能正常返回结果
  • chat.completions / responses 哪个能用

功能特点

  • 默认从 .env 读取配置
  • 命令行参数可覆盖 .env
  • 支持测试:
    • chat.completions
    • responses
    • both
  • responses 自动按 官方 message 数组格式 发送 input
  • 如果模型写成 provider/model,会自动去掉前缀再请求
  • 默认测试文本就是一句:你好
  • 支持彩色输出
  • 支持 --verbose 查看详细错误
  • 支持 --name / --provider-name 自定义显示名称
  • 可作为全局命令使用:ai-test

安装方式

说明:当前包使用单 CLI 入口配置,发布时命令名就是 ai-test

本地开发

npm install
npm link

安装完成后可直接运行:

ai-test --help

发布到 npm 后

npm install -g @light-ling/ai-test

注意:真正发布前,请先确认 ai-test 这个包名在 npm 上没有被占用。


如何使用

1)准备 .env

复制 .env.example.env,或者直接新建 .env

AI_TEST_NAME=AI Test
AI_TEST_URL=https://your-openai-compatible-endpoint.example/v1
AI_TEST_API_KEY=sk-xxxxxxxxxxxxxxxx
AI_TEST_MODEL=gpt-4.1-mini
AI_TEST_API=both
AI_TEST_TIMEOUT_MS=30000
AI_TEST_DEVELOPER_PROMPT=你是一个连通性测试端点。
AI_TEST_PROMPT=你好
AI_TEST_MAX_OUTPUT_TOKENS=16
AI_TEST_VERBOSE=false

2)直接运行

ai-test

默认就会发送一句:

你好

不需要用户手动输入提示词。


常见命令示例

使用 .env 默认配置

ai-test

覆盖 URL 和模型

ai-test -u https://example.com/v1 -m claude-sonnet-4-6

指定测试模式

ai-test -a chat
ai-test -a responses
ai-test -a both

自定义显示名称

ai-test --name GMN
ai-test --provider-name ClaudeProxy

输出详细错误

ai-test --verbose

使用 JSON 输出

ai-test --json

指定其他 .env 文件

ai-test --env ./configs/gmn.env

命令行参数说明

  • -u, --url <url>:OpenAI 兼容接口地址
  • -k, --api-key <key>:API Key
  • -m, --model <model>:模型名称
  • -a, --api <chat|responses|both>:测试哪种接口,默认 both
  • -t, --timeout <ms>:超时时间(毫秒)
  • -n, --name <label>:输出里显示的名称
  • --provider-name <label>--name 的别名
  • --max-output-tokens <n>:最大输出 token 数
  • --env <path>:指定 .env 文件路径
  • --json:JSON 输出
  • -v, --verbose:输出详细错误信息
  • -h, --help:显示帮助

配置优先级

优先级从高到低:

  1. 命令行参数
  2. .env 文件
  3. 代码中的默认值

也就是说:

ai-test -m gmn/gpt-5.3-codex

工具会自动规范化模型名,最终实际请求时使用:

gpt-5.3-codex

输出结果说明

成功示例

=== AI Test ===
[成功] responses.create 调用成功,耗时 1200ms
[返回] "你好!有什么可以帮你?"

失败示例

=== AI Test ===
[失败] responses.create 调用失败
状态码  : 503
错误信息: Service temporarily unavailable

如果加上 --verbose,还会额外打印完整错误详情。


发布前检查

我另外给你放了一份:

PUBLISH.md

里面是发布到 npm 前要走的检查清单,按那个来就行。