()
| 27 | * mirroring getRotatingApiKey. Falls back to a single FALAI_API_KEY for dev. |
| 28 | */ |
| 29 | export 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 | |
| 48 | export function getStringProp( |
| 49 | record: Record<string, unknown> | undefined, |
no test coverage detected