From 46b866f328b258dc31f8c29222bb84784f6e0c12 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Mar 2026 18:29:15 +0000 Subject: [PATCH] Support ANTHROPIC_AUTH_TOKEN for third-party API providers Add anthropic_auth_token input to both action.yml and base-action/action.yml, pass it as ANTHROPIC_AUTH_TOKEN env var to Claude Code, and update validation to accept it as an alternative to ANTHROPIC_API_KEY/CLAUDE_CODE_OAUTH_TOKEN. This enables use with proxy servers like LiteLLM. https://claude.ai/code/session_01Q7hAv9Ah5eeZjXPEqmhYoW --- action.yml | 4 ++++ base-action/action.yml | 5 +++++ base-action/src/validate-env.ts | 5 +++-- base-action/test/validate-env.test.ts | 11 +++++++++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index aecd94eee..1853a6422 100644 --- a/action.yml +++ b/action.yml @@ -61,6 +61,9 @@ inputs: claude_code_oauth_token: description: "Claude Code OAuth token (alternative to anthropic_api_key)" required: false + anthropic_auth_token: + description: "Anthropic auth token for third-party API providers like LiteLLM proxy (alternative to anthropic_api_key)" + required: false github_token: description: "GitHub token with repo and pull request permissions (optional if using GitHub App)" required: false @@ -233,6 +236,7 @@ runs: # Provider configuration ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }} CLAUDE_CODE_OAUTH_TOKEN: ${{ inputs.claude_code_oauth_token }} + ANTHROPIC_AUTH_TOKEN: ${{ inputs.anthropic_auth_token }} ANTHROPIC_BASE_URL: ${{ env.ANTHROPIC_BASE_URL }} ANTHROPIC_CUSTOM_HEADERS: ${{ env.ANTHROPIC_CUSTOM_HEADERS }} CLAUDE_CODE_USE_BEDROCK: ${{ inputs.use_bedrock == 'true' && '1' || '' }} diff --git a/base-action/action.yml b/base-action/action.yml index 50f3d5f23..723d8aabf 100644 --- a/base-action/action.yml +++ b/base-action/action.yml @@ -34,6 +34,10 @@ inputs: description: "Claude Code OAuth token (alternative to anthropic_api_key)" required: false default: "" + anthropic_auth_token: + description: "Anthropic auth token for third-party API providers like LiteLLM proxy (alternative to anthropic_api_key)" + required: false + default: "" use_bedrock: description: "Use Amazon Bedrock with OIDC authentication instead of direct Anthropic API" required: false @@ -175,6 +179,7 @@ runs: # Provider configuration ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }} CLAUDE_CODE_OAUTH_TOKEN: ${{ inputs.claude_code_oauth_token }} + ANTHROPIC_AUTH_TOKEN: ${{ inputs.anthropic_auth_token }} ANTHROPIC_BASE_URL: ${{ env.ANTHROPIC_BASE_URL }} ANTHROPIC_CUSTOM_HEADERS: ${{ env.ANTHROPIC_CUSTOM_HEADERS }} # Only set provider flags if explicitly true, since any value (including "false") is truthy diff --git a/base-action/src/validate-env.ts b/base-action/src/validate-env.ts index 1f28da37e..26fdc1623 100644 --- a/base-action/src/validate-env.ts +++ b/base-action/src/validate-env.ts @@ -8,6 +8,7 @@ export function validateEnvironmentVariables() { const useFoundry = process.env.CLAUDE_CODE_USE_FOUNDRY === "1"; const anthropicApiKey = process.env.ANTHROPIC_API_KEY; const claudeCodeOAuthToken = process.env.CLAUDE_CODE_OAUTH_TOKEN; + const anthropicAuthToken = process.env.ANTHROPIC_AUTH_TOKEN; const errors: string[] = []; @@ -20,9 +21,9 @@ export function validateEnvironmentVariables() { } if (!useBedrock && !useVertex && !useFoundry) { - if (!anthropicApiKey && !claudeCodeOAuthToken) { + if (!anthropicApiKey && !claudeCodeOAuthToken && !anthropicAuthToken) { errors.push( - "Either ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN is required when using direct Anthropic API.", + "Either ANTHROPIC_API_KEY, CLAUDE_CODE_OAUTH_TOKEN, or ANTHROPIC_AUTH_TOKEN is required when using direct Anthropic API.", ); } } else if (useBedrock) { diff --git a/base-action/test/validate-env.test.ts b/base-action/test/validate-env.test.ts index 4a4b09334..e578a68d0 100644 --- a/base-action/test/validate-env.test.ts +++ b/base-action/test/validate-env.test.ts @@ -26,6 +26,7 @@ describe("validateEnvironmentVariables", () => { delete process.env.ANTHROPIC_VERTEX_BASE_URL; delete process.env.ANTHROPIC_FOUNDRY_RESOURCE; delete process.env.ANTHROPIC_FOUNDRY_BASE_URL; + delete process.env.ANTHROPIC_AUTH_TOKEN; }); afterEach(() => { @@ -40,9 +41,15 @@ describe("validateEnvironmentVariables", () => { expect(() => validateEnvironmentVariables()).not.toThrow(); }); - test("should fail when ANTHROPIC_API_KEY is missing", () => { + test("should pass when ANTHROPIC_AUTH_TOKEN is provided", () => { + process.env.ANTHROPIC_AUTH_TOKEN = "test-auth-token"; + + expect(() => validateEnvironmentVariables()).not.toThrow(); + }); + + test("should fail when no auth token is provided", () => { expect(() => validateEnvironmentVariables()).toThrow( - "Either ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN is required when using direct Anthropic API.", + "Either ANTHROPIC_API_KEY, CLAUDE_CODE_OAUTH_TOKEN, or ANTHROPIC_AUTH_TOKEN is required when using direct Anthropic API.", ); }); });