From de2d30fa6ccc2fb86359047585c545ca5a7bd9c2 Mon Sep 17 00:00:00 2001 From: hailin Date: Sun, 8 Mar 2026 21:59:39 -0700 Subject: [PATCH] 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 --- .../services/agent-instance-deploy.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/services/agent-service/src/infrastructure/services/agent-instance-deploy.service.ts b/packages/services/agent-service/src/infrastructure/services/agent-instance-deploy.service.ts index 13a6252..58d4bf9 100644 --- a/packages/services/agent-service/src/infrastructure/services/agent-instance-deploy.service.ts +++ b/packages/services/agent-service/src/infrastructure/services/agent-instance-deploy.service.ts @@ -216,11 +216,13 @@ export class AgentInstanceDeployService { 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`); - // 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({ version: 1, 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`);