Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions packages/opencode/src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,37 @@ function fromModelsDevModel(provider: ModelsDev.Provider, model: ModelsDev.Model
}
}

const BEDROCK_1M_MODELS = ["claude-opus-4-6", "claude-opus-4-7", "claude-sonnet-4-5", "claude-sonnet-4-6"]
const BEDROCK_1M_BETA = "context-1m-2025-08-07"
const BEDROCK_1M_NATIVE = ["claude-opus-4-7"]

function splitBedrock1m(pid: string, models: Record<string, Model>) {
if (pid !== "amazon-bedrock") return
for (const [id, model] of Object.entries(models)) {
if (!BEDROCK_1M_MODELS.some((m) => model.api.id.includes(m))) continue
if (id.endsWith("-1m")) continue
const native = BEDROCK_1M_NATIVE.some((m) => model.api.id.includes(m))
const name = model.name.replace(/\s+\((200K|1M Experimental)\)$/i, "")
const opts = { ...model.options }
const raw = opts["anthropicBeta"]
const existing = (Array.isArray(raw) ? raw : typeof raw === "string" ? [raw] : []).filter(
(item): item is string => typeof item === "string",
)
delete opts["anthropicBeta"]
model.name = `${name} (200K)`
model.options = opts
model.limit = { ...model.limit, context: Math.min(model.limit.context, 200_000) }
const betas = native ? existing : [...new Set([...existing, BEDROCK_1M_BETA])]
models[`${id}-1m`] = {
...model,
id: ModelID.make(`${id}-1m`),
name: `${name} (1M)`,
limit: { ...model.limit, context: 1_000_000 },
options: { ...model.options, ...(betas.length > 0 ? { anthropicBeta: betas } : {}) },
}
}
}

export function fromModelsDevProvider(provider: ModelsDev.Provider): Info {
const models: Record<string, Model> = {}
for (const [key, model] of Object.entries(provider.models)) {
Expand All @@ -1061,6 +1092,7 @@ export function fromModelsDevProvider(provider: ModelsDev.Provider): Info {
}
}
}
splitBedrock1m(provider.id, models)
return {
id: ProviderID.make(provider.id),
source: "custom",
Expand Down
Loading