OpenCode plugin for iFlow providing access to Claude, GPT, Gemini, DeepSeek, and Qwen models
npm install @zhafron/opencode-iflow-authOpenCode plugin for iFlow.cn providing access to Qwen, DeepSeek, Kimi, GLM, and iFlow ROME models with dual authentication support.
- Dual authentication: OAuth 2.0 (PKCE) and API Key support.
- Multi-account rotation with sticky and round-robin strategies.
- Automated token refresh and rate limit handling with exponential backoff.
- Native thinking mode support for GLM-4.x models.
- Configurable request timeout and iteration limits to prevent hangs.
- Automatic port selection for OAuth callback server to avoid conflicts.
Add the plugin to your opencode.json or opencode.jsonc:
``json`
{
"plugin": ["@zhafron/opencode-iflow-auth"],
"provider": {
"iflow": {
"models": {
"iflow-rome-30ba3b": {
"name": "iFlow ROME 30B",
"limit": { "context": 256000, "output": 64000 },
"modalities": { "input": ["text"], "output": ["text"] }
},
"qwen3-coder-plus": {
"name": "Qwen3 Coder Plus",
"limit": { "context": 1000000, "output": 64000 },
"modalities": { "input": ["text"], "output": ["text"] }
},
"qwen3-max": {
"name": "Qwen3 Max",
"limit": { "context": 256000, "output": 32000 },
"modalities": { "input": ["text"], "output": ["text"] }
},
"qwen3-vl-plus": {
"name": "Qwen3 VL Plus",
"limit": { "context": 256000, "output": 32000 },
"modalities": { "input": ["text", "image"], "output": ["text"] }
},
"qwen3-235b-a22b-thinking-2507": {
"name": "Qwen3 235B Thinking",
"limit": { "context": 256000, "output": 64000 },
"modalities": { "input": ["text"], "output": ["text"] }
},
"kimi-k2": {
"name": "Kimi K2",
"limit": { "context": 128000, "output": 64000 },
"modalities": { "input": ["text"], "output": ["text"] }
},
"kimi-k2-0905": {
"name": "Kimi K2 0905",
"limit": { "context": 256000, "output": 64000 },
"modalities": { "input": ["text"], "output": ["text"] }
},
"glm-4.6": {
"name": "GLM-4.6 Thinking",
"limit": { "context": 200000, "output": 128000 },
"modalities": { "input": ["text", "image"], "output": ["text"] },
"variants": {
"low": { "thinkingConfig": { "thinkingBudget": 1024 } },
"medium": { "thinkingConfig": { "thinkingBudget": 8192 } },
"max": { "thinkingConfig": { "thinkingBudget": 32768 } }
}
},
"deepseek-v3": {
"name": "DeepSeek V3",
"limit": { "context": 128000, "output": 32000 },
"modalities": { "input": ["text"], "output": ["text"] }
},
"deepseek-v3.2": {
"name": "DeepSeek V3.2",
"limit": { "context": 128000, "output": 64000 },
"modalities": { "input": ["text"], "output": ["text"] }
},
"deepseek-r1": {
"name": "DeepSeek R1",
"limit": { "context": 128000, "output": 32000 },
"modalities": { "input": ["text"], "output": ["text"] },
"variants": {
"low": { "thinkingConfig": { "thinkingBudget": 1024 } },
"medium": { "thinkingConfig": { "thinkingBudget": 8192 } },
"max": { "thinkingConfig": { "thinkingBudget": 32768 } }
}
},
"qwen3-32b": {
"name": "Qwen3 32B",
"limit": { "context": 128000, "output": 32000 },
"modalities": { "input": ["text"], "output": ["text"] }
}
}
}
}
}
1. Run opencode auth login.Other
2. Select , type iflow, and press enter.sk-
3. Choose authentication method:
- OAuth 2.0: Follow browser flow for secure token-based authentication.
- API Key: Enter your iFlow API key (starts with ).~/.config/opencode/iflow.json
4. Configuration template will be automatically created at on first load.
The plugin supports extensive configuration options. Edit ~/.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: Default authentication method (oauth, apikey)account_selection_strategy
- : Account rotation strategy (sticky, round-robin)auth_server_port_start
- : Starting port for OAuth callback server (1024-65535)auth_server_port_range
- : Number of ports to try (1-100)max_request_iterations
- : Maximum loop iterations to prevent hangs (10-1000)request_timeout_ms
- : Request timeout in milliseconds (60000-600000ms)enable_log_api_request
- : Enable API request/response logging (errors always logged)
All configuration options can be overridden via environment variables:
- IFLOW_DEFAULT_AUTH_METHODIFLOW_ACCOUNT_SELECTION_STRATEGY
- IFLOW_AUTH_SERVER_PORT_START
- IFLOW_AUTH_SERVER_PORT_RANGE
- IFLOW_MAX_REQUEST_ITERATIONS
- IFLOW_REQUEST_TIMEOUT_MS
- IFLOW_ENABLE_LOG_API_REQUEST
-
Linux/macOS:
- Credentials: ~/.config/opencode/iflow-accounts.json~/.config/opencode/iflow.json
- Plugin Config:
Windows:
- Credentials: %APPDATA%\opencode\iflow-accounts.json%APPDATA%\opencode\iflow.json
- Plugin Config:
iFlow supports thinking models with customizable thinking budgets via variants:
Automatically enables thinking mode with configurable budget:
`json`
{
"variants": {
"low": { "thinkingConfig": { "thinkingBudget": 1024 } },
"medium": { "thinkingConfig": { "thinkingBudget": 8192 } },
"max": { "thinkingConfig": { "thinkingBudget": 32768 } }
}
}
The plugin automatically transforms requests to:
`typescript`
{
"chat_template_kwargs": {
"enable_thinking": true,
"clear_thinking": false
},
"thinking_budget": 8192 // from variant config
}
Supports thinking budget control via variants:
`json`
{
"variants": {
"low": { "thinkingConfig": { "thinkingBudget": 1024 } },
"medium": { "thinkingConfig": { "thinkingBudget": 8192 } },
"max": { "thinkingConfig": { "thinkingBudget": 32768 } }
}
}
The plugin automatically adds thinking_budget parameter to requests.
Both models return reasoning content in the response:
`json``
{
"choices": [{
"message": {
"role": "assistant",
"content": "The answer is 4.",
"reasoning_content": "Let me think step by step..."
}
}],
"usage": {
"completion_tokens_details": {
"reasoning_tokens": 1094
}
}
}
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.