# @asframe/opencode-iflow-auth 中文文档

规范地址：https://npmcn.com/package/%40asframe/opencode-iflow-auth/

版本：1\.0\.6
npm 元数据更新时间：2026-02-22T03:31:41.365Z
中文译文更新时间：2026-11-06T22:55:21.601Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40asframe/opencode-iflow-auth
原文对照：https://npmcn.com/package/%40asframe/opencode-iflow-auth/?lang=original
项目主页：https://github.com/asframe/opencode-iflow-auth#readme
源码仓库：https://github.com/asframe/opencode-iflow-auth

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：117 kB，42 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：4 个
- 首次发布：2026-02-21T10:54:41.263Z
- 最新版本发布：2026-02-22T03:31:41.244Z
- 近 30 天下载量：6400（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：7（近 12 个月 7 个）

## 中文简介

IFlow.cn 的 OpenCode 插件 - Access Quen, DeepSeek, Kimi, GLM-5 型号, 有 OAuth 2. 0, API 键, 和 CPI 代理支持

## 安装

```sh
npm install @asframe/opencode-iflow-auth
```

也可以使用：`pnpm add @asframe/opencode-iflow-auth`、`yarn add @asframe/opencode-iflow-auth`、`bun add @asframe/opencode-iflow-auth`

## README

# 打开代码 iFlow Auth 插件

