Skip to content

Commit 8e10113

Browse files
committed
improvement(byok): make available for all plans
1 parent 684ad5a commit 8e10113

File tree

10 files changed

+31
-342
lines changed

10 files changed

+31
-342
lines changed

apps/docs/content/docs/en/enterprise/index.mdx

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,6 @@ Define permission groups to control what features and integrations team members
3131

3232
---
3333

34-
## Bring Your Own Key (BYOK)
35-
36-
Use your own API keys for AI model providers instead of Sim Studio's hosted keys.
37-
38-
### Supported Providers
39-
40-
| Provider | Usage |
41-
|----------|-------|
42-
| OpenAI | Knowledge Base embeddings, Agent block |
43-
| Anthropic | Agent block |
44-
| Google | Agent block |
45-
| Mistral | Knowledge Base OCR |
46-
47-
### Setup
48-
49-
1. Navigate to **Settings****BYOK** in your workspace
50-
2. Click **Add Key** for your provider
51-
3. Enter your API key and save
52-
53-
<Callout type="warn">
54-
BYOK keys are encrypted at rest. Only organization admins and owners can manage keys.
55-
</Callout>
56-
57-
When configured, workflows use your key instead of Sim Studio's hosted keys. If removed, workflows automatically fall back to hosted keys.
58-
59-
---
60-
6134
## Single Sign-On (SSO)
6235

6336
Enterprise authentication with SAML 2.0 and OIDC support for centralized identity management.

apps/docs/content/docs/en/execution/costs.mdx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,28 @@ The model breakdown shows:
106106

107107
## Bring Your Own Key (BYOK)
108108

109-
You can use your own API keys for hosted models (OpenAI, Anthropic, Google, Mistral) in **Settings → BYOK** to pay base prices. Keys are encrypted and apply workspace-wide.
109+
Use your own API keys for AI model providers instead of Sim Studio's hosted keys to pay base prices with no markup.
110+
111+
### Supported Providers
112+
113+
| Provider | Usage |
114+
|----------|-------|
115+
| OpenAI | Knowledge Base embeddings, Agent block |
116+
| Anthropic | Agent block |
117+
| Google | Agent block |
118+
| Mistral | Knowledge Base OCR |
119+
120+
### Setup
121+
122+
1. Navigate to **Settings****BYOK** in your workspace
123+
2. Click **Add Key** for your provider
124+
3. Enter your API key and save
125+
126+
<Callout type="info">
127+
BYOK keys are encrypted at rest. Only workspace admins can manage keys.
128+
</Callout>
129+
130+
When configured, workflows use your key instead of Sim Studio's hosted keys. If removed, workflows automatically fall back to hosted keys with the 1.4x multiplier.
110131

111132
## Cost Optimization Strategies
112133

apps/sim/app/api/v1/admin/byok/route.ts

Lines changed: 0 additions & 199 deletions
This file was deleted.

apps/sim/app/api/v1/admin/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@
5353
* GET /api/v1/admin/subscriptions/:id - Get subscription details
5454
* DELETE /api/v1/admin/subscriptions/:id - Cancel subscription (?atPeriodEnd=true for scheduled)
5555
*
56-
* BYOK Keys:
57-
* GET /api/v1/admin/byok - List BYOK keys (?organizationId=X or ?workspaceId=X)
58-
* DELETE /api/v1/admin/byok - Delete BYOK keys for org/workspace
59-
*
6056
* Access Control (Permission Groups):
6157
* GET /api/v1/admin/access-control - List permission groups (?organizationId=X)
6258
* DELETE /api/v1/admin/access-control - Delete permission groups for org (?organizationId=X)

apps/sim/app/api/workspaces/[id]/byok-keys/route.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { nanoid } from 'nanoid'
66
import { type NextRequest, NextResponse } from 'next/server'
77
import { z } from 'zod'
88
import { getSession } from '@/lib/auth'
9-
import { isEnterpriseOrgAdminOrOwner } from '@/lib/billing/core/subscription'
10-
import { isHosted } from '@/lib/core/config/feature-flags'
119
import { decryptSecret, encryptSecret } from '@/lib/core/security/encryption'
1210
import { generateRequestId } from '@/lib/core/utils/request'
1311
import { getUserEntityPermissions } from '@/lib/workspaces/permissions/utils'
@@ -58,15 +56,6 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
5856
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
5957
}
6058

