fix(deploy): use gateway key in auth-profiles.json instead of raw Anthropic key

OpenClaw reads API key from auth-profiles.json. Was writing raw Anthropic key
sk-ant-api03-... which gateway doesn't recognize. Must use effectiveApiKey
(sk-gw-oc-... gateway key) so authentication with iConsulting LLM gateway succeeds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-08 21:59:39 -07:00
parent c10a54116d
commit de2d30fa6c
1 changed files with 4 additions and 2 deletions

View File

@ -216,11 +216,13 @@ export class AgentInstanceDeployService {
const sshCreds = { host: creds.host, port: creds.sshPort, username: creds.sshUser, privateKey: creds.sshKey }; const sshCreds = { host: creds.host, port: creds.sshPort, username: creds.sshUser, privateKey: creds.sshKey };
await this.sshExec(sshCreds, `mkdir -p /data/openclaw/${instance.id} && printf '%s' '${openclawConfig.replace(/'/g, "'\\''")}' > /data/openclaw/${instance.id}/openclaw.json`); await this.sshExec(sshCreds, `mkdir -p /data/openclaw/${instance.id} && printf '%s' '${openclawConfig.replace(/'/g, "'\\''")}' > /data/openclaw/${instance.id}/openclaw.json`);
// Write gateway API key for LLM proxy in auth-profiles.json // Write gateway API key for LLM proxy in auth-profiles.json.
// Must use effectiveApiKey (gateway key) so OpenClaw authenticates with the gateway,
// NOT the raw Anthropic key which the gateway does not recognize.
const authProfiles = JSON.stringify({ const authProfiles = JSON.stringify({
version: 1, version: 1,
profiles: { profiles: {
'anthropic-api-key': { type: 'api_key', provider: 'anthropic', key: claudeApiKey }, 'anthropic-api-key': { type: 'api_key', provider: 'anthropic', key: effectiveApiKey },
}, },
}); });
await this.sshExec(sshCreds, `mkdir -p /data/openclaw/${instance.id}/agents/main/agent && printf '%s' '${authProfiles.replace(/'/g, "'\\''")}' > /data/openclaw/${instance.id}/agents/main/agent/auth-profiles.json`); await this.sshExec(sshCreds, `mkdir -p /data/openclaw/${instance.id}/agents/main/agent && printf '%s' '${authProfiles.replace(/'/g, "'\\''")}' > /data/openclaw/${instance.id}/agents/main/agent/auth-profiles.json`);