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

@mackwan84/dsh-image-openai-compat

v0.3.0

Published

OpenAI 兼容网关图像生成 Provider:面向 one-api / new-api 等聚合网关与官方 OpenAI 的 /v1/images/generations 同步调用(最小公共子集:model/prompt/n/size + b64/url 双格式归一)

Readme

@mackwan84/dsh-image-openai-compat

English

OpenAI 兼容网关图像生成 Provider,实现 @mackwan84/dsh-imageImageGenerationService。面向 one-api / new-api 等私有聚合网关(官方 OpenAI 是可配特例),锚定 POST {baseUrl}/images/generations 同步协议:

  • 最小公共子集model + prompt + n + size 四参数,不发送 response_format / watermark 等任何 Provider 专属参数;
  • n 原生下传:多图一次请求携带 n(与方舟 Provider 的串行拆单策略不同);
  • 双返回格式归一data[].b64_json → data URL;data[].url 原样透传, 由消费方现有下载链路立即转存(url 永不持久化);
  • 尺寸透传"1280*720" 归一为 "1280x720" 后透传,本地不设预设白名单、 不改比例,由网关自行校验(拒绝时错误透传);
  • 能力边界:参考图(I2I)与指令编辑(/v1/images/edits,multipart)不在 最小子集内,显式 NOT_IMPLEMENTED
  • 无内置退避重试:429 直接按 RATE_LIMITED 上报,由调用方决策;
  • 凭据解析:ctx.credentials seam → 启动环境(.env/进程环境)→ MISSING_CREDENTIAL
  • 请求 redirect: 'error'(凭据不跟随重定向)。

配置(cordis.yml config 块)

| 键 | 默认 | 说明 | | ------------------- | ----------------------- | ---------------------------------------------------------------------------------- | | apiKey | OPENAI_COMPAT_API_KEY | 凭据引用(环境变量名) | | baseUrl | (空) | 网关地址,填到 /v1 为止(通常以 /v1 结尾);空=未配置报明确错误,**不自动补 /v1** | | wireframeModel | (空) | 线框图分层默认模型(部署期预置;空=生成时报可操作错误) | |highFidelityModel| (空) | 高保真分层默认模型(同上) | |requestTimeoutMs` | 300000 | 同步请求超时(生图网关常见 30~120s) |

错误语义

| 响应 | 错误码 | | --------------------------------------------- | ------------------------------------------------------------------------------- | | 401 / InvalidApiKey / AuthenticationError | MISSING_CREDENTIAL | | 400 / InvalidParameter | INVALID_PARAMETER | | 429 | RATE_LIMITED | | 其余非 2xx | HTTP_ERROR(透传状态码与 error.code/message,兼容顶层 code/message 包裹) | | 响应体非 JSON(如网关前端 HTML 页) | { message: 前 200 字符 } 参与错误文本 | | 响应缺少图片结果 | BAD_RESPONSE | | 超时 / 连接失败 | TIMEOUT / NETWORK_ERROR |

已知网关方言(实测,进 docs/references)

  • base URL 不带 /v1 时,部分网关 GET /models 返回前端 HTML 页且 HTTP 200(非 404);
  • new_api 系部分网关拒绝 n > 1(400);模型不存在返回 503 而非 404。