feat(byok): byok for hosted model capabilities#2574
Merged
icecrasher321 merged 10 commits intostagingfrom Dec 25, 2025
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
Author
|
@greptile |
Contributor
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
|
Collaborator
Author
|
@greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BYOK to allow users to use their own keys for hosted providers
Type of Change
Testing
Tested manually
Checklist