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

claude-local-proxy

v1.1.0

Published

A proxy server that converts Anthropic protocol requests into the OpenAI protocol format.

Readme

Claude-Local-Proxy

一个将 Anthropic 协议请求转换为 OpenAI 协议请求的代理服务器。

English | 中文 | Changelog

功能特性

  • 将 Anthropic API 格式转换为 OpenAI API 格式
  • 支持流式和非流式响应
  • 支持工具调用
  • 支持图片输入
  • 完整的 token 使用统计
  • 简单的认证机制

安装

作为 npm 包(推荐)

npm install -g claude-local-proxy

从 GitHub Release 下载

# 如果使用 dist 文件夹
node dist/cli/index.js start

# 如果使用源码,先构建
npm install
npm run build
node dist/cli/index.js start

快速开始

clp start

如果没有配置文件,服务会自动引导你进行配置:

? Configuration file does not exist. Do you want to configure now? (y/N): y
? Enter API Key: xxx-xxxxxxxxxxxxxxxx
listening on localhost:8888

完整配置指南:

  1. 启动服务(如无配置会自动引导):

    clp start
  2. 配置 Claude Code 模型(推荐):

    clp model setup

    这将引导你分别为 HAIKU、SONNET 和 OPUS 选择模型:

    === Claude Code Model Configuration ===
       
    Found 2 available models:
      1. z-ai/glm4.7
      2. minimaxai/minimax-m2.7
       
    Available models for ANTHROPIC_DEFAULT_HAIKU_MODEL:
      1. z-ai/glm4.7 (default)
      2. minimaxai/minimax-m2.7
    Select model for ANTHROPIC_DEFAULT_HAIKU_MODEL [1-2, default: 1]: 1
       
    Available models for ANTHROPIC_DEFAULT_SONNET_MODEL:
      1. z-ai/glm4.7
      2. minimaxai/minimax-m2.7 (default)
    Select model for ANTHROPIC_DEFAULT_SONNET_MODEL [1-2, default: 2]: 2
       
    Available models for ANTHROPIC_DEFAULT_OPUS_MODEL:
      1. z-ai/glm4.7 (default)
      2. minimaxai/minimax-m2.7
    Select model for ANTHROPIC_DEFAULT_OPUS_MODEL [1-2, default: 1]: 1
       
    ========================================
    Model configuration complete:
      ANTHROPIC_DEFAULT_HAIKU_MODEL  -> z-ai/glm4.7
      ANTHROPIC_DEFAULT_SONNET_MODEL -> minimaxai/minimax-m2.7
      ANTHROPIC_DEFAULT_OPUS_MODEL    -> z-ai/glm4.7
    ========================================
    Please start or restart Claude Code to apply the configuration.

    此命令会:

    • 备份现有的 Claude Code 配置
    • 自动配置三个模型层级(HAIKU、SONNET、OPUS)
    • 安装配置到 ~/.claude/settings.json
    • 自动启动或重启代理服务
  3. 重启 Claude Code 使配置生效。

其他命令

  • clp config - 配置或重新配置代理(需要 API Key)
  • clp start - 启动代理服务
  • clp stop - 停止代理服务
  • clp restart - 重启代理服务
  • clp status - 查看服务状态
  • clp logs - 查看最近日志
  • clp logs --tail - 实时跟踪日志
  • clp logs --lines=100 - 查看最近 N 行日志
  • clp logs --error - 只查看错误日志
  • clp logs --access - 只查看访问日志
  • clp model list - 列出可用模型
  • clp model add <model> - 添加新模型(如:clp model add z-ai/glm4.7)
  • clp model rm <model> - 删除模型(按名称或索引)
  • clp model setup - 配置 Claude Code 模型层级(HAIKU、SONNET、OPUS)
  • clp test - 测试所有可用模型
  • clp test <model> - 测试指定模型

配置

配置文件

| 操作系统 | 位置 | |---------|------| | Windows | C:\Users\<username>\.claude-local-proxy\settings.json | | macOS / Linux | ~/.claude-local-proxy/settings.json |

格式:

{
  "PROXY_URL": "localhost:8888",
  "API_BASE_URL": "https://integrate.api.nvidia.com/v1/chat/completions",
  "API_KEY": "your-api-key",
  "SERVER_KEY": "your-secret-key",
  "TIMEOUT": 300000,
  "LOG_BODY_MAX": 4096,
  "LOG_STREAM_PREVIEW_MAX": 256
}

