Skip to content

Commit 91ed533

Browse files
improvement(byok): make available for all plans (#2782)
* improvement(byok): make available for all plans * update docs * address greptile comments
1 parent d55072a commit 91ed533

File tree

11 files changed

+32
-346
lines changed

11 files changed

+32
-346
lines changed

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

Lines changed: 0 additions & 28 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.
@@ -117,4 +90,3 @@ curl -X POST https://your-instance/api/v1/admin/organizations/{orgId}/members \
11790
### Notes
11891

11992
- Enabling `ACCESS_CONTROL_ENABLED` automatically enables organizations, as access control requires organization membership.
120-
- BYOK is only available on hosted Sim Studio. Self-hosted deployments configure AI provider keys directly via environment variables.

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 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: 1 addition & 40 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,
@@ -108,7 +97,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
10897
})
10998
)
11099

111-
return NextResponse.json({ keys: formattedKeys, byokEnabled: true })
100+
return NextResponse.json({ keys: formattedKeys })
112101
} catch (error: unknown) {
113102
logger.error(`[${requestId}] BYOK keys GET error`, error)
114103
return NextResponse.json(
@@ -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(

0 commit comments

Comments
 (0)