@asframe/opencode-iflow-auth

中文文档
1.0.6发布于 2026/02/22MITTypeScriptES Module近 30 天下载 6400

OpenCode plugin for iFlow.cn - Access Qwen, DeepSeek, Kimi, GLM-5 models with OAuth 2.0, API Key, and CLI Proxy support

原始使用文档
文档目录36 节
  1. Features
  2. Supported Models
  3. API Key Mode ( iflow provider)
  4. CLI Proxy Mode ( iflow-proxy provider)
  5. Two Plugin Modes
  6. 1. IFlowPlugin - Direct API Mode
  7. 2. IFlowProxyPlugin - CLI Proxy Mode
  8. Installation
  9. Quick Start
  10. Full Configuration
  11. Setup
  12. Direct API Mode
  13. CLI Proxy Mode (for GLM-5)
  14. Usage
  15. Configuration
  16. Configuration Options
  17. Environment Variables
  18. Storage
  19. Thinking Models
  20. GLM-4.6, GLM-5 & DeepSeek R1
  21. Troubleshooting
  22. CLI Proxy Issues
  23. Port Already in Use
  24. Authentication Issues
  25. FAQ
  26. Q: Why do I need CLI Proxy for GLM-5?
  27. Q: Can I use both modes at the same time?
  28. Q: Is this plugin official?
  29. Q: How do I get an API key?
  30. Changelog
  31. v1.0.1
  32. v1.0.0
  33. Contributing
  34. License
  35. Disclaimer
  36. Links

OpenCode iFlow Auth Plugin

npm version npm downloads license GitHub

OpenCode plugin for iFlow.cn providing access to Qwen, DeepSeek, Kimi, GLM, and iFlow ROME models with dual authentication and CLI Proxy support.

Features

  • Dual authentication: OAuth 2.0 (PKCE) and API Key support.
  • CLI Proxy mode: Support GLM-5 through iflow CLI with automatic proxy server.
  • Multi-account rotation: Sticky and round-robin strategies.
  • Automated token refresh: Rate limit handling with exponential backoff.
  • Native thinking mode: Support for GLM-4.x, GLM-5 and DeepSeek R1 models.
  • Configurable timeout: Request timeout and iteration limits to prevent hangs.
  • Automatic port selection: OAuth callback server port conflict avoidance.
  • Auto-install CLI: Automatically install iflow CLI if not found.

Supported Models

API Key Mode (iflow provider)

Models available via OAuth 2.0 or API Key authentication:

ModelContextOutputDescription
deepseek-v3128K32KDeepSeek V3
deepseek-v3.2128K64KDeepSeek V3.2
deepseek-r1128K32KDeepSeek R1 (Thinking)
glm-4.6200K128KGLM-4.6 (Reasoning, Vision)
glm-4.7256K64KGLM-4.7 (Latest, Reasoning, Vision)
qwen3-max256K32KQwen3 Max
qwen3-max-preview256K32KQwen3 Max Preview
qwen3-coder-plus1M64KQwen3 Coder Plus
qwen3-vl-plus256K32KQwen3 VL Plus (Vision)
qwen3-32b128K32KQwen3 32B
qwen3-235b256K64KQwen3 235B
qwen3-235b-a22b-thinking-2507256K64KQwen3 235B Thinking
qwen3-235b-a22b-instruct256K64KQwen3 235B Instruct
kimi-k2128K64KKimi K2
kimi-k2-0905256K64KKimi K2 0905
iflow-rome-30ba3b256K64KiFlow ROME 30B

CLI Proxy Mode (iflow-proxy provider)

All models from API Key Mode PLUS these exclusive models:

ModelContextOutputDescription
glm-5256K64KGLM-5 - Flagship model (744B params, 40B active), best for reasoning & coding
glm-5-free256K64KGLM-5 Free - Same capabilities as glm-5, free for limited time
glm-5-thinking256K64KGLM-5 Thinking - Enhanced "System 2" deep reasoning capabilities

