-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat(byok): byok for hosted model capabilities #2574
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR implements Bring Your Own Key (BYOK) functionality allowing workspaces to use their own API keys for hosted model providers (OpenAI, Anthropic, Google, Mistral, Exa). When BYOK keys are configured, the platform skips billing charges since users are paying providers directly. Key Changes
ArchitectureThe implementation follows a clean separation of concerns: encryption happens at the API boundary, decryption occurs at usage time via Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant UI as BYOK Settings UI
participant API as BYOK API Route
participant DB as Database
participant Enc as Encryption Service
participant Workflow as Workflow Executor
participant Handler as Agent Handler
participant BYOK as BYOK Service
participant Provider as Provider Service
participant LLM as LLM Provider
User->>UI: Add/Update API Key
UI->>API: POST /api/workspaces/{id}/byok-keys
API->>API: Verify admin permissions
API->>Enc: encryptSecret(apiKey)
Enc-->>API: encrypted key
API->>DB: Insert/Update workspace_byok_keys
DB-->>API: Success
API-->>UI: Masked key response
UI-->>User: Show success
Note over Workflow,LLM: Workflow Execution Flow
Workflow->>Handler: Execute agent block
Handler->>BYOK: getApiKeyWithBYOK(provider, model, workspaceId)
BYOK->>DB: Query workspace_byok_keys
DB-->>BYOK: Encrypted key (if exists)
BYOK->>Enc: decryptSecret(encryptedKey)
Enc-->>BYOK: Decrypted API key
BYOK-->>Handler: {apiKey, isBYOK: true}
Handler->>Provider: executeRequest({...request, isBYOK: true})
Provider->>LLM: API call with BYOK key
LLM-->>Provider: Response
Provider->>Provider: Skip billing (isBYOK=true)
Provider-->>Handler: Response with cost=0
Handler-->>Workflow: Block output
|
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.
33 files reviewed, 1 comment
Summary
BYOK to allow users to use their own keys for hosted providers
Type of Change
Testing
Tested manually
Checklist