1473fc7336
Naively uppercasing the routing prefix breaks for providers whose LiteLLM env var name doesn't match the prefix verbatim: together_ai/... needs TOGETHERAI_API_KEY (no underscore) perplexity/... needs PERPLEXITYAI_API_KEY Ask LiteLLM directly via litellm.validate_environment(model=...) which env vars it consults for the chosen provider, then setdefault each one to LLM_API_KEY. This is the SDK-blessed lookup and stays correct for every provider LiteLLM supports without a hand-maintained name map. Lowercase the routed model name before lookup so mixed-case user input (e.g. Together_AI/...) still resolves.