(workspaceId?: string | null)
| 57 | const GEMINI_MAX_ITEMS_PER_REQUEST = 100 |
| 58 | |
| 59 | async function resolveOpenAIKey(workspaceId?: string | null): Promise<{ |
| 60 | apiKey: string |
| 61 | isBYOK: boolean |
| 62 | }> { |
| 63 | if (workspaceId) { |
| 64 | const byokResult = await getBYOKKey(workspaceId, 'openai') |
| 65 | if (byokResult) { |
| 66 | logger.info('Using workspace BYOK key for OpenAI embeddings') |
| 67 | return { apiKey: byokResult.apiKey, isBYOK: true } |
| 68 | } |
| 69 | } |
| 70 | if (env.OPENAI_API_KEY) { |
| 71 | return { apiKey: env.OPENAI_API_KEY, isBYOK: false } |
| 72 | } |
| 73 | try { |
| 74 | return { apiKey: getRotatingApiKey('openai'), isBYOK: false } |
| 75 | } catch { |
| 76 | throw new Error('OPENAI_API_KEY is not configured') |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | async function resolveGeminiKey(workspaceId?: string | null): Promise<{ |
| 81 | apiKey: string |
no test coverage detected