MCPcopy Index your code
hub / github.com/garrytan/gstack / requireApiKey

Function requireApiKey

design/src/auth.ts:121–136  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

119 * Get API key or exit with setup instructions.
120 */
121export function requireApiKey(): string {
122 const resolution = resolveApiKeyInfo();
123 if (!resolution) {
124 console.error("No OpenAI API key found.");
125 console.error("");
126 console.error("Run: $D setup");
127 console.error(" or save to ~/.gstack/openai.json: { \"api_key\": \"sk-...\" }");
128 console.error(" or set OPENAI_API_KEY environment variable");
129 console.error("");
130 console.error("Get a key at: https://platform.openai.com/api-keys");
131 process.exit(1);
132 }
133 console.error(`Using OpenAI key from ${describeApiKeySource(resolution)}.`);
134 if (resolution.warning) console.error(resolution.warning);
135 return resolution.key;
136}

Callers 9

auth.test.tsFile · 0.90
checkMockupFunction · 0.90
diffMockupsFunction · 0.90
generateFunction · 0.90
evolveFunction · 0.90
iterateFunction · 0.90
variantsFunction · 0.90
extractDesignLanguageFunction · 0.90

Calls 2

resolveApiKeyInfoFunction · 0.85
describeApiKeySourceFunction · 0.85

Tested by

no test coverage detected