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

iflow-proxy

v1.0.0

Published

iFlow API 反向代理 - 提供 OpenAI / Anthropic 兼容接口,支持多账号轮换,适配 Claude Code / Cline 等工具

Readme

iflow-proxy

iFlow API 反向代理 — 提供 OpenAIAnthropic 兼容接口,支持多账号自动轮换。

可直接对接 Claude CodeClineLangChainOpenAI SDK 等工具。

功能

  • OpenAI 兼容 API/v1/chat/completions/v1/models
  • Anthropic 兼容 API/v1/messages/v1/messages/count_tokens
  • 多账号轮换:Round-Robin / Fill-First 策略
  • 两种登录方式:OAuth 手机登录 + Cookie 登录
  • 自动刷新:Token 过期前自动刷新凭据
  • 配额切换:账号配额耗尽自动切换到下一个
  • 流式支持:完整支持 SSE 流式响应
  • Web 管理面板:实时统计、Token 消耗图表、账号管理
  • 跨平台:Windows / macOS / Linux 均可运行

安装

# 全局安装
npm install -g iflow-proxy

# 或用 npx 直接运行(无需安装)
npx iflow-proxy

快速开始

# 1. 初始化配置文件(可选,在当前目录生成 config.yaml)
iflow-proxy init

# 2. 添加 iFlow 账号(OAuth 手机登录)
iflow-proxy login

# 或 Cookie 登录
iflow-proxy login:cookie

# 3. 启动代理服务
iflow-proxy

使用 npx(无需全局安装)

npx iflow-proxy               # 启动服务
npx iflow-proxy login          # 添加账号
npx iflow-proxy init           # 生成配置

配置

配置文件搜索顺序:

  1. --config 命令行指定
  2. 当前目录的 config.yaml
  3. ~/.iflow-proxy/config.yaml
  4. 包自带的默认配置
port: 8318                          # 服务端口
host: "0.0.0.0"                     # 绑定地址
api-keys:                           # 客户端调用密钥
  - "sk-iflow-proxy-key"
auth-dir: "~/.iflow-proxy"         # 凭据存储目录
routing:
  strategy: "round-robin"           # round-robin | fill-first
quota-exceeded:
  switch-account: true              # 配额耗尽自动切换
log-level: "info"                   # debug | info | warn | error

调用示例

curl (OpenAI 格式)

curl http://localhost:8318/v1/chat/completions \
  -H "Authorization: Bearer sk-iflow-proxy-key" \
  -H "Content-Type: application/json" \
  -d '{"model": "glm-5", "messages": [{"role": "user", "content": "你好"}]}'

curl (Anthropic 格式)

curl http://localhost:8318/v1/messages \
  -H "x-api-key: sk-iflow-proxy-key" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{"model": "glm-5", "max_tokens": 1024, "messages": [{"role": "user", "content": "你好"}]}'

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    api_key="sk-iflow-proxy-key",
    base_url="http://localhost:8318/v1",
)
resp = client.chat.completions.create(
    model="glm-5",
    messages=[{"role": "user", "content": "你好"}],
)
print(resp.choices[0].message.content)

Python (Anthropic SDK / Claude Code)

import anthropic

client = anthropic.Anthropic(
    api_key="sk-iflow-proxy-key",
    base_url="http://localhost:8318",
)
resp = client.messages.create(
    model="glm-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "你好"}],
)
print(resp.content[0].text)

Node.js (OpenAI SDK)

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'sk-iflow-proxy-key',
  baseURL: 'http://localhost:8318/v1',
});

const response = await client.chat.completions.create({
  model: 'glm-5',
  messages: [{ role: 'user', content: '你好' }],
});
console.log(response.choices[0].message.content);

命令行参数

iflow-proxy [command] [options]

命令:
  start              启动代理服务(默认)
  login              OAuth 手机登录(添加账号)
  login:cookie       Cookie 登录
  init               在当前目录生成默认 config.yaml
  --help, -h         显示帮助

选项:
  --config <path>    指定配置文件路径

项目结构

iflow-proxy/
├── bin/
│   └── iflow-proxy.js       # CLI 入口
├── config.yaml               # 默认配置文件
├── package.json
├── public/                    # Web 管理面板
├── README.md
└── src/
    ├── index.js               # 服务入口(Express)
    ├── config.js              # 配置加载器
    ├── anthropic/
    │   └── adapter.js         # Anthropic ↔ OpenAI 双向转换器
    ├── auth/
    │   ├── credentials.js     # 凭据管理(加载/保存/刷新)
    │   └── selector.js        # 多账号轮换选择器
    ├── iflow/
    │   ├── signature.js       # iFlow 签名与请求头
    │   ├── client.js          # iFlow API 客户端
    │   └── models.js          # 模型列表管理
    └── cli/
        ├── login.js           # OAuth 登录脚本
        └── cookie-login.js    # Cookie 登录脚本

数据存储

所有数据存储在 ~/.iflow-proxy/ 目录下(跨平台通用):

~/.iflow-proxy/
├── iflow-*.json              # 账号凭据文件
└── data/
    └── stats.json            # 统计数据

复用已有凭据

如果你已通过 CLIProxyAPI 登录了 iFlow 账号:

# Linux / macOS
cp ~/.cli-proxy-api/iflow-*.json ~/.iflow-proxy/

# 或 Windows (PowerShell)
Copy-Item "$env:USERPROFILE\.cli-proxy-api\iflow-*.json" "$env:USERPROFILE\.iflow-proxy\"

License

MIT