Bug Description
When configuring the Bailian (阿里云百炼) provider with environment variable reference "apiKey": "__env__:BAILIAN_API_KEY", the agent fails with HTTP 401: invalid access token or token expired error, even though:
- The API key is valid and working when tested directly
- The environment variable is correctly loaded by the systemd service
- Other providers (minimax, nvidia, deepseek) work fine with the same pattern
Steps to Reproduce
-
Configure ~/.config/openclaw/credentials.env with:
BAILIAN_API_KEY=sk-sp-xxxxxxxxxxxxx
-
Configure ~/.openclaw/openclaw.json with:
{
"models": {
"providers": {
"bailian": {
"baseUrl": "https://coding.dashscope.aliyuncs.com/v1",
"apiKey": "__env__:BAILIAN_API_KEY",
"api": "openai-completions"
}
}
}
}
-
Restart the Gateway and send a message using bailian/qwen3.5-plus model
-
Check logs: HTTP 401: invalid access token or token expired
Root Cause
The envMap in the OpenClaw codebase does not include a mapping for the bailian provider. When resolveEnvApiKey("bailian") is called, it returns null because bailian is not in the mapping table.
Proposed Fix
Add bailian to the envMap in /src/agents/model-auth.ts:
const envMap = {
// ... existing mappings
bailian: "BAILIAN_API_KEY",
}
Environment
- OpenClaw Version: 2026.3.8
- Node.js: v22.22.0
- OS: Linux 6.1.0-22-amd64 (x64)
- Provider: Bailian (阿里云百炼)
Additional Context
- Other providers (minimax, nvidia, deepseek) work correctly with the same
__env__: pattern
- Direct API calls to Bailian work fine with the same API key
- This is a simple mapping omission that can be fixed by adding one line to envMap
Bug Description
When configuring the Bailian (阿里云百炼) provider with environment variable reference
"apiKey": "__env__:BAILIAN_API_KEY", the agent fails withHTTP 401: invalid access token or token expirederror, even though:Steps to Reproduce
Configure
~/.config/openclaw/credentials.envwith:Configure
~/.openclaw/openclaw.jsonwith:{ "models": { "providers": { "bailian": { "baseUrl": "https://coding.dashscope.aliyuncs.com/v1", "apiKey": "__env__:BAILIAN_API_KEY", "api": "openai-completions" } } } }Restart the Gateway and send a message using bailian/qwen3.5-plus model
Check logs:
HTTP 401: invalid access token or token expiredRoot Cause
The
envMapin the OpenClaw codebase does not include a mapping for thebailianprovider. WhenresolveEnvApiKey("bailian")is called, it returnsnullbecausebailianis not in the mapping table.Proposed Fix
Add
bailianto theenvMapin/src/agents/model-auth.ts:Environment
Additional Context
__env__:pattern