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

ccr-transformer-content-fix

v1.0.0

Published

Fix Anthropic content arrays to OpenAI string format for Claude Code Router

Readme

ccr-transformer-content-fix

Claude Code Router 自定义 transformer,解决 OpenAI 兼容 API 报错 模型参数content不正确 的问题。

问题背景

Claude Code 发送的请求中 content 是 Anthropic 格式的数组:

{"content": [{"type": "text", "text": "hello"}]}

部分 OpenAI 兼容 API 严格要求 content 必须是字符串:

{"content": "hello"}

ccr 内置的 openrouterdeepseekOpenAI transformer 均未做此转换,导致 400 错误。

安装方式

方式一:npm 安装(推荐)

npm install -g ccr-transformer-content-fix

方式二:手动安装

mkdir -p ~/.claude-code-router/plugins
cd ~/.claude-code-router/plugins
# 将本仓库的 index.js 和 package.json 放入 content-fix/ 目录

配置

~/.claude-code-router/config.json 中添加:

{
  "transformers": [
    {
      "name": "content-fix",
      "path": "ccr-transformer-content-fix"
    }
  ],
  "Providers": [
    {
      "transformer": {
        "use": ["content-fix", "deepseek", "tooluse", "reasoning", "maxtoken"],
        "maxtoken": { "max_tokens": 32000 }
      }
    }
  ]
}

注意content-fix 必须放在 transformer 链的第一位,确保在其他 transformer 处理之前先把 content 转成字符串。

手动安装时的 path 配置

如果手动放在 ~/.claude-code-router/plugins/content-fix/,path 写绝对路径:

"path": "/Users/你的用户名/.claude-code-router/plugins/content-fix/index.js"

Transformer 链说明

| 顺序 | Transformer | 作用 | |------|-------------|------| | 1 | content-fix | content 数组 → 字符串 | | 2 | deepseek | Anthropic ↔ DeepSeek/OpenAI 协议转换 | | 3 | tooluse | tool_choice 优化 | | 4 | reasoning | 处理 reasoning_content | | 5 | maxtoken | 设置 max_tokens |

根据你的 API 类型,第 2 个 transformer 可替换为 openrouterOpenAI

License

MIT