[![npm version](https://img.shields.io/npm/v/@asframe/opencode-iflow-auth)](https://www.npmjs.com/package/@asframe/opencode-iflow-auth) [![npm downloads](https://img.shields.io/npm/dm/@asframe/opencode-iflow-auth)](https://www.npmjs.com/package/@asframe/opencode-iflow-auth) [![license](https://img.shields.io/npm/l/@asframe/opencode-iflow-auth)](https://www.npmjs.com/package/@asframe/opencode-iflow-auth) [![GitHub](https://img.shields.io/badge/GitHub-asframe%2Fopencode--iflow--auth-blue)](https://github.com/asframe/opencode-iflow-auth)

OpenCode插件为iFlow.cn提供对Quen,DeepSeek,Kimi,GLM,和有双重认证和CLI代理支持的iFlow ROME模型的访问.

## 特征

-   **双重认证**: OAuth 2.0 (PKCE)和API Key支持.
-   **CLI 代理模式**:通过iflow CLI支持GLM-5,使用自动代理服务器.
-   **多账户轮换**:粘接和圆旋相接策略.
-   **自动令牌刷新**: 速率限制处理与指数后退.
-   **本地思维模式**:支持GLM-4.x,GLM-5和DeepSeek R1模型.
-   **配置超时**: 请求超时和重复限制以防止绞刑.
-   **自动选择端口**: OAuth 回调服务器端口冲突避免.
-   **自动安装 CLI**: 如果找不到的话, 自动安装 iflow CLI .

## 支持的模式

### API 密钥模式 (`iflow` 提供者)

通过 OAuth 2.0 或 API 密钥认证可用的模型 :

| 型号 | A. 背景情况 | 产出 | 说明 |
| --- | --- | --- | --- |
| `deepseek-v3` | 128K (英语) | 32K 号 | 深搜索 V3 |
| `deepseek-v3.2` | 128K (英语) | 64K 车次 | 深搜索 V3.2 |
| `deepseek-r1` | 128K (英语) | 32K 号 | 深搜索 R1 (思维) |
| `glm-4.6` | 200 000K 电话 | 128K (英语) | GLM-4.6(反响、视觉) |
| `glm-4.7` | 256K (韩语) | 64K 车次 | GLM-4.7(最近、原因、愿景) |
| `qwen3-max` | 256K (韩语) | 32K 号 | Qwen3 麦斯 |
| `qwen3-max-preview` | 256K (韩语) | 32K 号 | Quen3 最大预览 |
| `qwen3-coder-plus` | 1门 | 64K 车次 | Quen3 编码器加 |
| `qwen3-vl-plus` | 256K (韩语) | 32K 号 | Quen3 VL Plus (图像) |
| `qwen3-32b` | 128K (英语) | 32K 号 | 倒数32B |
| `qwen3-235b` | 256K (韩语) | 64K 车次 | Quen3 235B (中文(简体) ) |
| `qwen3-235b-a22b-thinking-2507` | 256K (韩语) | 64K 车次 | Quen3 235B (中文(简体) ). 思考 |
| `qwen3-235b-a22b-instruct` | 256K (韩语) | 64K 车次 | Quen3 235B (中文(简体) ). 指示 |
| `kimi-k2` | 128K (英语) | 64K 车次 | 木卫一 K2 |
| `kimi-k2-0905` | 256K (韩语) | 64K 车次 | Kimi K2 0905 (英语) |
| `iflow-rome-30ba3b` | 256K (韩语) | 64K 车次 | iFlow ROME 30B (英语) |

### CLI 代理模式( R)`iflow-proxy` 提供者)

**API 密钥模式的所有模型** 推出这些独家模式:

| 型号 | A. 背景情况 | 产出 | 说明 |
| --- | --- | --- | --- |
| `glm-5` | 256K (韩语) | 64K 车次 | GLM-5 - 旗舰模型(744B params, 40B 活性),最适合推理和编码 |
| `glm-5-free` | 256K (韩语) | 64K 车次 | GLM-5 自由 - 与 glm-5 相同的能力,但时间有限 |
| `glm-5-thinking` | 256K (韩语) | 64K 车次 | GLM-5 思考 - 增强"系统2"深度推理能力 |

**GLM-5 模范家庭:**

| 型号 | 说明 |
| --- | --- |
| `glm-5` | 来自Zhipu AI. 744B参数(40B活性)的最新旗舰型号,28.5T令牌. 最擅长推理,编码,代理任务. |
| `glm-5-free` | 在宣传期间免费使用GLM-5. 同样的能力,没有费用. |
| `glm-5-thinking` | 增强深度推理模式. 在复杂的建筑问题和"第2集"的思考上表现得非常出色. |

**总结:**

-   **API 密钥模式**16个型号
-   **CLI 代理模式**: 19个型号(16+3独家)

**说明**: CLI 语言 如果您更喜欢任何模型的CLI认证而不是API Key,也可以使用代理模式.

## 两个插件模式

此套件导出两个插件 :

### 1\. 联合国. `IFlowPlugin` - 直接API模式

直接API呼叫iFlow.cn为标准模型.

| 财产 | 数值 |
| --- | --- |
| 提供者 | `iflow` |
| 基础URL | `https://apis.iflow.cn/v1` |
| 认证 | OAuth 2.0 / API 密钥 |

### 2\. 联合国. `IFlowProxyPlugin` - CLI 代理模式

GLM-5支持的路由请求通过iflow CLI. 代理服务器在 OpenCode 加载插件时自动启动.

| 财产 | 数值 |
| --- | --- |
| 提供者 | `iflow-proxy` |
| 代理端口 | `127.0.0.1:19998` |
| 认证 | 如果 cLI 登录 |

**如何运作:**

1.  如果模型需要CLI(glm-5,glm-5-无,glm-5-思考),插件会检测
2.  在端口启动本地代理服务器 19998
3.  通过 CLI 所需的模式 `iflow` 通过 stdin 的 CLI
4.  直接向 iFlow API 移动其它模式

## 安装

### 快速启动

将插件添加到您的 `opencode.json` 或者说 `opencode.jsonc`数字 :

```json
{
  "plugin": ["@asframe/opencode-iflow-auth"]
}
```

### 完整配置

```json
{
  "plugin": ["@asframe/opencode-iflow-auth"],
  "provider": {
    "iflow": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://apis.iflow.cn/v1"
      },
      "models": {
        "deepseek-v3.2": {
          "name": "DeepSeek V3.2",
          "limit": { "context": 128000, "output": 64000 },
          "modalities": { "input": ["text"], "output": ["text"] }
        },
        "glm-4.6": {
          "name": "GLM-4.6",
          "limit": { "context": 128000, "output": 64000 },
          "modalities": { "input": ["text"], "output": ["text"] }
        },
        "kimi-k2": {
          "name": "Kimi K2",
          "limit": { "context": 128000, "output": 64000 },
          "modalities": { "input": ["text"], "output": ["text"] }
        },
        "qwen3-coder-plus": {
          "name": "Qwen3 Coder Plus",
          "limit": { "context": 1000000, "output": 64000 },
          "modalities": { "input": ["text"], "output": ["text"] }
        }
      }
    },
    "iflow-proxy": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "http://127.0.0.1:19998/v1"
      },
      "models": {
        "glm-5": {
          "name": "GLM-5 (via CLI Proxy)",
          "limit": { "context": 256000, "output": 64000 },
          "modalities": { "input": ["text", "image"], "output": ["text"] }
        },
        "glm-5-free": {
          "name": "GLM-5 Free (via CLI Proxy)",
          "limit": { "context": 256000, "output": 64000 },
          "modalities": { "input": ["text"], "output": ["text"] }
        },
        "glm-5-thinking": {
          "name": "GLM-5 Thinking (via CLI Proxy)",
          "limit": { "context": 256000, "output": 64000 },
          "modalities": { "input": ["text"], "output": ["text"] }
        }
      }
    }
  }
}
```

## 设置

### 直接 API 模式

1.  运行 `opencode auth login`。 。 。 .
2.  选择 `Other`类型 `iflow`键入.
3.  选择认证方法 :
    -   **OAuth 2.0 数据**: 跟踪浏览器流量以获取基于安全符的认证.
    -   **API 密钥**: 输入您的 iFlow API 密钥( 以 `sk-`) (中文(简体) ).

### CLI 代理模式(用于 GLM-5)

1.  安装 iflow CLI : `npm install -g iflow-cli`
2.  登录到 iflow CLI : `iflow login`
3.  使用时代理服务器将自动启动 `iflow-proxy` 供养.

**自动安装 CLI :**

如果不安装下 CLI,插件可以自动为您安装. 通过设置环境变量启用此特性 :

```bash
# PowerShell
$env:IFLOW_AUTO_INSTALL_CLI = "true"

# Bash
export IFLOW_AUTO_INSTALL_CLI=true
```

**CLI 代理设备的要求 :**

-   节点.js 18+
-   如果安装和登录的CLI较低(或设置) `IFLOW_AUTO_INSTALL_CLI=true` 自动安装)
-   可使用端口 19998( 如果已运行, 将使用现有代理)

## 使用量

```bash
# Direct API mode
opencode run "你好" --model iflow/deepseek-v3.2
opencode run "你好" --model iflow/glm-4.6
opencode run "你好" --model iflow/kimi-k2

# CLI Proxy mode (GLM-5)
opencode run "你好" --model iflow-proxy/glm-5
opencode run "你好" --model iflow-proxy/glm-5-thinking
```

## 配置

编辑 `~/.config/opencode/iflow.json`数字 :

```json
{
  "default_auth_method": "oauth",
  "account_selection_strategy": "round-robin",
  "auth_server_port_start": 8087,
  "auth_server_port_range": 10,
  "max_request_iterations": 50,
  "request_timeout_ms": 300000,
  "enable_log_api_request": false
}
```

### 配置选项

| 选项 | 类型 | 默认 | 说明 |
| --- | --- | --- | --- |
| `default_auth_method` | 字符串 | `oauth` | 默认认证方法( E)`oauth`, (中文(简体) ), `apikey`(中文(简体) ) |
| `account_selection_strategy` | 字符串 | `sticky` | 账户轮换战略`sticky`, (中文(简体) ), `round-robin`(中文(简体) ) |
| `auth_server_port_start` | 编号 | `8087` | OAuth 回调服务器启动端口( 1024-65535) |
| `auth_server_port_range` | 编号 | `10` | 要尝试的端口数( 1100) |
| `max_request_iterations` | 编号 | `50` | 最大循环迭接来防止挂起 (10-1000) |
| `request_timeout_ms` | 编号 | `300000` | 请求超时以毫秒( 60 000- 600 000 毫秒) |
| `enable_log_api_request` | 布尔 | `false` | 启用 API 请求/ 回复记录 |

### 环境变量

| 变量 | 说明 |
| --- | --- |
| `IFLOW_AUTH_DEBUG` | 启用认证插件的调试记录( E)`true`编号 :`false`(中文(简体) ) |
| `IFLOW_PROXY_DEBUG` | 启用代理插件的调试日志( E)`true`编号 :`false`(中文(简体) ) |
| `IFLOW_AUTO_INSTALL_CLI` | 如果未安装, 则自动安装 CLI( 默认 : `true`设置 `false` 要禁用) |
| `IFLOW_AUTO_LOGIN` | 如果不登录则自动触发( 默认) : `true`设置 `false` 要禁用) |
| `IFLOW_DEFAULT_AUTH_METHOD` | 覆盖默认认证方法 |
| `IFLOW_ACCOUNT_SELECTION_STRATEGY` | 覆盖账户选择策略 |
| `IFLOW_AUTH_SERVER_PORT_START` | 覆盖 OAuth 服务器端口 |
| `IFLOW_AUTH_SERVER_PORT_RANGE` | 覆盖 OAuth 服务器端口范围 |
| `IFLOW_MAX_REQUEST_ITERATIONS` | 覆盖最大迭代 |
| `IFLOW_REQUEST_TIMEOUT_MS` | 覆盖请求超时 |
| `IFLOW_ENABLE_LOG_API_REQUEST` | 启用 API 记录 |

