anthropics / anthropics/claude-code-action

feat: Add native base_url and custom_headers inputs for LLM Gateway integration

Aperta
#840 1 commento 3 reazioni 0 assegnatari Vedi su GitHub
dev-experience enhancement feature-request p2
Lingua principale
TypeScript
Stelle
8.9k
Fork
2.1k
Merge medio
3g 9h
PR unite (30g)
10

Descrizione

## Problem

Users integrating Claude Code Action with LLM Gateways, API proxies, or API management solutions currently need to use `env:` blocks to set `ANTHROPIC_BASE_URL` and `ANTHROPIC_CUSTOM_HEADERS`. This is:

- **Not discoverable** - inputs don't appear in action.yml or IDE autocomplete
- **Requires custom scripting** - users must understand env var passthrough
- **Confusing format** - users don't know headers need JSON format (see #704)

### Related Discussions (Users Currently Blocked)

- **#704** - "AWS Bedrock via portkey" - User stuck with incorrect header format
- **#575** - "How to use portkey in claude code gh action?" - No solution provided
- **#272** - "Connect claude-code-action with the LLM Gateway" - Workaround via env blocks
- **#551** - "What to configure my own base url" - Same pattern

## Proposed Solution

Add native inputs that mirror the existing pattern for `anthropic_api_key`:

```yaml
- uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
base_url: "https://your-gateway.example.com"
custom_headers: '{"x-portkey-api-key": "${{ secrets.PORTKEY_KEY }}"}'
```

### New Inputs

| Input | Description | Default |
|-------|-------------|---------|
| `base_url` | Custom API endpoint URL for LLM Gateway/proxy | `""` |
| `custom_headers` | Custom HTTP headers as JSON string | `""` |

### Backwards Compatibility

Inputs take precedence but fall back to env vars:
```yaml
ANTHROPIC_BASE_URL: ${{ inputs.base_url || env.ANTHROPIC_BASE_URL }}
ANTHROPIC_CUSTOM_HEADERS: ${{ inputs.custom_headers || env.ANTHROPIC_CUSTOM_HEADERS }}
```

## Use Cases

1. **LLM Gateways** - Route through enterprise gateways per [Anthropic docs](https://docs.anthropic.com/en/docs/claude-code/llm-gateway)
2. **Portkey/LiteLLM** - Observability and fallback routing
3. **API Management** - Azure APIM, AWS API Gateway, Kong policies
4. **Custom Auth** - Subscription keys, bearer tokens, correlation IDs

## Implementation

Simple YAML changes to both `action.yml` files + documentation updates. No TypeScript changes needed - the SDK already reads these env vars.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.