Cline for VS Code API Setup

Configure Cline for VS Code with a TokenHub OpenAI-compatible API, API key, and coding-agent model.

What is Cline for VS Code?

Cline is an open-source coding agent for VS Code that can use a custom OpenAI-compatible API to read code, propose edits, and run approved tools.

This Cline VS Code setup keeps your provider credentials and model selection in Cline's own settings, then verifies the connection with a read-only coding task before any write access is approved. Cline combines model responses with file access, terminal commands, browser actions, and approval controls inside the editor. A successful chat response is only the first check: use a test workspace, keep automatic approval disabled initially, and verify native tool calling before relying on the model for edits or long autonomous tasks.

Cline can route model requests through TokenHub's OpenAI compatible API gateway. Keep the official installation flow, then replace only the API key, Base URL, and model ID.

The TokenHub endpoint used by this guide is https://us-api.tokenhub.com/v1/chat/completions.

When to use it

Start in a small repository or test project. First ask the tool to read files, explain code, or produce a plan; only then enable edits, terminal commands, or agent automation.

Install or open the tool

Follow the official Cline documentation to install or open the tool. If menus or command names differ, prefer the current official documentation.

For CLI tools, confirm the executable works before adding TokenHub credentials:

# open the tool, then open its model or provider settings

Prepare TokenHub credentials

Create a TokenHub API key and choose a model from the TokenHub model list that fits this tool.

export TOKENHUB_API_KEY="sk-..."

Keep the key in your local shell, IDE secret storage, or the secure API key field of the tool. Do not commit it to the repository.

Configure TokenHub persistently

Use the tool configuration file or settings page first. This avoids the common problem where a terminal sees the environment variable but the IDE, plugin, or new window does not.

Provider values

FieldValue
ProviderOpenAI Compatible or Custom
Base URLhttps://us-api.tokenhub.com/v1
API KeyThe value of TOKENHUB_API_KEY
Modelgpt-4.1 or another TokenHub model ID

Settings file locations

FieldValue
Provider settingsCline settings panel
Provider modeOpenAI Compatible
Required fieldsBase URL, API Key, Model ID

Use the settings UI first when the extension owns the schema. It stores the same values in a user-level settings file and avoids guessing private keys that may change between releases.

Save the TokenHub provider in the tool UI. If the tool separates Chat, Edit, Apply, Fast, or Autocomplete models, point every slot to TokenHub for the first test.

If the tool separates chat, edit, apply, and fast models, use the same TokenHub model for the first test. Split models later by cost, latency, and reasoning strength.

Temporary environment variables for debugging

Use the settings UI first when the extension owns the schema. It stores the same values in a user-level settings file and avoids guessing private keys that may change between releases.

Use temporary variables only to confirm the key, network, and model name. After validation, move the same values into the persistent configuration above.

Verify the connection

Test with a read-only prompt first, confirming that the model can read context without changing files. Then test edits, Apply, or agent tasks.

Read the project README and summarize it in three sentences. Do not modify any files.

After a successful prompt, check TokenHub request logs for model name, endpoint, token usage, and billing group.

Troubleshooting

SymptomFix
401 or authentication failureConfirm TOKENHUB_API_KEY is valid and saved in the same terminal, IDE, or client profile.
404 or model not foundUse a model ID that exists in your TokenHub workspace and matches the selected protocol.
Wrong endpointKeep the Base URL exactly as shown. OpenAI-compatible tools usually need /v1; Claude-compatible tools usually do not.
Request timeoutCheck network access to https://us-api.tokenhub.com, proxy settings, and workspace allowlists.
Tool uses another modelRecheck every chat, edit, apply, fast, and autocomplete model slot.

Choose a compatible Cline model

WorkloadModel choiceWhy it fits
Complex coding tasksA tool-capable reasoning modelUse a model with reliable tool use, streaming, and the context length your workflow needs.
Daily implementationA balanced coding modelPrioritize reliable edits and useful latency for normal coding loops.
Background and subagent workA fast, lower-cost modelUse this for iterations, summaries, and simpler work only after validating tool use.
Browse TokenHub models and compatibility

Cline for VS Code API FAQ

Where should I save the TokenHub configuration in Cline?

Save it through Cline's API Provider settings panel. Team documentation can share the Base URL and model ID, but never a real API key.

Why can Cline answer questions but not edit files?

First confirm that the model supports tool use, then check Cline's file-write permissions and approval settings. A text response only proves that the base connection works.

Why did the provider change after reopening a workspace?

Workspace-level configuration may override user settings. Check that the active provider, Base URL, and model ID still point to TokenHub.

How are Cline API costs calculated?

The extension and model API are separate billing layers. TokenHub charges according to the selected model's actual token and applicable cache usage at the current model-page price.

What do Cline rules and .clinerules do?

They provide project conventions, command constraints, and workflow guidance. They do not replace the Provider Base URL, API key, or Model ID configuration.

References

This setup is based on TokenHub and official documentation, last verified on 2026-09-04.