GLM-5 Model Family:

ModelDescription
glm-5Latest flagship model from Zhipu AI. 744B parameters (40B active), 28.5T tokens. Best-in-class for reasoning, coding, and agentic tasks.
glm-5-freeFree access to GLM-5 during promotional period. Same capabilities, no cost.
glm-5-thinkingEnhanced deep reasoning mode. Excels at complex architectural problems and "System 2" thinking.

Summary:

  • API Key Mode: 16 models
  • CLI Proxy Mode: 19 models (16 + 3 exclusive)

Note: CLI Proxy mode can also be used if you prefer CLI authentication over API Key for any model.

Two Plugin Modes

This package exports two plugins:

1. IFlowPlugin - Direct API Mode

Direct API calls to iFlow.cn for standard models.

PropertyValue
Provideriflow
baseURLhttps://apis.iflow.cn/v1
AuthOAuth 2.0 / API Key

2. IFlowProxyPlugin - CLI Proxy Mode

Routes requests through iflow CLI for GLM-5 support. The proxy server starts automatically when OpenCode loads the plugin.

PropertyValue
Provideriflow-proxy
Proxy Port127.0.0.1:19998
Authiflow CLI login

How it works:

  1. Plugin detects if model requires CLI (glm-5, glm-5-free, glm-5-thinking)
  2. Starts a local proxy server on port 19998
  3. Routes CLI-required models through iflow CLI via stdin
  4. Routes other models directly to iFlow API

Installation

Quick Start

Add the plugin to your opencode.json or opencode.jsonc:

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

Full Configuration

{
  "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"] }
        }
      }
    }
  }
}

Setup

Direct API Mode

  1. Run opencode auth login.
  2. Select Other, type iflow, and press enter.
  3. Choose authentication method:
    • OAuth 2.0: Follow browser flow for secure token-based authentication.
    • API Key: Enter your iFlow API key (starts with sk-).

CLI Proxy Mode (for GLM-5)

  1. Install iflow CLI: npm install -g iflow-cli
  2. Login to iflow CLI: iflow login
  3. The proxy server will start automatically when using iflow-proxy provider.

Auto-install CLI:

If iflow CLI is not installed, the plugin can automatically install it for you. Enable this feature by setting the environment variable:

# PowerShell
$env:IFLOW_AUTO_INSTALL_CLI = "true"

# Bash
export IFLOW_AUTO_INSTALL_CLI=true

Requirements for CLI Proxy:

  • Node.js 18+
  • iflow CLI installed and logged in (or set IFLOW_AUTO_INSTALL_CLI=true to auto-install)
  • Port 19998 available (or will use existing proxy if already running)

Usage

# 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

Configuration

Edit ~/.config/opencode/iflow.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
}

Configuration Options

OptionTypeDefaultDescription
default_auth_methodstringoauthDefault authentication method (oauth, apikey)
account_selection_strategystringstickyAccount rotation strategy (sticky, round-robin)
auth_server_port_startnumber8087Starting port for OAuth callback server (1024-65535)
auth_server_port_rangenumber10Number of ports to try (1-100)
max_request_iterationsnumber50Maximum loop iterations to prevent hangs (10-1000)
request_timeout_msnumber300000Request timeout in milliseconds (60000-600000ms)
enable_log_api_requestbooleanfalseEnable API request/response logging

Environment Variables

