MCPcopy Index your code
hub / github.com/simstudioai/sim / getFalApiKey

Function getFalApiKey

apps/sim/lib/media/falai.ts:29–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27 * mirroring getRotatingApiKey. Falls back to a single FALAI_API_KEY for dev.
28 */
29export function getFalApiKey(): string {
30 const count = Number.parseInt(process.env.FALAI_API_KEY_COUNT || '0', 10)
31 const keys: string[] = []
32 for (let i = 1; i <= count; i++) {
33 const key = process.env[`FALAI_API_KEY_${i}`]
34 if (key) keys.push(key)
35 }
36 if (keys.length === 0 && process.env.FALAI_API_KEY) {
37 keys.push(process.env.FALAI_API_KEY)
38 }
39 if (keys.length === 0) {
40 throw new Error(
41 'No hosted Fal.ai API key configured. Set FALAI_API_KEY_COUNT and FALAI_API_KEY_1..N.'
42 )
43 }
44 const index = new Date().getMinutes() % keys.length
45 return keys[index]
46}
47
48export function getStringProp(
49 record: Record<string, unknown> | undefined,

Callers 2

generateFalAudioFunction · 0.90
generateFalVideoFunction · 0.90

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected