Providers and keys: the model string
A model string names the provider, a slash, then the provider's model id. API keys come from environment variables named for each provider.
import litellm
for name in ["openai/gpt-4o-mini", "anthropic/claude-sonnet-4-5", "ollama/llama3"]:
model, provider, _, _ = litellm.get_llm_provider(name)
print(f"{provider:10} {model}")get_llm_provider is the function LiteLLM uses to split the string. The part after the slash is passed to the provider unchanged. For well-known OpenAI and Anthropic model ids, LiteLLM can often work out the provider without the prefix, but writing it keeps the code unambiguous.
Keys
The SDK quickstart lists the variable each provider reads: OPENAI_API_KEY for OpenAI, ANTHROPIC_API_KEY for Anthropic, and so on. Set them in the environment, as in APIs for AI, and completion finds them; nothing in the call changes between providers. An api_key= argument overrides the variable for one call.
A model string LiteLLM cannot read
import litellm
from litellm import completion
litellm.suppress_debug_info = True
try:
completion(model="support-bot", messages=[{"role": "user", "content": "hi"}])
except litellm.BadRequestError as error:
print(type(error).__name__)
print(str(error).splitlines()[0])No provider prefix, and not a model id LiteLLM recognises, so it cannot know where to send the request and says so before sending anything.
litellm.suppress_debug_info = True is a module setting that stops LiteLLM printing a help link to the screen alongside errors. The error itself is unchanged; the examples in this course set it to keep output readable.
- Split
"azure/my-deployment"and"gemini/gemini-2.5-flash". - Split
"gpt-4o-mini"with no prefix. - Remove the
suppress_debug_infoline and run the error example again.
Slow is fine. Stopping is the only problem.