fix: Claude w/bedrock custom inference profile - caching support (#9838)
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
This commit is contained in:
@@ -248,6 +248,8 @@ export namespace ProviderTransform {
|
|||||||
model.providerID === "anthropic" ||
|
model.providerID === "anthropic" ||
|
||||||
model.api.id.includes("anthropic") ||
|
model.api.id.includes("anthropic") ||
|
||||||
model.api.id.includes("claude") ||
|
model.api.id.includes("claude") ||
|
||||||
|
model.id.includes("anthropic") ||
|
||||||
|
model.id.includes("claude") ||
|
||||||
model.api.npm === "@ai-sdk/anthropic"
|
model.api.npm === "@ai-sdk/anthropic"
|
||||||
) {
|
) {
|
||||||
msgs = applyCaching(msgs, model.providerID)
|
msgs = applyCaching(msgs, model.providerID)
|
||||||
|
|||||||
@@ -996,6 +996,41 @@ describe("ProviderTransform.message - providerOptions key remapping", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("ProviderTransform.message - claude w/bedrock custom inference profile", () => {
|
||||||
|
test("adds cachePoint", () => {
|
||||||
|
const model = {
|
||||||
|
id: "amazon-bedrock/custom-claude-sonnet-4.5",
|
||||||
|
providerID: "amazon-bedrock",
|
||||||
|
api: {
|
||||||
|
id: "arn:aws:bedrock:xxx:yyy:application-inference-profile/zzz",
|
||||||
|
url: "https://api.test.com",
|
||||||
|
npm: "@ai-sdk/amazon-bedrock",
|
||||||
|
},
|
||||||
|
name: "Custom inference profile",
|
||||||
|
capabilities: {},
|
||||||
|
options: {},
|
||||||
|
headers: {},
|
||||||
|
} as any
|
||||||
|
|
||||||
|
const msgs = [
|
||||||
|
{
|
||||||
|
role: "user",
|
||||||
|
content: "Hello",
|
||||||
|
},
|
||||||
|
] as any[]
|
||||||
|
|
||||||
|
const result = ProviderTransform.message(msgs, model, {})
|
||||||
|
|
||||||
|
expect(result[0].providerOptions?.bedrock).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
cachePoint: {
|
||||||
|
type: "ephemeral",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("ProviderTransform.variants", () => {
|
describe("ProviderTransform.variants", () => {
|
||||||
const createMockModel = (overrides: Partial<any> = {}): any => ({
|
const createMockModel = (overrides: Partial<any> = {}): any => ({
|
||||||
id: "test/test-model",
|
id: "test/test-model",
|
||||||
|
|||||||
@@ -229,6 +229,27 @@ To use Amazon Bedrock with OpenCode:
|
|||||||
/models
|
/models
|
||||||
```
|
```
|
||||||
|
|
||||||
|
:::note
|
||||||
|
For custom inference profiles, use the model and provider name in the key and set the `id` property to the arn. This ensures correct caching:
|
||||||
|
|
||||||
|
```json title="opencode.json"
|
||||||
|
{
|
||||||
|
"$schema": "https://opencode.ai/config.json",
|
||||||
|
"provider": {
|
||||||
|
"amazon-bedrock": {
|
||||||
|
// ...
|
||||||
|
"models": {
|
||||||
|
"anthropic-claude-sonnet-4.5": {
|
||||||
|
"id": "arn:aws:bedrock:us-east-1:xxx:application-inference-profile/yyy"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Anthropic
|
### Anthropic
|
||||||
|
|||||||
Reference in New Issue
Block a user