Windows Setup Guide for an LLM Development Assistant
This guide explains how to configure a small command-line assistant on Windows using an OpenAI-compatible Chat Completions API. It covers environment requirements, API key management, Python virtual environments, dependency installation, optional package mirrors, and the basic configuration file.
1. Environment and Version Requirements
The setup requires the following environment. Verify each item before you begin.
- Operating system: Windows 10 22H2 or Windows 11, 64-bit
- Python: 3.10 or later; Python 3.11 or 3.12 is recommended
- Memory: At least 8 GB
- Disk space: At least 2 GB of free space
- Terminal: PowerShell 5.1 or PowerShell 7
Run the following commands in PowerShell to check your environment:
winverpy --version
If py --version returns output similar to Python 3.11.9, your Python version meets the requirement. If the command is not found, install Python from python.org and select Add python.exe to PATH during installation.
This guide uses a small command-line assistant as an example. The assistant calls an OpenAI-compatible Chat Completions API, which is available from many LLM providers. If your editor plugin supports a custom API endpoint and model name, you can also enter the relevant values from Section 4 in the plugin settings.
2. Obtain and Store the API Key Securely
2.1 Create an API Key
- Sign in to your model provider’s console and open the API Keys or Key Management page.
- Create a key. Use a name that identifies its purpose and owner, such as
dev-laptop-user1. - Grant only the permissions required by the project, such as access to the chat or conversation API.
- Copy the key immediately after creation. Many platforms do not display the complete key again after you leave the page.
- Check the remaining quota on the usage or billing page. Requests will fail if the available quota is insufficient.
2.2 Store the Key in a User Environment Variable
Run the following command in PowerShell and replace the quoted placeholder with your API key:
[Environment]::SetEnvironmentVariable("LLM_API_KEY", "PASTE_YOUR_API_KEY_HERE", "User")
This stores the variable in the current Windows user’s environment variables. Close and reopen PowerShell before using the variable.
To verify that the variable exists without displaying the key itself, run:
if ($env:LLM_API_KEY) { "Configured" } else { "Not configured" }
The expected output is:
Configured
Follow these security practices:
- Do not place the key in source code, configuration files, screenshots, or chat messages.
- Do not run
echo $env:LLM_API_KEYwhile sharing your screen. - Each team member should use a separate key so that keys can be revoked independently.
3. Create the Project and Install Dependencies
3.1 Create the Project Directory and Virtual Environment
mkdir D:\llm-assistantcd D:\llm-assistantpy -m venv .venv.\.venv\Scripts\Activate.ps1
After activation, (.venv) appears before the prompt.
If PowerShell reports that script execution is disabled on the system, run the following command to relax the policy for the current user only:
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
You can restore the previous setting with:
Set-ExecutionPolicy -Scope CurrentUser Undefined
3.2 Configure a Package Mirror When Required
If the default Python package index is slow or inaccessible in your region, you can configure an alternative mirror. For example:
py -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
This command writes the setting to the current user’s pip configuration file. Restore the default index with:
py -m pip config unset global.index-url
If the project uses npm, you can configure an npm registry instead:
npm config set registry https://registry.npmmirror.com
Restore the default npm registry with:
npm config delete registry
Use a mirror that is actually accessible from your location. If the mirror causes connection problems, restore the default source.
3.3 Install the OpenAI SDK
py -m pip install "openai>=1.0,<2.0"py -m pip show openai
In the output from the second command, the Version field should begin with 1..
The SDK is a pure Python package and normally does not require compilation tools. If a dependency reports Microsoft Visual C++ 14.0 or greater is required, install Visual Studio Build Tools and select the Desktop development with C++ workload.
3.4 Create a .gitignore File
Create a .gitignore file in the project root with the following contents:
.venv/*.local.json.envlogs/
This prevents the virtual environment, local configuration files, environment files, and logs from being committed to the repository.
4. Write the Request Script and Configuration
4.1 Create the Configuration File
Create config.json in the project root:
{"api_base": "https://your-provider.example.com/v1","api_key_env": "LLM_API_KEY","model_name": "Copy the name of an existing lightweight model from the provider's model list","temperature": 0.2,"max_tokens": 1024,"timeout_seconds": 30}
your-provider.example.com is a placeholder domain and cannot be used for real requests. Replace it with the endpoint specified in your provider’s documentation, and make sure the path includes /v1. The model_name value must also be copied from a model that actually exists in the provider’s model list.
The configuration fields are used as follows:
| Field | Meaning |
|---|---|
api_base |
The API root URL specified by the provider. Do not append /chat/completions. |
api_key_env |
The name of the environment variable containing the API key. The script reads the key through this variable instead of storing it in the configuration file. |
model_name |
The model identifier to send in requests. Use a valid lightweight model name from the provider’s model list. |
temperature |
The temperature value used for generation. |
max_tokens |
The maximum number of tokens requested in the response. |
timeout_seconds |
The request timeout in seconds. |