## 存储

**Linux/macOS : (原始内容存档于2018-09-29) (英语)**

-   全权证书: `~/.config/opencode/iflow-accounts.json`
-   插件配置 : `~/.config/opencode/iflow.json`

**窗口 :**

-   全权证书: `%APPDATA%\opencode\iflow-accounts.json`
-   插件配置 : `%APPDATA%\opencode\iflow.json`

## 思考模式

iFlow通过变体支持具有自定义思维预算的思维模型:

### GLM-4.6、GLM-5和DeepSeek R1

```json
{
  "variants": {
    "low": { "thinkingConfig": { "thinkingBudget": 1024 } },
    "medium": { "thinkingConfig": { "thinkingBudget": 8192 } },
    "max": { "thinkingConfig": { "thinkingBudget": 32768 } }
  }
}
```

## 解决问题

### CLI 代理问题

如果您遇到 CLI 代理服务器的问题 :

1.  **检查是否安装了 CLI :**
    
    ```bash
    iflow --version
    ```
    
2.  **检查是否登录:**
    
    ```bash
    iflow login
    ```
    
3.  **直接测试 iflow CLI :**
    
    ```bash
    echo "你好" | iflow -m glm-5
    ```
    
4.  **启用调试记录 :**
    
    ```bash
    $env:IFLOW_PROXY_DEBUG = "true"
    opencode run "你好" --model iflow-proxy/glm-5
    ```
    

