diff --git a/app/api/common.ts b/app/api/common.ts index b7e41fa26..864f8870f 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -51,6 +51,11 @@ export async function requestOpenai(req: NextRequest) { ); if (isAzure) { + const isAIFoundation = serverConfig.azureUrl?.includes(".models.ai.azure.com"); + if (isAIFoundation) { + // For AI Foundation, use the path directly without api-version + path = req.nextUrl.pathname.replaceAll("/api/azure/", ""); + } else { const azureApiVersion = req?.nextUrl?.searchParams?.get("api-version") || serverConfig.azureApiVersion; @@ -85,6 +90,7 @@ export async function requestOpenai(req: NextRequest) { console.log("[Replace with DeployId", realDeployName); path = path.replaceAll(modelName, realDeployName); } + } } }