-
Notifications
You must be signed in to change notification settings - Fork 6
Add AWS BYOK with naive approach only for anthropic models #548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,14 +128,26 @@ export function applyVercelSettings( | |
| ? VercelUserByokInferenceProviderIdSchema.enum.mistral | ||
| : provider.providerId; | ||
| const list = new Array<VercelInferenceProviderConfig>(); | ||
|
|
||
| if (key === VercelUserByokInferenceProviderIdSchema.enum.zai) { | ||
| // Z.AI Coding Plan support | ||
| list.push({ | ||
| apiKey: provider.decryptedAPIKey, | ||
| baseURL: 'https://api.z.ai/api/coding/paas/v4', | ||
| }); | ||
| } | ||
| list.push({ apiKey: provider.decryptedAPIKey }); | ||
|
|
||
| if (key === VercelUserByokInferenceProviderIdSchema.enum.bedrock) { | ||
| const { accessKeyId, secretAccessKey, region } = JSON.parse(provider.decryptedAPIKey) as { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: Unvalidated This parses user-provided BYOK credentials without a guarded parse or runtime schema validation. Malformed JSON will throw at runtime, and missing fields can flow through as |
||
| accessKeyId: string; | ||
| secretAccessKey: string; | ||
| region?: string; | ||
| }; | ||
| list.push({ accessKeyId, secretAccessKey, region }); | ||
| } else { | ||
| list.push({ apiKey: provider.decryptedAPIKey }); | ||
| } | ||
|
|
||
| byokProviders[key] = [...(byokProviders[key] ?? []), ...list]; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUGGESTION: Consider making the union discriminated
This union type has no discriminant property, which means TypeScript can't narrow it without manual checks. If Vercel's gateway API accepts it, consider adding a discriminant (e.g.
type: 'apiKey' | 'bedrock') or at minimum adding a comment explaining how consumers should distinguish between the two shapes. As-is, code consumingVercelInferenceProviderConfigwill need to use'accessKeyId' in configchecks to narrow.