### 已经在使用的端口

如果已使用端口19998,插件将检测并使用已存在的代理. 如果您需要重新启动代理服务器 :

```bash
# Kill existing process on port 19998
# Windows
Get-Process -Id (Get-NetTCPConnection -LocalPort 19998).OwningProcess | Stop-Process -Force

# Linux/macOS
lsof -i :19998 | grep LISTEN | awk '{print $2}' | xargs kill -9
```

### 认证问题

1.  **API 密钥不工作 :**
    
    -   确保您的 API 密钥以开头 `sk-`
    -   检查密钥是否有效 [iFlow.cn (英语)](https://iflow.cn/)
2.  **无法工作 :**
    
    -   清除浏览器 cookie
    -   尝试不同的浏览器
    -   检查是否有回调端口可用

## 财务问题

### 问:为什么我需要GLM-5的CLI代理?

GLM-5需要特殊认证,只能通过iflow CLI获得. CLI代理模式通过CLI路由请求来弥补这一缺口.

### 问:我能同时使用两种模式吗?

没错! 您可以同时配置 `iflow` 财务报告和审定财务报表 `iflow-proxy` 供货商并交替使用.

### 问题:这是正式的插件吗?

不,这是一个独立的执行,不附属于,不由iFlow.cn认可或支持.

### 问:我如何获得API密钥?

1.  访问 [iFlow.cn (英语)](https://iflow.cn/)
2.  创建账户或登录
3.  转到 API 设置
4.  生成新的 API 密钥

## 更改日志

### 页:1

-   添加GLM-4.7型号支持
-   改进了README文件,并进行了更明确的模型比较
-   添加的详细 GLM-5 型号家族描述
-   更新的模型计数( 16 API Key 模型, 19 CLI 代理模型)

### v1.0.0 (韩语)

-   初步释放
-   双认证 (OAuth 2. 0 / API 密钥)
-   GLM-5 的 CLI 代理模式
-   自动安装 CLI 特性
-   多账户轮换
-   思考模式支持

## 捐款

欢迎捐款! 请随意提交拉力请求.

1.  叉子存储器
2.  创建您的特性分支( E)`git checkout -b feature/amazing-feature`(中文(简体) )
3.  提交更改( E)`git commit -m 'Add some amazing feature'`(中文(简体) )
4.  推向分行(`git push origin feature/amazing-feature`(中文(简体) )
5.  打开拉请求

## 许可证

麻省理工学院执照 - 看 [自由主义](https://npmcn.com/package/%40asframe/opencode-iflow-auth/LICENSE) 详细情况.

## 免责声明

此插件严格用于学习和教育目的. 它是一个独立的实施,不附属于iFlow.cn,得到其认可或支持. 此插件的使用有你自己的风险 .

请随意打开一个 PR 来进一步优化这个插件 .

## 链接

-   [GitHub 仓库](https://github.com/asframe/opencode-iflow-auth)
-   [npm 软件包](https://www.npmjs.com/package/@asframe/opencode-iflow-auth)
-   [iFlow.cn (英语)](https://iflow.cn/)
-   [打开代码](https://opencode.ai/)

## 常见问题

### @asframe/opencode-iflow-auth 是什么？

IFlow\.cn 的 OpenCode 插件 - Access Quen, DeepSeek, Kimi, GLM-5 型号, 有 OAuth 2\. 0, API 键, 和 CPI 代理支持

### 如何安装 @asframe/opencode-iflow-auth？

在项目目录运行 npm install @asframe/opencode-iflow-auth，或使用 pnpm add / yarn add / bun add。

### @asframe/opencode-iflow-auth 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @asframe/opencode-iflow-auth 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @asframe/opencode-iflow-auth 可以商用吗？

@asframe/opencode-iflow-auth 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @asframe/opencode-iflow-auth 的下载量有多少？

根据 npm 官方下载统计，@asframe/opencode-iflow-auth 在 2026/10/07 – 2026/11/05 这 30 天内被下载 6,400 次，日均约 213 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @asframe/opencode-iflow-auth 还在维护吗？

最新版本 1\.0\.6 发布于 2026/02/22（8 个月前）；至今共发布 7 个版本，其中过去 12 个月发布了 7 个；首次发布于 2026/02/21。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

