Skip to content

Commit d431c8d

Browse files
committed
update openrouter, fixed serializer to allow ollama/vllm models without api key
1 parent 02b80db commit d431c8d

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

apps/sim/providers/openrouter/index.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -431,19 +431,13 @@ export const openRouterProvider: ProviderConfig = {
431431
const accumulatedCost = calculateCost(requestedModel, tokens.input, tokens.output)
432432

433433
const streamingParams: ChatCompletionCreateParamsStreaming & { provider?: any } = {
434-
model: payload.model,
434+
...payload,
435435
messages: [...currentMessages],
436+
tool_choice: 'auto',
436437
stream: true,
437438
stream_options: { include_usage: true },
438439
}
439440

440-
if (payload.temperature !== undefined) {
441-
streamingParams.temperature = payload.temperature
442-
}
443-
if (payload.max_tokens !== undefined) {
444-
streamingParams.max_tokens = payload.max_tokens
445-
}
446-
447441
if (request.responseFormat) {
448442
;(streamingParams as any).messages = await applyResponseFormat(
449443
streamingParams as any,

apps/sim/serializer/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from '@/lib/workflows/subblocks/visibility'
1515
import { getBlock } from '@/blocks'
1616
import type { SubBlockConfig } from '@/blocks/types'
17+
import { getProviderFromModel } from '@/providers/utils'
1718
import type { SerializedBlock, SerializedWorkflow } from '@/serializer/types'
1819
import type { BlockState, Loop, Parallel } from '@/stores/workflows/workflow/types'
1920
import { generateLoopBlocks, generateParallelBlocks } from '@/stores/workflows/workflow/utils'
@@ -524,6 +525,16 @@ export class Serializer {
524525
const canonicalId = canonicalIndex.canonicalIdBySubBlockId[subBlockConfig.id]
525526
const fieldValue = canonicalId ? params[canonicalId] : params[subBlockConfig.id]
526527
if (fieldValue === undefined || fieldValue === null || fieldValue === '') {
528+
if (subBlockConfig.id === 'apiKey' && params.model) {
529+
try {
530+
const provider = getProviderFromModel(params.model as string)
531+
if (provider === 'ollama' || provider === 'vllm') {
532+
return
533+
}
534+
} catch {
535+
// If provider resolution fails, continue with validation
536+
}
537+
}
527538
missingFields.push(subBlockConfig.title || subBlockConfig.id)
528539
}
529540
})

0 commit comments

Comments
 (0)