Cline Open-Source LLM Integration: A Practical Setup Guide
This guide explains how to connect open-source LLMs to Cline in VS Code through OpenRouter or DeepSeek’s official API. It covers preparation, API key handling, environment variables, model ID lookup, curl connectivity tests, and Cline configuration, along with checks for context length, pricing, tool-calling support, and model availability.
Cline Open-Source LLM Integration: A Practical Setup Guide
1. Preparation and Model Selection
This article is for developers who already write code in VS Code and want to connect open-source LLMs to a coding assistant. Before starting, prepare the following:
- VS Code, with the Cline extension installed from the marketplace.
- An OpenRouter account (https://openrouter.ai) for aggregated gateway access.
- If you plan to use an official direct connection, a DeepSeek open platform account (https://platform.deepseek.com).
- The
curlcommand-line tool. macOS and Linux usually include it. Windows 10 and later includecurl.exe; verify it in PowerShell withcurl.exe --version. If the command is not found, macOS users can install it withbrew install curl, Linux users can use the system package manager, and Windows users can download it from the official source.
The two connection methods compare as follows:
| Item | OpenRouter gateway | Official API direct connection |
|---|---|---|
| Use case | Initial trials and frequent switching between vendors | Committed use of one provider for long-term stability |
| Interface format | OpenAI Chat Completions compatible | OpenAI Chat Completions compatible |
| Switching cost | Change only the model ID; the key stays the same | Changing vendors requires a new account, key, and endpoint |
| Billing transparency | Billed at the unit price shown on the model page; verify whether additional fees apply | Billed according to the vendor’s published unit prices and rules |
Model parameter sizes, context lengths, and prices change by version. Before connecting, check each item on the official model card rather than relying on numbers from this or other articles. Use this checklist:
- Whether the context length covers your codebase and conversation length.
- The input and output price per million tokens.
- Whether tool calling is supported. Cline’s file read/write and command execution features depend on tool calling, so confirm this during model selection.
- Whether the model is still being served.
This article was updated in November 2026. Endpoint addresses, model names, and prices are subject to the official documentation.
2. Connecting Through OpenRouter
Step 1: Create an API Key
After logging in to OpenRouter, go to the Keys page and create a key. The key starts with sk-or- and is shown in full only once at creation time. Save it immediately in a password manager or system keychain. Do not paste it into chats, screenshots, logs, or code repositories.
Step 2: Set Environment Variables
Environment variables are used for curl tests and script calls, and they help avoid scattering the key across multiple places.
macOS or Linux (using zsh as an example, written to ~/.zshrc):
export OPENROUTER_API_KEY="your key"
After saving, run source ~/.zshrc to apply the change.
Windows PowerShell:
setx OPENROUTER_API_KEY "your key"
setx applies only to terminals opened afterward. After setting it, reopen the terminal and restart VS Code so it reads the new variable.
The API Key field in Cline must be filled in separately. Cline generally stores the key in VS Code’s encrypted storage. Do not manually write the key into settings.json or project files.
Step 3: Find the Model ID
OpenRouter model IDs use the vendor/model-name format. You can copy the ID from the model details page, or list all models with:
curl -s https://openrouter.ai/api/v1/models | jq -r '.data[].id'
The response is JSON. The model list is in the data array, and the id field of each item is the model ID. Because there are many models, you can filter with grep:
curl -s https://openrouter.ai/api/v1/models | jq -r '.data[].id' | grep -i "deepseek"
To check the context length and unit price for a specific model, run:
curl -s https://openrouter.ai/api/v1/models | jq '.data[] | select(.id=="vendor/model-name") | {id, context_length, pricing}'
Replace vendor/model-name with the ID you want to check. The values in the pricing field are USD prices per token. Convert them to prices per million tokens before comparing them with the model page. Readers who do not have jq installed can install it with Homebrew, apt, or winget.
Step 4: Verify Connectivity with curl
Before giving the key to Cline, use curl to confirm that the key and model ID are valid:
curl https://openrouter.ai/api/v1/chat/completions \-H "Authorization: Bearer $OPENROUTER_API_KEY" \-H "Content-Type: application/json" \-d '{"model": "vendor/model-name", "messages": [{"role": "user", "content": "Reply in one sentence: connection successful"}]}'
On Windows PowerShell, use curl.exe, write the parameters on one line, and replace the variable with $env:OPENROUTER_API_KEY. If the returned JSON contains text in choices[0].message.content, the connection path is working. If an error is returned, inspect the returned details and troubleshoot accordingly.
Step 5: Enter Parameters in Cline
- Click the Cline icon in the VS Code sidebar to open the settings panel.
- Select
OpenAI Compatiblefor API Provider. - Enter
https://openrouter.ai/api/v1for Base URL. - Enter the OpenRouter key for API Key.
- Enter the model ID confirmed in Step 3 for Model ID.
- Save the settings and send a simple message to test.
Cline also includes a built-in OpenRouter option. After selecting it, you only need to enter the key and model ID because the address is already built in. Either method works.
3. Connecting Through the Official DeepSeek API
An official direct connection removes one forwarding layer. Billing and quota rules are provided directly by the vendor, making this suitable for scenarios where you use the same provider’s model over the long term.
Step 1: Get a Key and Set an Environment Variable
Log in to the DeepSeek open platform, go to the API keys page, and create a key. It is also shown only once. Save the key as the environment variable DEEPSEEK_API_KEY. Use the same method as in Section 2, replacing only the variable name.
Step 2: Confirm the Endpoint and Model Name
The DeepSeek API is compatible with the OpenAI format. The Base URL is https://api.deepseek.com. When using the OpenAI SDK, you can also write it as https://api.deepseek.com/v1; v1 here refers to the API version and is unrelated to the model version. Model names are subject to the official documentation. You can list currently available models with the following command:
```bash
curl -s https://api.de
