anthropics / anthropics/claude-code-action
feat: Add native base_url and custom_headers inputs for LLM Gateway integration
- Dominant language
- TypeScript
- Stars
- 8.9k
- Forks
- 2.1k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
## 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.
Contributor guide
Assessment
This issue has not been assessed yet.