{"record":{"id":"51f4439aabec1d74","repo":"hsliuping/TradingAgents-CN","slug":"unsupported-llm-provider-provider","errorCode":null,"errorMessage":"Unsupported LLM provider: {provider}","messagePattern":"Unsupported LLM provider: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tradingagents/llm_clients/factory.py","lineNumber":53,"sourceCode":"    provider_lower = normalize_provider_key(provider)\n    provider_lower = _PROVIDER_ALIASES.get(provider_lower, provider_lower)\n\n    if provider_lower in _OPENAI_COMPATIBLE:\n        from .openai_client import OpenAIClient\n\n        return OpenAIClient(model, base_url, provider=provider_lower, **kwargs)\n\n    if provider_lower == \"google\":\n        from .google_client import GoogleClient\n\n        return GoogleClient(model, base_url, **kwargs)\n\n    if provider_lower == \"anthropic\":\n        from .anthropic_client import AnthropicClient\n\n        return AnthropicClient(model, base_url, **kwargs)\n\n    raise ValueError(f\"Unsupported LLM provider: {provider}\")\n","sourceCodeStart":35,"sourceCodeEnd":54,"githubUrl":"https://github.com/hsliuping/TradingAgents-CN/blob/74783e8817d6cf6de29867880631cc555153f36b/tradingagents/llm_clients/factory.py#L35-L54","documentation":"Raised by create_llm_client when the requested LLM provider string does not match any of the supported providers after lowercasing. The factory only recognizes a fixed set (e.g. 'anthropic', plus other handled branches above line 53); anything else falls through to this ValueError. It exists to fail fast on typos or unsupported backends before client construction.","triggerScenarios":"Calling create_llm_client(model, base_url) or create_llm_client('openai', ...) with a provider string like 'OpenAI ', 'gpt', 'azure-openai', 'googl', or an unimplemented backend — any value whose lowercased form has no matching if-branch in the factory.","commonSituations":"Typo in the provider name from config/env (LLM_PROVIDER=opanai), passing a model name instead of a provider name, using a provider the installed version doesn't support (azure, bedrock, ollama), or trailing whitespace/case differences if not normalized upstream.","solutions":["Check the factory's if/elif chain above line 53 for the exact supported provider strings and correct the argument to one of them (e.g. 'anthropic').","Print/inspect the exact value being passed (including whitespace and case) at the call site or from config before invoking the factory.","If you need a new backend, add a matching branch that imports and returns the corresponding client class instead of bypassing the factory.","Upgrade the package if the provider was added in a newer release."],"exampleFix":"// before\nclient = create_llm_client(provider=\"Anthropic \", model=\"claude-3-5-sonnet\")\n\n# after\nclient = create_llm_client(provider=\"anthropic\", model=\"claude-3-5-sonnet\")","handlingStrategy":"validation","validationCode":"from tradingagents.llm_clients.factory import create_llm_client\nSUPPORTED_PROVIDERS = {\"anthropic\", \"openai\", \"deepseek\", \"google\", \"ollama\"}  # mirror factory branches\nprovider = (provider or \"\").strip().lower()\nif provider not in SUPPORTED_PROVIDERS:\n    raise ConfigError(f\"bad provider {provider!r}; expected one of {sorted(SUPPORTED_PROVIDERS)}\")\nclient = create_llm_client(provider, model, base_url, **kwargs)","typeGuard":"def is_supported_provider(p: str) -> bool:\n    \"\"\"Check against the factory's if/elif branches (see factory.py).\"\"\"\n    return isinstance(p, str) and p.strip().lower() in {\"anthropic\", \"openai\", \"deepseek\", \"google\", \"ollama\"}","tryCatchPattern":"try:\n    client = create_llm_client(provider, model, base_url, **kwargs)\nexcept ValueError as e:\n    if \"Unsupported LLM provider\" in str(e):\n        raise ConfigError(f\"Fix provider setting: {provider!r}\") from e\n    raise","preventionTips":["Centralize provider selection in config and validate it at startup, not per request.","Normalize with .strip().lower() before calling the factory.","Keep the allowed provider list in sync with factory.py when upgrading."],"tags":["llm","factory","provider","configuration","python"],"backgroundTag":"unsupported-provider","analyzedSha":"74783e8817d6cf6de29867880631cc555153f36b","analyzedAt":"2026-08-28T11:39:07.729Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}