61-
let byokEnabled = true
62-
if (isHosted) {
63-
byokEnabled = await isEnterpriseOrgAdminOrOwner(userId)
64-
}
65-
66-
if (!byokEnabled) {
67-
return NextResponse.json({ keys: [], byokEnabled: false })
68-
}
69-
7059
const byokKeys = await db
7160
.select({
7261
id: workspaceBYOKKeys.id,
@@ -131,20 +120,6 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
131120

132121
const userId = session.user.id
133122

134-
if (isHosted) {
135-
const canManageBYOK = await isEnterpriseOrgAdminOrOwner(userId)
136-
if (!canManageBYOK) {
137-
logger.warn(`[${requestId}] User not authorized to manage BYOK keys`, { userId })
138-
return NextResponse.json(
139-
{
140-
error:
141-
'BYOK is an Enterprise-only feature. Only organization admins and owners can manage API keys.',
142-
},
143-
{ status: 403 }
144-
)
145-
}
146-
}
147-
148123
const permission = await getUserEntityPermissions(userId, 'workspace', workspaceId)
149124
if (permission !== 'admin') {
150125
return NextResponse.json(
@@ -245,20 +220,6 @@ export async function DELETE(
245220

246221
const userId = session.user.id
247222

248-
if (isHosted) {
249-
const canManageBYOK = await isEnterpriseOrgAdminOrOwner(userId)
250-
if (!canManageBYOK) {
251-
logger.warn(`[${requestId}] User not authorized to manage BYOK keys`, { userId })
252-
return NextResponse.json(
253-
{
254-
error:
255-
'BYOK is an Enterprise-only feature. Only organization admins and owners can manage API keys.',
256-
},
257-
{ status: 403 }
258-
)
259-
}
260-
}
261-
262223
const permission = await getUserEntityPermissions(userId, 'workspace', workspaceId)
263224
if (permission !== 'admin') {
264225
return NextResponse.json(

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/byok/byok.tsx

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { useState } from 'react'
44
import { createLogger } from '@sim/logger'
5-
import { Crown, Eye, EyeOff } from 'lucide-react'
5+
import { Eye, EyeOff } from 'lucide-react'
66
import { useParams } from 'next/navigation'
77
import {
88
Button,
@@ -83,7 +83,6 @@ export function BYOK() {
8383

8484
const { data, isLoading } = useBYOKKeys(workspaceId)
8585
const keys = data?.keys ?? []
86-
const byokEnabled = data?.byokEnabled ?? true
8786
const upsertKey = useUpsertBYOKKey()
8887
const deleteKey = useDeleteBYOKKey()
8988

@@ -98,31 +97,6 @@ export function BYOK() {
9897
return keys.find((k) => k.providerId === providerId)
9998
}
10099

101-
// Show enterprise-only gate if BYOK is not enabled
102-
if (!isLoading && !byokEnabled) {
103-
return (
104-
<div className='flex h-full flex-col items-center justify-center gap-[16px] py-[32px]'>
105-
<div className='flex h-[48px] w-[48px] items-center justify-center rounded-full bg-[var(--surface-6)]'>
106-
<Crown className='h-[24px] w-[24px] text-[var(--amber-9)]' />
107-
</div>
108-
<div className='flex flex-col items-center gap-[8px] text-center'>
109-
<h3 className='font-medium text-[15px] text-[var(--text-primary)]'>Enterprise Feature</h3>
110-
<p className='max-w-[320px] text-[13px] text-[var(--text-secondary)]'>
111-
Bring Your Own Key (BYOK) is available exclusively on the Enterprise plan. Upgrade to
112-
use your own API keys and eliminate the 2x cost multiplier.
113-
</p>
114-
</div>
115-
<Button
116-
variant='primary'
117-
className='!bg-[var(--brand-tertiary-2)] !text-[var(--text-inverse)] hover:!bg-[var(--brand-tertiary-2)]/90'
118-
onClick={() => window.open('https://sim.ai/enterprise', '_blank')}
119-
>
120-
Contact Sales
121-
</Button>
122-
</div>
123-
)
124-
}
125-
126100
const handleSave = async () => {
127101
if (!editingProvider || !apiKeyInput.trim()) return
128102

@@ -340,7 +314,7 @@ export function BYOK() {
340314
<span className='font-medium text-[var(--text-primary)]'>
341315
{PROVIDERS.find((p) => p.id === deleteConfirmProvider)?.name}
342316
</span>{' '}
343-
API key? This workspace will revert to using platform keys with the 2x multiplier.
317+
API key? This workspace will revert to using platform hosted keys.
344318
</p>
345319
</ModalBody>
346320
<ModalFooter>

0 commit comments

Comments
 (0)