fix(setup,chat): pass dummy api_key for local providers
litellm requires the api_key field even for local OpenAI-compatible servers (LM Studio, llama.cpp). Use "local" as a sentinel value for providers that don't require a real key. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -121,16 +121,16 @@ def _test_connection(provider: Provider, model: str) -> None:
|
||||
try:
|
||||
import litellm
|
||||
|
||||
api_key = get_key(provider.id) if provider.requires_key else "no-key"
|
||||
# Local providers don't need a real key but litellm still requires the field
|
||||
api_key = get_key(provider.id) if provider.requires_key else "local"
|
||||
kwargs: dict = {
|
||||
"model": f"{provider.litellm_prefix}{model}",
|
||||
"messages": [{"role": "user", "content": "Reply with exactly: OK"}],
|
||||
"max_tokens": 10,
|
||||
"api_key": api_key,
|
||||
}
|
||||
if provider.base_url:
|
||||
kwargs["api_base"] = provider.base_url
|
||||
if api_key and api_key != "no-key":
|
||||
kwargs["api_key"] = api_key
|
||||
|
||||
litellm.completion(**kwargs)
|
||||
console.print("[green]✓ Connection OK[/green]")
|
||||
|
||||
Reference in New Issue
Block a user