fix(api): skip API key prompt for local Ollama using noApiKey flag

Local Ollama doesn't require an API key, but the CLI was still
prompting for one. This adds a `noApiKey` flag to provider presets
to mark providers that don't need authentication.

- Add `noApiKey?: boolean` property to ProviderPreset interface
- Set `noApiKey: true` for local Ollama (no key needed)
- All other presets unchanged (default to requiring API key)
- Skip API key prompt and show info message when noApiKey is true

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Huynh Duc Dung
2026-01-22 17:34:12 +08:00
co-authored by Claude
parent ef2c8bba12
commit dc6977d32e
2 changed files with 5 additions and 8 deletions
+2 -3
View File
@@ -181,11 +181,10 @@ async function handleCreate(args: string[]): Promise<void> {
console.log(dim('Note: For OpenRouter, ANTHROPIC_API_KEY should be empty.'));
}
// Step 3: API Key (skip if preset doesn't require one)
// Step 3: API Key (skip if preset has noApiKey flag)
let apiKey = parsedArgs.apiKey;
const requiresApiKey = preset?.requiresApiKey !== false;
if (!requiresApiKey) {
if (preset?.noApiKey) {
// Preset doesn't require API key (e.g., local Ollama)
console.log(info('No API key required for local Ollama'));
apiKey = ''; // Empty string for local providers