Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
HunterIOIcon,
IcypeasIcon,
JinaAIIcon,
KimiIcon,
LeadMagicIcon,
LinkupIcon,
MillionVerifierIcon,
Expand Down Expand Up @@ -86,6 +87,13 @@ const PROVIDERS: (BYOKManagerProvider & { id: BYOKProviderId })[] = [
description: 'LLM calls',
placeholder: 'xai-...',
},
{
id: 'kimi',
name: 'Kimi',
icon: KimiIcon,
description: 'LLM calls',
placeholder: 'sk-...',
},
{
id: 'fireworks',
name: 'Fireworks',
Expand Down Expand Up @@ -298,6 +306,7 @@ const PROVIDER_SECTIONS: BYOKProviderSection[] = [
'google',
'mistral',
'xai',
'kimi',
'fireworks',
'together',
'baseten',
Expand Down
14 changes: 14 additions & 0 deletions apps/sim/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3823,6 +3823,20 @@ export const ZaiIcon = (props: SVGProps<SVGSVGElement>) => (
</svg>
)

export const KimiIcon = (props: SVGProps<SVGSVGElement>) => (
<svg {...props} height='1em' viewBox='0 0 24 24' width='1em' xmlns='http://www.w3.org/2000/svg'>
<title>Kimi</title>
<path
d='M21.846 0a1.923 1.923 0 110 3.846H20.15a.226.226 0 01-.227-.226V1.923C19.923.861 20.784 0 21.846 0z'
fill='#1783FF'
/>
<path
d='M11.065 11.199l7.257-7.2c.137-.136.06-.41-.116-.41H14.3a.164.164 0 00-.117.051l-7.82 7.756c-.122.12-.302.013-.302-.179V3.82c0-.127-.083-.23-.185-.23H3.186c-.103 0-.186.103-.186.23V19.77c0 .128.083.23.186.23h2.69c.103 0 .186-.102.186-.23v-3.25c0-.069.025-.135.069-.178l2.424-2.406a.158.158 0 01.205-.023l6.484 4.772a7.677 7.677 0 003.453 1.283c.108.012.2-.095.2-.23v-3.06c0-.117-.07-.212-.164-.227a5.028 5.028 0 01-2.027-.807l-5.613-4.064c-.117-.078-.132-.279-.028-.381z'
fill='currentColor'
/>
</svg>
)

export function MetaIcon(props: SVGProps<SVGSVGElement>) {
const id = useId()
const gradient1Id = `meta_gradient_1_${id}`
Expand Down
9 changes: 8 additions & 1 deletion apps/sim/lib/api-key/byok.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,20 @@ export async function getApiKeyWithBYOK(
const isMistralModel = provider === 'mistral'
const isZaiModel = provider === 'zai'
const isXaiModel = provider === 'xai'
const isKimiModel = provider === 'kimi'

const byokProviderId = isGeminiModel ? 'google' : (provider as BYOKProviderId)

if (
isHosted &&
workspaceId &&
(isOpenAIModel || isClaudeModel || isGeminiModel || isMistralModel || isZaiModel || isXaiModel)
(isOpenAIModel ||
isClaudeModel ||
isGeminiModel ||
isMistralModel ||
isZaiModel ||
isXaiModel ||
isKimiModel)
) {
const hostedModels = getHostedModels()
const isModelHosted = hostedModels.some((m) => m.toLowerCase() === model.toLowerCase())
Expand Down
1 change: 1 addition & 0 deletions apps/sim/lib/api/contracts/byok-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const byokProviderIdSchema = z.enum([
'google',
'mistral',
'zai',
'kimi',
'xai',
'fireworks',
'together',
Expand Down
7 changes: 6 additions & 1 deletion apps/sim/lib/core/config/api-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export function getRotatingApiKey(provider: string): string {
provider !== 'gemini' &&
provider !== 'cohere' &&
provider !== 'zai' &&
provider !== 'xai'
provider !== 'xai' &&
provider !== 'kimi'
) {
throw new Error(`No rotation implemented for provider: ${provider}`)
}
Expand Down Expand Up @@ -44,6 +45,10 @@ export function getRotatingApiKey(provider: string): string {
if (env.XAI_API_KEY_1) keys.push(env.XAI_API_KEY_1)
if (env.XAI_API_KEY_2) keys.push(env.XAI_API_KEY_2)
if (env.XAI_API_KEY_3) keys.push(env.XAI_API_KEY_3)
} else if (provider === 'kimi') {
if (env.KIMI_API_KEY_1) keys.push(env.KIMI_API_KEY_1)
if (env.KIMI_API_KEY_2) keys.push(env.KIMI_API_KEY_2)
if (env.KIMI_API_KEY_3) keys.push(env.KIMI_API_KEY_3)
}

if (keys.length === 0) {
Expand Down
3 changes: 3 additions & 0 deletions apps/sim/lib/core/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ export const env = createEnv({
ZAI_API_KEY_1: z.string().min(1).optional(), // Primary Z.ai API key for load balancing
ZAI_API_KEY_2: z.string().min(1).optional(), // Additional Z.ai API key for load balancing
ZAI_API_KEY_3: z.string().min(1).optional(), // Additional Z.ai API key for load balancing
KIMI_API_KEY_1: z.string().min(1).optional(), // Primary Kimi (Moonshot AI) API key for load balancing
KIMI_API_KEY_2: z.string().min(1).optional(), // Additional Kimi API key for load balancing
KIMI_API_KEY_3: z.string().min(1).optional(), // Additional Kimi API key for load balancing
XAI_API_KEY_1: z.string().min(1).optional(), // Primary xAI API key for load balancing
XAI_API_KEY_2: z.string().min(1).optional(), // Additional xAI API key for load balancing
XAI_API_KEY_3: z.string().min(1).optional(), // Additional xAI API key for load balancing
Expand Down
5 changes: 5 additions & 0 deletions apps/sim/lib/tokenization/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ export const TOKENIZATION_CONFIG = {
confidence: 'medium',
supportedMethods: ['heuristic', 'fallback'],
},
kimi: {
avgCharsPerToken: 4,
confidence: 'medium',
supportedMethods: ['heuristic', 'fallback'],
},
ollama: {
avgCharsPerToken: 4,
confidence: 'low',
Expand Down
4 changes: 4 additions & 0 deletions apps/sim/providers/attachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type AttachmentProvider =
| 'nvidia'
| 'meta'
| 'zai'
| 'kimi'

export interface PreparedProviderAttachment {
file: UserFile
Expand Down Expand Up @@ -152,6 +153,7 @@ const PROVIDER_SUPPORTED_LABELS: Record<AttachmentProvider, string> = {
nvidia: 'no file attachments in the current API adapter',
meta: 'no file attachments in the current API adapter',
zai: 'no file attachments in the current API adapter',
kimi: 'images through image_url message parts on multimodal models',
}

export function getAttachmentProvider(providerId: ProviderId | string): AttachmentProvider | null {
Expand All @@ -175,6 +177,7 @@ export function getAttachmentProvider(providerId: ProviderId | string): Attachme
if (providerId === 'nvidia') return 'nvidia'
if (providerId === 'meta') return 'meta'
if (providerId === 'zai') return 'zai'
if (providerId === 'kimi') return 'kimi'
return null
}

Expand Down Expand Up @@ -319,6 +322,7 @@ function isMimeTypeSupportedByProvider(
case 'vllm':
case 'litellm':
case 'xai':
case 'kimi':
return isImageMimeType(mimeType)
case 'deepseek':
case 'cerebras':
Expand Down
Loading
Loading