From 9db2cbe18872f8edb0312707be9cf10df344c756 Mon Sep 17 00:00:00 2001 From: chrarnoldus <12196001+chrarnoldus@users.noreply.github.com> Date: Mon, 31 Aug 2026 09:08:29 +0000 Subject: [PATCH] feat(byok): support Bedrock API keys through Vercel Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com> --- .../organizations/byok/BYOKKeysManager.tsx | 25 ++- .../openrouter/inference-provider-id.test.ts | 35 ++++ .../openrouter/inference-provider-id.ts | 12 +- .../ai-gateway/providers/openrouter/types.ts | 4 +- .../ai-gateway/providers/vercel/index.test.ts | 54 ++++++ .../lib/ai-gateway/providers/vercel/index.ts | 8 +- .../ai-gateway/rewriteModelResponse.test.ts | 7 +- apps/web/src/routers/byok-router.test.ts | 171 +++++++++++++++++- 8 files changed, 298 insertions(+), 18 deletions(-) diff --git a/apps/web/src/components/organizations/byok/BYOKKeysManager.tsx b/apps/web/src/components/organizations/byok/BYOKKeysManager.tsx index ed96468d5a..a2b417c6a5 100644 --- a/apps/web/src/components/organizations/byok/BYOKKeysManager.tsx +++ b/apps/web/src/components/organizations/byok/BYOKKeysManager.tsx @@ -43,7 +43,7 @@ import { DirectUserByokInferenceProviderIdSchema, UserByokProviderIdSchema, VercelUserByokInferenceProviderIdSchema, - AwsCredentialsSchema, + BedrockCredentialsSchema, VertexCredentialsSchema, type VercelUserByokInferenceProviderId, } from '@/lib/ai-gateway/providers/openrouter/inference-provider-id'; @@ -280,7 +280,7 @@ export function BYOKKeysManager({ organizationId }: BYOKKeysManagerProps) { if (!value) return null; const schema = providerId === VercelUserByokInferenceProviderIdSchema.enum.bedrock - ? AwsCredentialsSchema + ? BedrockCredentialsSchema : providerId === VercelUserByokInferenceProviderIdSchema.enum.vertex ? VertexCredentialsSchema : null; @@ -293,11 +293,10 @@ export function BYOKKeysManager({ organizationId }: BYOKKeysManagerProps) { } const result = schema.safeParse(parsed); if (!result.success) { - const providerName = - providerId === VercelUserByokInferenceProviderIdSchema.enum.bedrock - ? 'AWS' - : 'Google Vertex'; - return `Invalid ${providerName} credentials:\n${z.prettifyError(result.error)}`; + if (providerId === VercelUserByokInferenceProviderIdSchema.enum.bedrock) { + return 'Enter JSON with apiKey and region, or accessKeyId, secretAccessKey, and region. Use only one authentication method.'; + } + return `Invalid Google Vertex credentials:\n${z.prettifyError(result.error)}`; } return null; }; @@ -581,7 +580,7 @@ export function BYOKKeysManager({ organizationId }: BYOKKeysManagerProps) {