VariableDescription
IFLOW_AUTH_DEBUGEnable debug logging for auth plugin (true/false)
IFLOW_PROXY_DEBUGEnable debug logging for proxy plugin (true/false)
IFLOW_AUTO_INSTALL_CLIAuto-install iflow CLI if not installed (default: true, set false to disable)
IFLOW_AUTO_LOGINAuto-trigger iflow login if not logged in (default: true, set false to disable)
IFLOW_DEFAULT_AUTH_METHODOverride default auth method
IFLOW_ACCOUNT_SELECTION_STRATEGYOverride account selection strategy
IFLOW_AUTH_SERVER_PORT_STARTOverride OAuth server port
IFLOW_AUTH_SERVER_PORT_RANGEOverride OAuth server port range
IFLOW_MAX_REQUEST_ITERATIONSOverride max iterations
IFLOW_REQUEST_TIMEOUT_MSOverride request timeout
IFLOW_ENABLE_LOG_API_REQUESTEnable API logging

Storage

Linux/macOS:

  • Credentials: ~/.config/opencode/iflow-accounts.json
  • Plugin Config: ~/.config/opencode/iflow.json

Windows:

  • Credentials: %APPDATA%\opencode\iflow-accounts.json
  • Plugin Config: %APPDATA%\opencode\iflow.json

Thinking Models

iFlow supports thinking models with customizable thinking budgets via variants:

GLM-4.6, GLM-5 & DeepSeek R1

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

Troubleshooting

CLI Proxy Issues

If you encounter issues with the CLI proxy:

  1. Check if iflow CLI is installed:

    iflow --version
    
  2. Check if you're logged in:

    iflow login
    
  3. Test iflow CLI directly:

    echo "你好" | iflow -m glm-5
    
  4. Enable debug logging:

    $env:IFLOW_PROXY_DEBUG = "true"
    opencode run "你好" --model iflow-proxy/glm-5
    

Port Already in Use

If port 19998 is already in use, the plugin will detect it and use the existing proxy. If you need to restart the proxy:

# 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

Authentication Issues

  1. API Key not working:

    • Ensure your API key starts with sk-
    • Check if the key is valid at iFlow.cn
  2. OAuth not working:

    • Clear browser cookies
    • Try a different browser
    • Check if the callback port is available

FAQ

Q: Why do I need CLI Proxy for GLM-5?

GLM-5 requires special authentication that is only available through the iflow CLI. The CLI Proxy mode bridges this gap by routing requests through the CLI.

Q: Can I use both modes at the same time?

Yes! You can configure both iflow and iflow-proxy providers and use them interchangeably.

Q: Is this plugin official?

No, this is an independent implementation and is not affiliated with, endorsed by, or supported by iFlow.cn.

Q: How do I get an API key?

  1. Visit iFlow.cn
  2. Create an account or login
  3. Go to API settings
  4. Generate a new API key

Changelog

v1.0.1

  • Added GLM-4.7 model support
  • Improved README documentation with clearer model comparison
  • Added detailed GLM-5 model family description
  • Updated model counts (16 API Key models, 19 CLI Proxy models)

v1.0.0

  • Initial release
  • Dual authentication (OAuth 2.0 / API Key)
  • CLI Proxy mode for GLM-5
  • Auto-install CLI feature
  • Multi-account rotation
  • Thinking model support

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License - see LICENSE for details.

Disclaimer

This plugin is provided strictly for learning and educational purposes. It is an independent implementation and is not affiliated with, endorsed by, or supported by iFlow.cn. Use of this plugin is at your own risk.

Feel free to open a PR to optimize this plugin further.

版本与发布记录

@asframe/opencode-iflow-auth 共发布 7 个版本,首次发布于 2026/02/21;过去 12 个月发布了 7 个版本。

版本发布日期距今
1.0.6latest2026/02/228 个月前
1.0.52026/02/228 个月前
1.0.42026/02/228 个月前
1.0.32026/02/218 个月前
1.0.22026/02/218 个月前
1.0.12026/02/218 个月前

关于 @asframe/opencode-iflow-auth 的常见问题

@asframe/opencode-iflow-auth 是什么?

OpenCode plugin for iFlow.cn - Access Qwen, DeepSeek, Kimi, GLM-5 models with OAuth 2.0, API Key, and CLI Proxy support

如何安装 @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 和提交记录判断。