MCPcopy Create free account
hub / github.com/echoVic/blade-code / validateApiKey

Function validateApiKey

src/config/defaults.ts:163–182  ·  view source on GitHub ↗
(provider: 'qwen' | 'volcengine', apiKey?: string)

Source from the content-addressed store, hash-verified

161 * 验证API密钥是否存在
162 */
163export function validateApiKey(provider: 'qwen' | 'volcengine', apiKey?: string): string {
164 // 优先使用传入的apiKey
165 if (apiKey) {
166 return apiKey;
167 }
168
169 // 然后检查环境变量
170 const config = getProviderConfig(provider);
171 if (config.apiKey) {
172 return config.apiKey;
173 }
174
175 // 如果都没有,抛出错误
176 throw new Error(
177 `${provider} API密钥未配置。请通过以下方式之一提供API密钥:\n` +
178 `1. 使用 --api-key 参数\n` +
179 `2. 设置环境变量 ${provider.toUpperCase()}_API_KEY\n` +
180 `3. 在 .env 文件中配置`
181 );
182}
183
184/**
185 * 模型说明映射

Callers 2

llmCommandFunction · 0.85
initMethod · 0.85

Calls 1

getProviderConfigFunction · 0.85

Tested by

no test coverage detected