GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: ensure vercel variants pass amazon models under bedrock key (#13… · un33k/opencode@933a491

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/opencode
    • src/provider
      • transform.ts
    • test/provider
      • transform.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/opencode/src/provider/transform.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/provider/transform.ts
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -802,15 +802,22 @@ export namespace ProviderTransform {
802802
return {}
803803
}
804804

805+
// Maps model ID prefix to provider slug used in providerOptions.
806+
// Example: "amazon/nova-2-lite" → "bedrock"
807+
const SLUG_OVERRIDES: Record<string, string> = {
808+
amazon: "bedrock",
809+
}
810+
805811
export function providerOptions(model: Provider.Model, options: { [x: string]: any }) {
806812
if (model.api.npm === "@ai-sdk/gateway") {
807813
// Gateway providerOptions are split across two namespaces:
808-
// - `gateway`: gateway-native routing/caching controls
814+
// - `gateway`: gateway-native routing/caching controls (order, only, byok, etc.)
809815
// - `<upstream slug>`: provider-specific model options (anthropic/openai/...)
810816
// We keep `gateway` as-is and route every other top-level option under the
811-
// model-derived upstream slug so variants/options can stay flat internally.
817+
// model-derived upstream slug.
812818
const i = model.api.id.indexOf("/")
813-
const slug = i > 0 ? model.api.id.slice(0, i) : undefined
819+
const rawSlug = i > 0 ? model.api.id.slice(0, i) : undefined
820+
const slug = rawSlug ? (SLUG_OVERRIDES[rawSlug] ?? rawSlug) : undefined
814821
const gateway = options.gateway
815822
const rest = Object.fromEntries(Object.entries(options).filter(([k]) => k !== "gateway"))
816823
const has = Object.keys(rest).length > 0
@@ -820,6 +827,7 @@ export namespace ProviderTransform {
820827

821828
if (has) {
822829
if (slug) {
830+
// Route model-specific options under the provider slug
823831
result[slug] = rest
824832
} else if (gateway && typeof gateway === "object" && !Array.isArray(gateway)) {
825833
result.gateway = { ...gateway, ...rest }
Collapse file

‎packages/opencode/test/provider/transform.test.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/test/provider/transform.test.ts
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,36 @@ describe("ProviderTransform.providerOptions", () => {
341341
gateway: { reasoningEffort: "high" },
342342
})
343343
})
344+
345+
test("maps amazon slug to bedrock for provider options", () => {
346+
const model = createModel({
347+
providerID: "vercel",
348+
api: {
349+
id: "amazon/nova-2-lite",
350+
url: "https://ai-gateway.vercel.sh/v3/ai",
351+
npm: "@ai-sdk/gateway",
352+
},
353+
})
354+
355+
expect(ProviderTransform.providerOptions(model, { reasoningConfig: { type: "enabled" } })).toEqual({
356+
bedrock: { reasoningConfig: { type: "enabled" } },
357+
})
358+
})
359+
360+
test("uses groq slug for groq models", () => {
361+
const model = createModel({
362+
providerID: "vercel",
363+
api: {
364+
id: "groq/llama-3.3-70b-versatile",
365+
url: "https://ai-gateway.vercel.sh/v3/ai",
366+
npm: "@ai-sdk/gateway",
367+
},
368+
})
369+
370+
expect(ProviderTransform.providerOptions(model, { reasoningFormat: "parsed" })).toEqual({
371+
groq: { reasoningFormat: "parsed" },
372+
})
373+
})
344374
})
345375

346376
describe("ProviderTransform.schema - gemini array items", () => {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.