うごく生ゴミプログラマの備忘録

うごく生ゴミ 〜再臨〜

VS Code + GitHub Copilotに追加プラグイン無しでAmazon Bedrockのモデルを設定する

VS Code, GitHub Copilotに追加プラグイン無しでAmazon Bedrockのモデルを設定する方法がわかったので、備忘録かいておくます。

ただ、今のところAmazon Bedrock上のAnthropic製のモデルを動かすということができなかった。

AWS側の設定

AWSのマネジメントコンソールから、IAM → IAM users → Security credentialsタブ に移動し、Amazon Bedrock用APIキーを作成する。

AWSスクリーンショット

VS Code側の設定

VS Codeを起動し、GitHub Copilotのモデル管理画面に遷移する。

VS Codeスクリーンショット2
GitHub Copiotの

モデルを追加... をクリックする。

Custom Entpoint をクリックする。

Amazon Bedrockなど、分かりやすい名前を入力する。

VS Codeスクリーンショット4

AWS側でAPIキーを入力する。

以下のような画面がでるので、使いたいモデルの設定をする。

VS Codeスクリーンショット5

今回は、DeepSeekとgpt-oss-20bとgpt-oss-120bの3つを使いたかったので、以下のような設定値にしてみました。リージョンは us-west-2 オレゴンを使っているので "url": "https://bedrock-mantle.us-west-2.api.aws/v1" としています。

   {
        "name": "Amazon Bedrock",
        "vendor": "customendpoint",
        "apiKey": "${input:chat.lm.secret.xxxxxxxxxxxxxx}",
        "apiType": "chat-completions",
        "models": [
            {
                "id": "openai.gpt-oss-20b",
                "name": "gpt-oss-20B",
                "url": "https://bedrock-mantle.us-west-2.api.aws/v1",
                "toolCalling": true,
                "vision": true,
                "maxInputTokens": 128000,
                "maxOutputTokens": 16000
            },
            {
                "id": "openai.gpt-oss-120b",
                "name": "gpt-oss-120B",
                "url": "https://bedrock-mantle.us-west-2.api.aws/v1",
                "toolCalling": true,
                "vision": true,
                "maxInputTokens": 128000,
                "maxOutputTokens": 16000
            },
            {
                "id": "deepseek.v3.2",
                "name": "DeepSeek V3.2",
                "url": "https://bedrock-mantle.us-west-2.api.aws/v1",
                "toolCalling": true,
                "vision": true,
                "maxInputTokens": 164000,
                "maxOutputTokens": 16000
            }
        ]
    }

ポイントは、bedrock-runtime のURLではなく、bedrock-mantleのAPIエンドポイント(https://bedrock-mantle.us-west-2.api.aws/v1)を利用する点。

bedrock-mantleについては以下の記事が詳しかったです。今回のケースで、bedrock-mantleのエンドポイントの何がうれしいかというと、Amazon Bedrockネイティブの形式ではなく、OpenAI互換の形式で呼び出せる点。(Anthropic形式にも対応しているらしいが、私の環境ではまだ動作確認できていない。)

zenn.dev

bedrock-mantleのエンドポイントに対応しているかは、AWSのドキュメントで確認できる。 docs.aws.amazon.com

また、gpt-oss 20bの場合、サポートしているAPIとしてCHAT COMPLETIONSに対応しているので、前述のVS Codeの設定は以下ように設定しています。

"apiType": "chat-completions",

補足

Anthropicのモデルについて、以下のURLをみると Claude 4.5 Haiku は bedrock-mantleをサポートしているとあり、"apiType": "messages", エンドポイントに "https://bedrock-mantle.{region}.api.aws/anthropic/v1/messages" を指定すれば動作するように見えるが、私の環境では現状動作が確認できていないです。(なにか間違っているのか、AWS側でbedrock-mantle経由でアクセスできるアカウントに制限をかけているのか、ちょっとよくわからないです。)

docs.aws.amazon.com

動作させたスクリーンショット

↓設定したAmazon Bedrock側のモデルを実際に動かした結果。(Amazon Bedrock側のgpt-oss-20bを動かしています。)

VS Codeスクリーンショット5

ひとまずAmazon BedrockのモデルをGitHub Copilotとして動かすことができました。