(msgs: ModelMessage[], model: Provider.Model, options: Record<string, unknown>)
| 428 | } |
| 429 | |
| 430 | export function message(msgs: ModelMessage[], model: Provider.Model, options: Record<string, unknown>) { |
| 431 | msgs = unsupportedParts(msgs, model) |
| 432 | msgs = normalizeMessages(msgs, model, options) |
| 433 | if ( |
| 434 | (model.providerID === "anthropic" || |
| 435 | model.providerID === "google-vertex-anthropic" || |
| 436 | model.api.id.includes("anthropic") || |
| 437 | model.api.id.includes("claude") || |
| 438 | model.id.includes("anthropic") || |
| 439 | model.id.includes("claude") || |
| 440 | model.api.npm === "@ai-sdk/anthropic" || |
| 441 | model.api.npm === "@ai-sdk/alibaba") && |
| 442 | model.api.npm !== "@ai-sdk/gateway" |
| 443 | ) { |
| 444 | msgs = applyCaching(msgs, model) |
| 445 | } |
| 446 | |
| 447 | // Remap providerOptions keys from stored providerID to expected SDK key |
| 448 | const key = sdkKey(model.api.npm) |
| 449 | if (key && key !== model.providerID) { |
| 450 | const remap = (opts: Record<string, any> | undefined) => { |
| 451 | if (!opts) return opts |
| 452 | if (!(model.providerID in opts)) return opts |
| 453 | const result = { ...opts } |
| 454 | result[key] = result[model.providerID] |
| 455 | delete result[model.providerID] |
| 456 | return result |
| 457 | } |
| 458 | |
| 459 | msgs = mapProviderOptions(msgs, remap) |
| 460 | } |
| 461 | |
| 462 | // Strip Responses item IDs before serialization, following Codex and keeping signed request bodies immutable. |
| 463 | if ( |
| 464 | options.store !== true && |
| 465 | key && |
| 466 | ["@ai-sdk/openai", "@ai-sdk/azure", "@ai-sdk/amazon-bedrock/mantle", "@ai-sdk/github-copilot"].includes( |
| 467 | model.api.npm, |
| 468 | ) |
| 469 | ) { |
| 470 | msgs = mapProviderOptions(msgs, (options) => { |
| 471 | if (!options?.[key] || !("itemId" in options[key])) return options |
| 472 | const metadata = { ...options[key] } |
| 473 | delete metadata.itemId |
| 474 | return { ...options, [key]: metadata } |
| 475 | }) |
| 476 | } |
| 477 | |
| 478 | return msgs |
| 479 | } |
| 480 | |
| 481 | export function temperature(model: Provider.Model) { |
| 482 | const id = model.id.toLowerCase() |
nothing calls this directly
no test coverage detected