claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[FEATURE] Make Claude model ID fully configurable (including AWS China regions and custom models)

Open EivMeyer opened this issue 1 month ago • 2 comments

Feature Request

Problem

Claude Code currently hardcodes the model selection logic, which prevents users from:

  1. Using AWS China region models - China regions (cn-northwest-1, cn-north-1) have separate model IDs that follow different naming conventions
  2. Using custom fine-tuned models - Organizations with custom models cannot use them with Claude Code
  3. Optimizing costs - Users cannot easily switch between model tiers for different workloads
  4. Testing new models - When new models are released, users must wait for CLI updates

Related Issues

  • #2656 - AWS China regions fail with "unsupported country/region" error
  • #11549 - Scenario-based model selection
  • #4937 - Model selection for custom commands

Proposed Solution

Add a configuration option to fully override the model ID used by Claude Code:

# Environment variable
export CLAUDE_CODE_MODEL_ID="anthropic.claude-sonnet-4-v1:0"  # AWS China
export CLAUDE_CODE_MODEL_ID="arn:aws:bedrock:us-east-1:123456789012:custom-model/my-model"  # Custom model
export CLAUDE_CODE_MODEL_ID="claude-opus-4-20250514"  # Future model

# OR via settings.json
{
  "modelId": "anthropic.claude-sonnet-4-v1:0"
}

This would allow:

  • AWS China support - Use China-specific model IDs (e.g., anthropic.claude-sonnet-4-v1:0 in cn-northwest-1)
  • Custom models - Point to fine-tuned models via ARN or custom identifiers
  • Future-proofing - Use new models immediately without waiting for CLI updates
  • Cost optimization - Easily switch between Haiku/Sonnet/Opus based on task complexity

AWS China Model ID Examples

AWS China regions use different model ID formats:

Standard Region China Region
anthropic.claude-sonnet-4-20250514-v1:0 anthropic.claude-sonnet-4-v1:0
anthropic.claude-opus-4-20250514-v1:0 anthropic.claude-opus-4-v1:0
anthropic.claude-haiku-3-5-20241022-v1:0 anthropic.claude-haiku-3-5-v1:0

These models are available in:

  • cn-northwest-1 (Ningxia)
  • cn-north-1 (Beijing)

Implementation Notes

Current behavior:

  • Claude Code maps internal model names (sonnet, opus, haiku) to specific model IDs
  • This mapping is hardcoded in the CLI source

Proposed behavior:

  1. Check if CLAUDE_CODE_MODEL_ID or settings.modelId is set
  2. If set, use that exact model ID (no validation, pass-through)
  3. If not set, fallback to current hardcoded mapping

Why pass-through?

  • Model IDs vary by platform (Bedrock, Vertex AI, Anthropic API)
  • Model IDs vary by region (especially China vs standard regions)
  • Custom models have unpredictable identifiers
  • New models are released frequently

Alternative: Model Mapping File

If pass-through is too risky, allow users to define custom mappings:

// ~/.claude/model-mappings.json
{
  "sonnet": "anthropic.claude-sonnet-4-v1:0",
  "opus": "anthropic.claude-opus-4-v1:0",
  "haiku": "anthropic.claude-haiku-3-5-v1:0"
}

This preserves the internal model selection logic while allowing regional/custom variations.

Benefits

  1. Unblocks AWS China users - Immediate workaround for #2656
  2. Enables enterprise use cases - Custom fine-tuned models
  3. Reduces maintenance burden - No need to hardcode every regional variant
  4. Future-proof - Works with models that don't exist yet

Priority

HIGH - This is blocking:

  • Users in China regions (large market)
  • Enterprise customers with custom models
  • Early adopters wanting to test new models

Workaround (Current)

None - users in China regions or with custom models cannot use Claude Code at all.


Is this something you'd accept a PR for? I'm happy to implement this if the approach sounds reasonable.

EivMeyer avatar Dec 03 '25 12:12 EivMeyer