Skip to content
Open
1 change: 1 addition & 0 deletions packages/types/src/provider-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ const bedrockSchema = apiModelIdProviderModelSchema.extend({
awsSessionToken: z.string().optional(),
awsRegion: z.string().optional(),
awsUseCrossRegionInference: z.boolean().optional(),
awsUseGlobalInference: z.boolean().optional(), // Enable Global Inference profile routing when supported
awsUsePromptCache: z.boolean().optional(),
awsProfile: z.string().optional(),
awsUseProfile: z.boolean().optional(),
Expand Down
28 changes: 22 additions & 6 deletions packages/types/src/providers/bedrock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,17 +401,22 @@ export const BEDROCK_DEFAULT_CONTEXT = 128_000
// https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html
// This mapping is pre-ordered by pattern length (descending) to ensure more specific patterns match first
export const AWS_INFERENCE_PROFILE_MAPPING: Array<[string, string]> = [
// US Government Cloud → ug. inference profile (most specific prefix first)
// Australia regions (Sydney and Melbourne) → au. inference profile (most specific - 14 chars)
["ap-southeast-2", "au."],
["ap-southeast-4", "au."],
// Japan regions (Tokyo and Osaka) → jp. inference profile (13 chars)
["ap-northeast-", "jp."],
// US Government Cloud → ug. inference profile (7 chars)
["us-gov-", "ug."],
// Americas regions → us. inference profile
// Americas regions → us. inference profile (3 chars)
["us-", "us."],
// Europe regions → eu. inference profile
// Europe regions → eu. inference profile (3 chars)
["eu-", "eu."],
// Asia Pacific regions → apac. inference profile
// Asia Pacific regions → apac. inference profile (3 chars)
["ap-", "apac."],
// Canada regions → ca. inference profile
// Canada regions → ca. inference profile (3 chars)
["ca-", "ca."],
// South America regions → sa. inference profile
// South America regions → sa. inference profile (3 chars)
["sa-", "sa."],
]

Expand Down Expand Up @@ -448,3 +453,14 @@ export const BEDROCK_1M_CONTEXT_MODEL_IDS = [
"anthropic.claude-sonnet-4-20250514-v1:0",
"anthropic.claude-sonnet-4-5-20250929-v1:0",
] as const

// Amazon Bedrock models that support Global Inference profiles
// As of Oct 2025, AWS supports Global Inference for:
// - Claude Sonnet 4
// - Claude Sonnet 4.5
// - Claude Haiku 4.5
export const BEDROCK_GLOBAL_INFERENCE_MODEL_IDS = [
"anthropic.claude-sonnet-4-20250514-v1:0",
"anthropic.claude-sonnet-4-5-20250929-v1:0",
"anthropic.claude-haiku-4-5-20251001-v1:0",
] as const
13 changes: 11 additions & 2 deletions src/api/providers/__tests__/bedrock-inference-profiles.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ describe("Amazon Bedrock Inference Profiles", () => {
describe("AWS_INFERENCE_PROFILE_MAPPING constant", () => {
it("should contain all expected region mappings", () => {
expect(AWS_INFERENCE_PROFILE_MAPPING).toEqual([
["ap-southeast-2", "au."],
["ap-southeast-4", "au."],
["ap-northeast-", "jp."],
["us-gov-", "ug."],
["us-", "us."],
["eu-", "eu."],
Expand All @@ -47,7 +50,7 @@ describe("Amazon Bedrock Inference Profiles", () => {

it("should have valid inference profile prefixes", () => {
AWS_INFERENCE_PROFILE_MAPPING.forEach(([regionPattern, inferenceProfile]) => {
expect(regionPattern).toMatch(/^[a-z-]+$/)
expect(regionPattern).toMatch(/^[a-z0-9-]+$/)
expect(inferenceProfile).toMatch(/^[a-z]+\.$/)
})
})
Expand Down Expand Up @@ -77,8 +80,14 @@ describe("Amazon Bedrock Inference Profiles", () => {

it("should return correct prefix for Asia Pacific regions", () => {
const handler = createHandler()
// Australia regions (Sydney and Melbourne) get au. prefix
expect((handler as any).constructor.getPrefixForRegion("ap-southeast-2")).toBe("au.")
expect((handler as any).constructor.getPrefixForRegion("ap-southeast-4")).toBe("au.")
// Japan regions (Tokyo and Osaka) get jp. prefix
expect((handler as any).constructor.getPrefixForRegion("ap-northeast-1")).toBe("jp.")
expect((handler as any).constructor.getPrefixForRegion("ap-northeast-3")).toBe("jp.")
// Other APAC regions get apac. prefix
expect((handler as any).constructor.getPrefixForRegion("ap-southeast-1")).toBe("apac.")
expect((handler as any).constructor.getPrefixForRegion("ap-northeast-1")).toBe("apac.")
expect((handler as any).constructor.getPrefixForRegion("ap-south-1")).toBe("apac.")
expect((handler as any).constructor.getPrefixForRegion("ap-east-1")).toBe("apac.")
})
Expand Down
8 changes: 7 additions & 1 deletion src/api/providers/__tests__/bedrock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,14 @@ describe("AwsBedrockHandler", () => {
it("should return correct prefix for APAC regions", () => {
const getPrefixForRegion = (AwsBedrockHandler as any).getPrefixForRegion

// Australia regions (Sydney and Melbourne) get au. prefix
expect(getPrefixForRegion("ap-southeast-2")).toBe("au.")
expect(getPrefixForRegion("ap-southeast-4")).toBe("au.")
// Japan regions (Tokyo and Osaka) get jp. prefix
expect(getPrefixForRegion("ap-northeast-1")).toBe("jp.")
expect(getPrefixForRegion("ap-northeast-3")).toBe("jp.")
// Other APAC regions get apac. prefix
expect(getPrefixForRegion("ap-southeast-1")).toBe("apac.")
expect(getPrefixForRegion("ap-northeast-1")).toBe("apac.")
expect(getPrefixForRegion("ap-south-1")).toBe("apac.")
})

Expand Down
18 changes: 16 additions & 2 deletions src/api/providers/bedrock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
BEDROCK_DEFAULT_CONTEXT,
AWS_INFERENCE_PROFILE_MAPPING,
BEDROCK_1M_CONTEXT_MODEL_IDS,
BEDROCK_GLOBAL_INFERENCE_MODEL_IDS,
} from "@roo-code/types"

import { ApiStream } from "../transform/stream"
Expand Down Expand Up @@ -887,6 +888,11 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
}
}

// Also strip Global Inference profile prefix if present
if (modelId.startsWith("global.")) {
return modelId.substring("global.".length)
}

// Return the model ID as-is for all other cases
return modelId
}
Expand Down Expand Up @@ -964,8 +970,16 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
//a model was selected from the drop down
modelConfig = this.getModelById(this.options.apiModelId as string)

// Add cross-region inference prefix if enabled
if (this.options.awsUseCrossRegionInference && this.options.awsRegion) {
// Apply Global Inference prefix if enabled and supported (takes precedence over cross-region)
const baseIdForGlobal = this.parseBaseModelId(modelConfig.id)
if (
this.options.awsUseGlobalInference &&
BEDROCK_GLOBAL_INFERENCE_MODEL_IDS.includes(baseIdForGlobal as any)
) {
modelConfig.id = `global.${baseIdForGlobal}`
}
// Otherwise, add cross-region inference prefix if enabled
else if (this.options.awsUseCrossRegionInference && this.options.awsRegion) {
const prefix = AwsBedrockHandler.getPrefixForRegion(this.options.awsRegion)
if (prefix) {
modelConfig.id = `${prefix}${modelConfig.id}`
Expand Down
31 changes: 29 additions & 2 deletions webview-ui/src/components/settings/providers/Bedrock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { useCallback, useState, useEffect } from "react"
import { Checkbox } from "vscrui"
import { VSCodeTextField } from "@vscode/webview-ui-toolkit/react"

import { type ProviderSettings, type ModelInfo, BEDROCK_REGIONS, BEDROCK_1M_CONTEXT_MODEL_IDS } from "@roo-code/types"
import {
type ProviderSettings,
type ModelInfo,
BEDROCK_REGIONS,
BEDROCK_1M_CONTEXT_MODEL_IDS,
BEDROCK_GLOBAL_INFERENCE_MODEL_IDS,
} from "@roo-code/types"

import { useAppTranslation } from "@src/i18n/TranslationContext"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, StandardTooltip } from "@src/components/ui"
Expand All @@ -23,6 +29,11 @@ export const Bedrock = ({ apiConfiguration, setApiConfigurationField, selectedMo
const supports1MContextBeta =
!!apiConfiguration?.apiModelId && BEDROCK_1M_CONTEXT_MODEL_IDS.includes(apiConfiguration.apiModelId as any)

// Check if the selected model supports Global Inference profile routing
const supportsGlobalInference =
!!apiConfiguration?.apiModelId &&
BEDROCK_GLOBAL_INFERENCE_MODEL_IDS.includes(apiConfiguration.apiModelId as any)

// Update the endpoint enabled state when the configuration changes
useEffect(() => {
setAwsEndpointSelected(!!apiConfiguration?.awsBedrockEndpointEnabled)
Expand Down Expand Up @@ -138,9 +149,25 @@ export const Bedrock = ({ apiConfiguration, setApiConfigurationField, selectedMo
</SelectContent>
</Select>
</div>
{supportsGlobalInference && (
<Checkbox
checked={apiConfiguration?.awsUseGlobalInference || false}
disabled={apiConfiguration?.awsUseCrossRegionInference || false}
onChange={(checked: boolean) => {
// Enabling Global Inference should disable cross-region inference
setApiConfigurationField("awsUseGlobalInference", checked)
if (checked) setApiConfigurationField("awsUseCrossRegionInference", false)
}}>
{t("settings:providers.awsGlobalInference")}
</Checkbox>
)}
<Checkbox
checked={apiConfiguration?.awsUseCrossRegionInference || false}
onChange={handleInputChange("awsUseCrossRegionInference", noTransform)}>
disabled={apiConfiguration?.awsUseGlobalInference || false}
onChange={(checked: boolean) => {
setApiConfigurationField("awsUseCrossRegionInference", checked)
if (checked) setApiConfigurationField("awsUseGlobalInference", false)
}}>
{t("settings:providers.awsCrossRegion")}
</Checkbox>
{selectedModelInfo?.supportsPromptCache && (
Expand Down
1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/ca/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/de/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@
"awsSessionToken": "AWS Session Token",
"awsRegion": "AWS Region",
"awsCrossRegion": "Use cross-region inference",
"awsGlobalInference": "Use Global inference (auto-select optimal AWS Region)",
"awsBedrockVpc": {
"useCustomVpcEndpoint": "Use custom VPC endpoint",
"vpcEndpointUrlPlaceholder": "Enter VPC Endpoint URL (optional)",
Expand Down
1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/es/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/fr/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/hi/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/id/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/it/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/ja/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/ko/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/nl/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/pl/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/pt-BR/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/ru/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/tr/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/vi/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/zh-CN/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/zh-TW/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.