配置项

| 配置项 | 说明 | 默认值 | |--------|-------------|---------| | PROXY_URL | 服务器监听地址 | localhost:8888 | | API_BASE_URL | API 地址 | 必填 | | API_KEY | API 密钥 | 必填 | | SERVER_KEY | 服务器认证密钥 | 可选 | | TIMEOUT | 上游请求超时(毫秒) | 300000 | | LOG_BODY_MAX | 日志最大字符数 | 4096 | | LOG_STREAM_PREVIEW_MAX | 流预览字符数 | 256 |

环境变量

环境变量可覆盖配置文件(优先级更高):

| 变量 | 说明 | 默认值 | |----------|-------------|---------| | PROXY_URL | 服务器监听地址 | 配置值 | | API_BASE_URL | API 地址 | 配置值 | | API_KEY | API 密钥 | 配置值 | | SERVER_KEY | 服务器认证密钥 | 配置值 | | TIMEOUT | 上游超时(毫秒) | 配置值 | | LOG_BODY_MAX | 日志最大字符数 | 配置值 | | LOG_STREAM_PREVIEW_MAX | 流预览字符数 | 配置值 |

日志系统

| 操作系统 | 日志位置 | |---------|-------------| | Windows | C:\Users\<username>\.claude-local-proxy\logs\ | | macOS / Linux | ~/.claude-local-proxy/logs/ |

日志类型:

  • proxy-YYYY-MM-DD.log - 主日志
  • error-YYYY-MM-DD.log - 错误日志
  • access-YYYY-MM-DD.log - 访问日志

特性:

  • 按日期轮转
  • 单文件最大 10MB
  • 自动清理 7 天前的日志
  • 同时输出到控制台和文件

API 使用

请求格式

curl -X POST http://localhost:8888/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: your-secret-key" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "z-ai/glm4.7",
    "max_tokens": 100,
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'

支持的模型

  • z-ai/glm4.7
  • minimaxai/minimax-m2.7

Claude Code 配置

使用 model setup 命令

推荐使用 model setup 命令自动配置 Claude Code:

clp model setup

此命令会:

  1. 读取可用模型列表(从 ~/.claude-local-proxy/models.json)
  2. 引导选择三个模型(HAIKU、SONNET、OPUS)
  3. 自动生成 Claude Code 配置文件
  4. 备份原有配置(如存在)
  5. 安装新配置到 ~/.claude/settings.json
  6. 自动启动或重启代理服务
  7. 显示模型配置映射
  8. 提示重启 Claude Code

模型管理

使用 model setup 前可管理模型列表:

  • clp model list - 列出可用模型
  • clp model add <model> - 添加新模型(如:clp model add z-ai/glm4.7)
  • clp model rm <model> - 删除模型(按名称或索引,如 clp model rm z-ai/glm4.7 或 clp model rm 1)

注意:

  • 添加时如已存在会提示 "Model already exists"
  • 删除时如只剩一个会提示 "Cannot remove the last model"

手动配置

手动创建 ~/.claude/settings.json:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your-secret-key",
    "ANTHROPIC_BASE_URL": "http://localhost:8888",
    "API_TIMEOUT_MS": "300000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "z-ai/glm4.7",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "z-ai/glm4.7",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "z-ai/glm4.7"
  },
  "includeCoAuthoredBy": false
}

模型配置

可用模型存储在 ~/.claude-local-proxy/models.json

默认模型:

["z-ai/glm4.7", "minimaxai/minimax-m2.7"]

故障排查

服务无法启动

  1. 检查配置是否存在:

    clp status
  2. 运行配置命令:

    clp config
  3. 检查端口是否被占用:

    # macOS/Linux
    lsof -i :8888
    # Windows
    netstat -ano | findstr :8888
  4. 查看错误日志:

    clp logs --error

重置配置

rm ~/.claude-local-proxy/settings.json
clp config

重置 Claude Code 配置

clp stop
# 或手动删除备份后重新配置
rm ~/.claude/settings.json.claude-local-proxy.bak
clp model setup

许可证

MIT

贡献

欢迎提交 Issue 和 Pull Request!详见 .github/CONTRIBUTING.md