INNER CODE UNIT · TypeScript
getApiKey
gensx-inc/gensx · packages/gensx-cloud-mcp/src/index.ts:24
function getApiKey(): string {
// Environment variable takes precedence
const envApiKey = process.env.GENSX_API_KEY;
if (envApiKey) {
console.error("Using API key from environment variable");
return envApiKey;
}
// Fall back to config file
const config = readConfig();
if (config.api?.token) {
console.error("Using API key from config file");
return config.api.token;
}
console.error(
"No API key found. Please set GENSX_API_KEY environment variable or configure API key in ~/.gensx/config.json",
);