What You Need
| Item | Why |
|---|---|
| Python 3.10 or newer | Most LLM libraries need a recent Python. Check each library's page |
| A code editor | VS Code or similar |
| A terminal | To run commands |
| An API key | Lets your code call a hosted model |
| Git (optional) | To track changes |
Step 1: Create a Virtual Environment
A virtual environment keeps each project's packages separate so projects do not break each other.
Step 2: Protect Your API Key
An API key is like a password that also costs money when used. Never paste it into code that you share or commit to Git.
- Store it in an environment variable
- For local work, put it in a
.envfile and add.envto.gitignore - Use a different key for each project so you can delete one safely
- If a key leaks, revoke it in the provider's dashboard immediately
Step 3: Read the Key in Python
Here is a safe way to show a key without leaking it. It prints only the first and last characters.
sk-...def | (too short to show)
Step 4: Your First Call
Every provider has its own library, but the pattern is the same: create a client, send messages, read the reply. Replace the model name with one from your provider's documentation.
client.chat.completions.create(model=..., messages=[...]). Many open model servers copy that style, so one code pattern works in many places.
Practice
- Create the virtual environment
- Add
.envto.gitignore - Make a first call and print the answer
- Try asking the same question twice and compare
Conclusion
A clean environment and a protected key are the base of every LLM project.

