環境変数を以下のように設定して claude
コマンドを実行する。
export AWS_REGION=ap-northeast-1
export AWS_PROFILE=default
export CLAUDE_CODE_USE_BEDROCK=1
export ANTHROPIC_MODEL='apac.anthropic.claude-3-7-sonnet-20250219-v1:0'
export ANTHROPIC_SMALL_FAST_MODEL='apac.anthropic.claude-3-haiku-20240307-v1:0'
ポイントとしてはモデル ID ではなく推論プロファイル ID を指定する点。
ap-northeast-1 の場合、モデル ID の先頭に apac.
を付け加えれば推論プロファイル ID になる模様。ちゃんと確認したい場合は aws bedrock list-inference-profiles
で確認できます。
モデル ID を指定した場合のエラー(検索用)
API Error (anthropic.claude-3-7-sonnet-20250219-v1:0): 400 Invocation of model ID anthropic.claude-3-7-sonnet-20250219-v1:0 with on-demand throughput isn’t supported. Retry your request with the ID or ARN of an inference profile that contains this model.
API Error (anthropic.claude-sonnet-4-20250514-v1:0): 400 Invocation of model ID anthropic.claude-sonnet-4-20250514-v1:0 with on-demand throughput isn’t supported. Retry your request with the ID or ARN of an inference profile that contains this model.
参考