feat(llm): have OpenAI provider not require API keys (for endpoints like LM Studio)

This commit is contained in:
perf3ct
2025-06-06 19:22:39 +00:00
parent c26b74495c
commit 85cfc8fbd4
4 changed files with 30 additions and 19 deletions

View File

@@ -14,7 +14,9 @@ export class OpenAIService extends BaseAIService {
}
override isAvailable(): boolean {
return super.isAvailable() && !!options.getOption('openaiApiKey');
// Make API key optional to support OpenAI-compatible endpoints that don't require authentication
// The provider is considered available as long as the parent checks pass
return super.isAvailable();
}
private getClient(apiKey: string, baseUrl?: string): OpenAI {
@@ -29,7 +31,7 @@ export class OpenAIService extends BaseAIService {
async generateChatCompletion(messages: Message[], opts: ChatCompletionOptions = {}): Promise<ChatResponse> {
if (!this.isAvailable()) {
throw new Error('OpenAI service is not available. Check API key and AI settings.');
throw new Error('OpenAI service is not available. Check AI settings.');
}
// Get provider-specific options from the central provider manager