Skip to content

Commit 363d467

Browse files
committed
fix(litellm): close audit gaps from PR #4644
- byok.ts: add litellm branch to getApiKeyWithBYOK so workflow block execution can resolve the proxy key instead of throwing "API key is required for litellm ..." - check-api-validation-contracts.ts: bump route baseline 755 -> 756 to account for the new /api/providers/litellm/models route - .env.example: document LITELLM_BASE_URL / LITELLM_API_KEY - copilot edit-workflow validation: include LiteLLM in the list of user-configured prefixed providers shown to the model - providers/utils.ts: drop stray optional-chain on providers.litellm to match the vllm pattern - lint: apply biome formatting fixes (multi-line if, SVG path, multi-line DYNAMIC_MODEL_PROVIDERS)
1 parent cebaf0c commit 363d467

8 files changed

Lines changed: 22 additions & 10 deletions

File tree

apps/sim/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ API_ENCRYPTION_KEY=your_api_encryption_key # Use `openssl rand -hex 32` to gener
4848
# OLLAMA_URL=http://localhost:11434 # URL for local Ollama server - uncomment if using local models
4949
# VLLM_BASE_URL=http://localhost:8000 # Base URL for your self-hosted vLLM (OpenAI-compatible)
5050
# VLLM_API_KEY= # Optional bearer token if your vLLM instance requires auth
51+
# LITELLM_BASE_URL=http://localhost:4000 # Base URL for your LiteLLM proxy (OpenAI-compatible)
52+
# LITELLM_API_KEY= # Optional bearer token if your LiteLLM proxy requires auth
5153
# FIREWORKS_API_KEY= # Optional Fireworks AI API key for model listing
5254
# NEXT_PUBLIC_BEDROCK_DEFAULT_CREDENTIALS=true # Set when using AWS default credential chain (IAM roles, ECS task roles, IRSA). Hides credential fields in Agent block UI.
5355
# AZURE_OPENAI_ENDPOINT= # Azure OpenAI endpoint (hides field in UI when set alongside NEXT_PUBLIC_AZURE_CONFIGURED)

apps/sim/blocks/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ function shouldRequireApiKeyForModel(model: string): boolean {
165165
}
166166

167167
const storeProvider = getProviderFromStore(normalizedModel)
168-
if (storeProvider === 'ollama' || storeProvider === 'vllm' || storeProvider === 'litellm') return false
168+
if (storeProvider === 'ollama' || storeProvider === 'vllm' || storeProvider === 'litellm')
169+
return false
169170
if (storeProvider) return true
170171

171172
if (isOllamaConfigured) {

apps/sim/components/icons.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4444,10 +4444,7 @@ export function LitellmIcon(props: SVGProps<SVGSVGElement>) {
44444444
<svg {...props} fill='none' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'>
44454445
<title>LiteLLM</title>
44464446
<rect width='24' height='24' rx='4' fill='#1A56DB' />
4447-
<path
4448-
d='M6 7h2v10H6V7zm4 0h2v8h4v2h-6V7z'
4449-
fill='white'
4450-
/>
4447+
<path d='M6 7h2v10H6V7zm4 0h2v8h4v2h-6V7z' fill='white' />
44514448
</svg>
44524449
)
44534450
}

apps/sim/lib/api-key/byok.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ export async function getApiKeyWithBYOK(
7474
return { apiKey: userProvidedKey || env.VLLM_API_KEY || 'empty', isBYOK: false }
7575
}
7676

77+
const isLitellmModel =
78+
provider === 'litellm' || useProvidersStore.getState().providers.litellm.models.includes(model)
79+
if (isLitellmModel) {
80+
return { apiKey: userProvidedKey || env.LITELLM_API_KEY || 'empty', isBYOK: false }
81+
}
82+
7783
const isFireworksModel =
7884
provider === 'fireworks' ||
7985
useProvidersStore.getState().providers.fireworks.models.includes(model)

apps/sim/lib/copilot/tools/server/workflow/edit-workflow/validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ export function validateValueForSubBlockType(
369369
blockType,
370370
field: fieldName,
371371
value,
372-
error: `Unknown model id "${trimmed}" for block "${blockType}". Read components/blocks/${blockType}.json (the model.options array) for valid ids; prefer entries with recommended: true and avoid deprecated: true. For user-configured models (Ollama, vLLM, OpenRouter, Fireworks), prefix the id with the provider slash, e.g. "ollama/llama3.1:8b".${suggestionText}`,
372+
error: `Unknown model id "${trimmed}" for block "${blockType}". Read components/blocks/${blockType}.json (the model.options array) for valid ids; prefer entries with recommended: true and avoid deprecated: true. For user-configured models (Ollama, vLLM, LiteLLM, OpenRouter, Fireworks), prefix the id with the provider slash, e.g. "ollama/llama3.1:8b".${suggestionText}`,
373373
},
374374
}
375375
}

apps/sim/providers/models.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2817,7 +2817,13 @@ export function getProviderModels(providerId: string): string[] {
28172817
return PROVIDER_DEFINITIONS[providerId]?.models.map((m) => m.id) || []
28182818
}
28192819

2820-
export const DYNAMIC_MODEL_PROVIDERS = ['ollama', 'vllm', 'litellm', 'openrouter', 'fireworks'] as const
2820+
export const DYNAMIC_MODEL_PROVIDERS = [
2821+
'ollama',
2822+
'vllm',
2823+
'litellm',
2824+
'openrouter',
2825+
'fireworks',
2826+
] as const
28212827

28222828
function getAllStaticModelIds(): string[] {
28232829
const ids: string[] = []

apps/sim/providers/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ export function getApiKey(provider: string, model: string, userProvidedKey?: str
753753
}
754754

755755
const isLitellmModel =
756-
provider === 'litellm' || useProvidersStore.getState().providers.litellm?.models.includes(model)
756+
provider === 'litellm' || useProvidersStore.getState().providers.litellm.models.includes(model)
757757
if (isLitellmModel) {
758758
return userProvidedKey || 'empty'
759759
}

scripts/check-api-validation-contracts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const QUERY_HOOKS_DIR = path.join(ROOT, 'apps/sim/hooks/queries')
99
const SELECTOR_HOOKS_DIR = path.join(ROOT, 'apps/sim/hooks/selectors')
1010

1111
const BASELINE = {
12-
totalRoutes: 755,
13-
zodRoutes: 755,
12+
totalRoutes: 756,
13+
zodRoutes: 756,
1414
nonZodRoutes: 0,
1515
} as const
1616

0 commit comments

Comments
 (0)