diff --git a/.changeset/clean-needles-deliver.md b/.changeset/clean-needles-deliver.md
new file mode 100644
index 00000000..2c0e5ad2
--- /dev/null
+++ b/.changeset/clean-needles-deliver.md
@@ -0,0 +1,5 @@
+---
+"claude-dev": minor
+---
+
+Add support for custom model ID in AWS Bedrock provider, enabling use of Application Inference Profile.
diff --git a/src/api/providers/bedrock.ts b/src/api/providers/bedrock.ts
index df5a1dd3..325433f4 100644
--- a/src/api/providers/bedrock.ts
+++ b/src/api/providers/bedrock.ts
@@ -28,20 +28,26 @@ export class AwsBedrockHandler implements ApiHandler {
const modelId = await this.getModelId()
const model = this.getModel()
+ // This baseModelId is used to indicate the capabilities of the model.
+ // If the user selects a custom model, baseModelId will be set to the base model ID of the custom model.
+ // Otherwise, baseModelId will be the same as modelId.
+ const baseModelId =
+ (this.options.awsBedrockCustomSelected ? this.options.awsBedrockCustomModelBaseId : modelId) || modelId
+
// Check if this is an Amazon Nova model
- if (modelId.includes("amazon.nova")) {
+ if (baseModelId.includes("amazon.nova")) {
yield* this.createNovaMessage(systemPrompt, messages, modelId, model)
return
}
// Check if this is a Deepseek model
- if (modelId.includes("deepseek")) {
+ if (baseModelId.includes("deepseek")) {
yield* this.createDeepseekMessage(systemPrompt, messages, modelId, model)
return
}
const budget_tokens = this.options.thinkingBudgetTokens || 0
- const reasoningOn = modelId.includes("3-7") && budget_tokens !== 0 ? true : false
+ const reasoningOn = baseModelId.includes("3-7") && budget_tokens !== 0 ? true : false
// Get model info and message indices for caching
const userMsgIndices = messages.reduce((acc, msg, index) => (msg.role === "user" ? [...acc, index] : acc), [] as number[])
@@ -167,12 +173,23 @@ export class AwsBedrockHandler implements ApiHandler {
}
}
- getModel(): { id: BedrockModelId; info: ModelInfo } {
+ getModel(): { id: string; info: ModelInfo } {
const modelId = this.options.apiModelId
if (modelId && modelId in bedrockModels) {
const id = modelId as BedrockModelId
return { id, info: bedrockModels[id] }
}
+
+ const customSelected = this.options.awsBedrockCustomSelected
+ const baseModel = this.options.awsBedrockCustomModelBaseId
+ if (customSelected && modelId && baseModel && baseModel in bedrockModels) {
+ // Use the user-input model ID but inherit capabilities from the base model
+ return {
+ id: modelId,
+ info: bedrockModels[baseModel],
+ }
+ }
+
return {
id: bedrockDefaultModelId,
info: bedrockModels[bedrockDefaultModelId],
@@ -290,7 +307,7 @@ export class AwsBedrockHandler implements ApiHandler {
systemPrompt: string,
messages: Anthropic.Messages.MessageParam[],
modelId: string,
- model: { id: BedrockModelId; info: ModelInfo },
+ model: { id: string; info: ModelInfo },
): ApiStream {
// Get Bedrock client with proper credentials
const client = await this.getBedrockClient()
@@ -482,7 +499,7 @@ export class AwsBedrockHandler implements ApiHandler {
systemPrompt: string,
messages: Anthropic.Messages.MessageParam[],
modelId: string,
- model: { id: BedrockModelId; info: ModelInfo },
+ model: { id: string; info: ModelInfo },
): ApiStream {
// Get Bedrock client with proper credentials
const client = await this.getBedrockClient()
diff --git a/src/core/controller/index.ts b/src/core/controller/index.ts
index 83183cbb..0d0c841c 100644
--- a/src/core/controller/index.ts
+++ b/src/core/controller/index.ts
@@ -832,6 +832,8 @@ export class Controller {
previousModeVsCodeLmModelSelector: newVsCodeLmModelSelector,
previousModeThinkingBudgetTokens: newThinkingBudgetTokens,
previousModeReasoningEffort: newReasoningEffort,
+ previousModeAwsBedrockCustomSelected: newAwsBedrockCustomSelected,
+ previousModeAwsBedrockCustomModelBaseId: newAwsBedrockCustomModelBaseId,
planActSeparateModelsSetting,
} = await getAllExtensionState(this.context)
@@ -844,7 +846,6 @@ export class Controller {
await updateGlobalState(this.context, "previousModeReasoningEffort", apiConfiguration.reasoningEffort)
switch (apiConfiguration.apiProvider) {
case "anthropic":
- case "bedrock":
case "vertex":
case "gemini":
case "asksage":
@@ -854,6 +855,19 @@ export class Controller {
case "xai":
await updateGlobalState(this.context, "previousModeModelId", apiConfiguration.apiModelId)
break
+ case "bedrock":
+ await updateGlobalState(this.context, "previousModeModelId", apiConfiguration.apiModelId)
+ await updateGlobalState(
+ this.context,
+ "previousModeAwsBedrockCustomSelected",
+ apiConfiguration.awsBedrockCustomSelected,
+ )
+ await updateGlobalState(
+ this.context,
+ "previousModeAwsBedrockCustomModelBaseId",
+ apiConfiguration.awsBedrockCustomModelBaseId,
+ )
+ break
case "openrouter":
case "cline":
await updateGlobalState(this.context, "previousModeModelId", apiConfiguration.openRouterModelId)
@@ -899,7 +913,6 @@ export class Controller {
await updateGlobalState(this.context, "reasoningEffort", newReasoningEffort)
switch (newApiProvider) {
case "anthropic":
- case "bedrock":
case "vertex":
case "gemini":
case "asksage":
@@ -909,6 +922,11 @@ export class Controller {
case "xai":
await updateGlobalState(this.context, "apiModelId", newModelId)
break
+ case "bedrock":
+ await updateGlobalState(this.context, "apiModelId", newModelId)
+ await updateGlobalState(this.context, "awsBedrockCustomSelected", newAwsBedrockCustomSelected)
+ await updateGlobalState(this.context, "awsBedrockCustomModelBaseId", newAwsBedrockCustomModelBaseId)
+ break
case "openrouter":
case "cline":
await updateGlobalState(this.context, "openRouterModelId", newModelId)
diff --git a/src/core/storage/state-keys.ts b/src/core/storage/state-keys.ts
index b0be5f8f..63b914ed 100644
--- a/src/core/storage/state-keys.ts
+++ b/src/core/storage/state-keys.ts
@@ -29,6 +29,8 @@ export type GlobalStateKey =
| "awsBedrockEndpoint"
| "awsProfile"
| "awsUseProfile"
+ | "awsBedrockCustomSelected"
+ | "awsBedrockCustomModelBaseId"
| "vertexProjectId"
| "vertexRegion"
| "lastShownAnnouncementId"
@@ -60,6 +62,8 @@ export type GlobalStateKey =
| "previousModeThinkingBudgetTokens"
| "previousModeReasoningEffort"
| "previousModeVsCodeLmModelSelector"
+ | "previousModeAwsBedrockCustomSelected"
+ | "previousModeAwsBedrockCustomModelBaseId"
| "previousModeModelInfo"
| "liteLlmBaseUrl"
| "liteLlmModelId"
diff --git a/src/core/storage/state.ts b/src/core/storage/state.ts
index 857ba780..1a971ee7 100644
--- a/src/core/storage/state.ts
+++ b/src/core/storage/state.ts
@@ -3,7 +3,7 @@ import { DEFAULT_CHAT_SETTINGS } from "@shared/ChatSettings"
import { DEFAULT_BROWSER_SETTINGS } from "@shared/BrowserSettings"
import { DEFAULT_AUTO_APPROVAL_SETTINGS } from "@shared/AutoApprovalSettings"
import { GlobalStateKey, SecretKey } from "./state-keys"
-import { ApiConfiguration, ApiProvider, ModelInfo } from "@shared/api"
+import { ApiConfiguration, ApiProvider, BedrockModelId, ModelInfo } from "@shared/api"
import { HistoryItem } from "@shared/HistoryItem"
import { AutoApprovalSettings } from "@shared/AutoApprovalSettings"
import { BrowserSettings } from "@shared/BrowserSettings"
@@ -67,6 +67,8 @@ export async function getAllExtensionState(context: vscode.ExtensionContext) {
awsBedrockEndpoint,
awsProfile,
awsUseProfile,
+ awsBedrockCustomSelected,
+ awsBedrockCustomModelBaseId,
vertexProjectId,
vertexRegion,
openAiBaseUrl,
@@ -113,6 +115,8 @@ export async function getAllExtensionState(context: vscode.ExtensionContext) {
previousModeVsCodeLmModelSelector,
previousModeThinkingBudgetTokens,
previousModeReasoningEffort,
+ previousModeAwsBedrockCustomSelected,
+ previousModeAwsBedrockCustomModelBaseId,
qwenApiLine,
liteLlmApiKey,
telemetrySetting,
@@ -142,6 +146,8 @@ export async function getAllExtensionState(context: vscode.ExtensionContext) {
getGlobalState(context, "awsBedrockEndpoint") as Promise
+ Select "Custom" when using the Application Inference Profile in Bedrock. Enter the Application
+ Inference Profile ID in the Model ID field. However, be sure to encode the / in the ARN as %2F.
+
+ Example: arn:aws:bedrock:us-west-2:<AWS Account
+ ID>:application-inference-profile%2Fxxxxxxxxxxxx
+