Installation and setup
LiteLLM installs from PyPI, with an extra for its gateway server. It reads each provider's key from the environment, and Groq and Gemini both hand out free keys.
litellm[proxy] 1.101.0 and its helpers
[proxy] adds the gateway server. tenacity is needed for retries in lesson 10 and prisma for the gateway's key checks in lesson 18; lessons 10 and 18 show what happens without them. openai is used to call the gateway in lesson 17.
pip install "litellm[proxy]==1.101.0" tenacity prisma openaifrom importlib.metadata import version
print(version("litellm"))Provider keys for completion()Optional
The course registers stand-in providers in lessons 5 and 8, so it runs without a key. For a real call, completion() looks at the prefix of the model name and reads that provider's variable.
| Provider | Key | Variable | model= |
|---|---|---|---|
| Groq | Free, console.groq.com/keys | GROQ_API_KEY | "groq/openai/gpt-oss-120b" |
| Gemini | Free, aistudio.google.com/apikey | GEMINI_API_KEY | "gemini/gemini-2.5-flash" |
| OpenRouter | Free models end in :free, openrouter.ai/keys | OPENROUTER_API_KEY | "openrouter/google/gemma-4-31b-it:free" |
| OpenAI | Paid, platform.openai.com/api-keys | OPENAI_API_KEY | "openai/gpt-4o-mini" |
export GROQ_API_KEY=gsk_...from litellm import completion
response = completion(
model="groq/openai/gpt-oss-120b",
messages=[{"role": "user", "content": "Say hello"}],
)
print(response.choices[0].message.content)A gateway config names the variable instead of holding the key, as os.environ/GROQ_API_KEY. The gateway's own admin key, LITELLM_MASTER_KEY, is set the same way.
model_list:
- model_name: fast
litellm_params:
model: groq/openai/gpt-oss-120b
api_key: os.environ/GROQ_API_KEY- Run
litellm --helpand read the gateway's options.
Little by little, you're building something great.