Install OpenCode in VS Code: Terminal Setup Guide
You install OpenCode in VS Code from the integrated terminal, not the extension marketplace: OpenCode runs in that terminal while VS Code opens your project folder and shows the edits. You run one installer command, enter an API key when asked, then open your working folder.
OpenCode is installed with one installer command in the VS Code integrated terminal, the API key lands in the OpenCode config file, and you open your project folder like any other project with no extra extension.
Does OpenCode need a VS Code extension?
No. OpenCode runs in a terminal, and the VS Code integrated terminal is enough to use it. VS Code keeps its normal job: you open the project folder, read the file changes, and run OpenCode in the terminal panel that works on the same folder.
So there is no sidebar or custom panel to install. You need VS Code, the terminal inside it, and an API key for a model from the list on the site.
How do you install OpenCode in VS Code from the terminal?
Open the integrated terminal in VS Code and run the installer command for your operating system. The script asks for your API key, so have a key in the sk-tkx-... format ready before you start.
bash <(curl -fsSL https://tokenomixai.com/install/opencode.sh)On Windows, run the PowerShell version in the VS Code terminal. The irm command downloads the script and iex runs it, and your key is still typed in when the script asks, never placed inside the URL.
irm https://tokenomixai.com/install/opencode.ps1 | iexThe installer adds a provider named tokenomixai to the OpenCode config file, makes a backup first, and leaves your other providers, MCP servers and plugins untouched. If you want to inspect the result or set it up by hand, see the docs.
Where do the API key and base URL go?
The installer adds the tokenomixai key to the provider object, not an array, using the npm package @ai-sdk/openai-compatible with options holding baseURL and apiKey. The config path on your machine is listed in the docs.
{
"provider": {
"tokenomixai": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.tokenomixai.com/v1",
"apiKey": "sk-tkx-..."
}
}
}
}The base URL for OpenCode is https://api.tokenomixai.com/v1 and it is OpenAI-compatible, so chat completions and responses travel the same path. One sk-tkx-... key works across many text and code models, and the model list with its IDs lives on the docs page.
If you edit the config yourself, do not turn provider into an array. OpenCode reads provider as an object with one entry per provider name, and adding keys in the wrong shape breaks the file on load.
Open a project folder in VS Code and run the agent
- Open the project folder through the File menu in VS Code, not a single file.
- Make sure the integrated terminal sits at the project root, since OpenCode reads context from the working directory.
- Run OpenCode from that terminal and ask it to read, edit or explain files in the folder.
- Review the changes in the editor before saving or committing.
You do not reinstall every time you open VS Code. The config and API key live at the user level, so switching projects only means switching folders, not switching keys.
For models that accept images as input, you can attach an image as context, but OpenCode is still there for text and code work.
How do you check the remaining token quota?
TokenomixAI quota is counted in tokens, not in time windows, so there is no 5-hour limit that stops your key mid-session. The key keeps working while tokens remain and before it expires.
curl https://api.tokenomixai.com/v1/quota -H "Authorization: Bearer sk-tkx-..."The response carries a status field with the value active or exhausted, then remainingTokens, maxTokens, usagePercent, expiresAt, and low, which is true at 10 percent or less. Checking it from the VS Code terminal is faster than switching to a browser tab.
One limit is worth remembering: 600 requests per minute per account, shared by every key on that account. Past that, the API returns 429 with a Retry-After header, so wait a moment and send the request again.
OpenCode or Claude Code in the VS Code terminal?
Both run from the terminal, but they are configured in different places. Here is the short comparison before you pick one, or run both on the same machine.
| Item | OpenCode | Claude Code |
|---|---|---|
| Base URL | https://api.tokenomixai.com/v1 | https://api.tokenomixai.com without /v1 |
| Config file | the OpenCode config file | the Claude Code settings file |
| What the installer writes | the tokenomixai provider inside the provider object | ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN in the env block |
| Install command | the opencode.sh or opencode.ps1 script | the claude.sh or claude.ps1 script |
With Claude Code the base URL is written without /v1 because the tool adds /v1/messages itself, and its auth token goes into the env block instead. Full setup details are on the Claude Code page.
Restore from backup when the config breaks
The installer always makes a backup before it changes a file. If OpenCode refuses to load the config after a manual edit, roll back to the previous state first, then redo the key step.
bash <(curl -fsSL https://tokenomixai.com/install/opencode.sh) --restore$env:RESTORE="1"; irm https://tokenomixai.com/install/opencode.ps1 | iexOn Windows the RESTORE variable is set on the same line before the command runs. When the restore finishes, open a new terminal in VS Code so the file changes are read again.
Frequently asked questions
Do I need to reinstall OpenCode every time I open VS Code?
No. The installer only writes config at the user level, so you run it once. After that you open the project folder and start OpenCode from the integrated terminal.
Does my API key end up inside the project folder?
No, the key is stored in the OpenCode config file at the user level, not in the project. Keep it out of any file you commit to a public repository.
Can I use OpenCode in the PowerShell terminal in VS Code on Windows?
Yes. Run the PowerShell installer command in the VS Code terminal and enter your API key when the script asks. The flow matches the macOS and Linux version.
Why is OpenCode not recognized after the installer finishes?
Check that the installer ran to the end without an error, then open a new terminal in VS Code so the environment is read again. If it still fails, review the config file and the full steps in the docs.
How do I know my tokens are almost gone?
Call the quota endpoint with your key and read the low and usagePercent fields. Once status is exhausted the key stops working until you top up, and the key itself stays the same.