docs(provider): add comments to vercel transform logic
This commit is contained in:
@@ -23,13 +23,18 @@ function applyGatewayTransforms(model: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function transformModelForProvider(provider: string, model: string): string {
|
export function transformModelForProvider(provider: string, model: string): string {
|
||||||
|
// Vercel AI Gateway expects <sub-provider>/<model> (e.g. anthropic/claude-opus-4.6).
|
||||||
|
// Canonical names in model-requirements.ts may be bare (claude-opus-4-6) or
|
||||||
|
// already prefixed (anthropic/claude-opus-4-6). Both need gateway-specific transforms.
|
||||||
if (provider === "vercel") {
|
if (provider === "vercel") {
|
||||||
|
// Already prefixed — transform only the model part
|
||||||
const slashIndex = model.indexOf("/")
|
const slashIndex = model.indexOf("/")
|
||||||
if (slashIndex !== -1) {
|
if (slashIndex !== -1) {
|
||||||
const subProvider = model.substring(0, slashIndex)
|
const subProvider = model.substring(0, slashIndex)
|
||||||
const subModel = model.substring(slashIndex + 1)
|
const subModel = model.substring(slashIndex + 1)
|
||||||
return `${subProvider}/${applyGatewayTransforms(subModel)}`
|
return `${subProvider}/${applyGatewayTransforms(subModel)}`
|
||||||
}
|
}
|
||||||
|
// Bare name — infer sub-provider from model prefix (claude- → anthropic, etc.)
|
||||||
const subProvider = inferSubProvider(model)
|
const subProvider = inferSubProvider(model)
|
||||||
if (subProvider) {
|
if (subProvider) {
|
||||||
return `${subProvider}/${applyGatewayTransforms(model)}`
|
return `${subProvider}/${applyGatewayTransforms(model)}`
|
||||||
|
|||||||
Reference in New Issue
Block a user