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

Function resolveOpenAIKey

apps/sim/lib/knowledge/embeddings.ts:59–78  ·  view source on GitHub ↗
(workspaceId?: string | null)

Source from the content-addressed store, hash-verified

57const GEMINI_MAX_ITEMS_PER_REQUEST = 100
58
59async 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
80async function resolveGeminiKey(workspaceId?: string | null): Promise<{
81 apiKey: string

Callers 1

resolveProviderFunction · 0.85

Calls 3

getBYOKKeyFunction · 0.90
getRotatingApiKeyFunction · 0.90
infoMethod · 0.80

Tested by

no test coverage detected