• Home
  • Search
  • AI Services
  • Models
  • Writing
  • Multimedia Creation
  • Translation & Others
Home›Developer Center›OpenCode Windows

OpenCode Windows

API DocumentationAPI Quick StartOpenAI ChatGPT APIAnthropic (Claude) APIGoogle Gemini APIGoogle Search APIGoogle News APIOpenRouter APIAPI Pricing
CLI & Agent Guidescc-switch macOScc-switch Windowscc-switch LinuxOpenCode macOSOpenCode WindowsOpenCode LinuxOpenClaw macOSOpenClaw WindowsOpenClaw LinuxHermes Agent macOSHermes Agent WindowsHermes Agent LinuxClaude Code CLI macOSClaude Code CLI WindowsClaude Code CLI LinuxCodex CLI macOSCodex CLI WindowsCodex CLI Linux
MYAI168 API & MCPMYAI168 Chat API GuideMYAI168 MCP CLIMYAI168 MCP Web & App
No matching questions on this page.Search the whole site
OpenCode Setup Overview (Windows)

OpenCode Install & Setup Guide — Windows

This guide explains how to install OpenCode on Windows and edit the config file opencode.json so that the model service points to MyAI168.

Please follow steps 1 to 7 below in order. If you run into trouble, see "Common Notes" at the end.

This guide applies to the current OpenCode 1.x release; the newly released OpenCode 2 reads the same config file in the same locations and format, so the setup below works unchanged.

1. Install OpenCode and launch it once

If OpenCode is not installed yet, open PowerShell and run one of the following (official docs: https://opencode.ai/docs/; the official docs recommend WSL on Windows for best compatibility, but native Windows also works with the commands below):

# Option 1: Chocolatey
choco install opencode

# Option 2: Scoop
scoop install opencode

# Option 3: npm (requires Node.js)
npm install -g opencode-ai

After installing, launch it once (type opencode in the terminal, or open the desktop app) so the config folder gets created, then fully quit it following "Step 2".

* The official docs do not guarantee that the first launch creates the config file opencode.json; if "Step 3" cannot find it, see the note at the end of that step to create it manually.

* If you have already installed and used OpenCode and the config file exists, you may skip this step.

* To switch to OpenCode 2: it uses the same opencode command and cannot be installed alongside 1.x, so remove 1.x first and follow the official docs at https://opencode.ai/v2/docs. OpenCode 2 on Windows is not available through Chocolatey / Scoop or other package managers; download the official standalone binary instead.

2. Fully quit OpenCode first

Always quit the app before editing, otherwise your changes may be overwritten by the old settings.

Close the window, and make sure there is no OpenCode icon in the taskbar (system tray) at the bottom-right (if there is, right-click it and choose Exit).

3. Open the folder containing the config file

The config file is named opencode.json and lives in a hidden directory inside your user home folder.

  1. Press Win + R to open "Run".
  2. Paste this line and press Enter:
%USERPROFILE%\.config\opencode\

File Explorer will open that folder, and opencode.json is inside it.

* OpenCode also accepts the JSONC format (opencode.jsonc); if the folder already contains opencode.jsonc, just edit that file instead — the remaining steps are the same.

* If you cannot find opencode.json in the folder, search for the file name opencode.json directly in the File Explorer search box.

If you still cannot find opencode.json (the folder is empty or does not exist): the app has not auto-generated the config file yet, so create it manually. Open "Run" (Win + R), paste the line below and press Enter to create the folder:

cmd /c "mkdir %USERPROFILE%\.config\opencode 2>nul & type nul > %USERPROFILE%\.config\opencode\opencode.json"

Then open the folder as described above and you will see the newly created empty opencode.json. The manually created file is empty; go straight to "Step 5" and paste the full content into it.

4. Open the file with a text editor

Right-click opencode.json → "Open with" → choose "Notepad".

* Important: always use a plain text editor. Do not open it with word processors like Word, as they may break the format when saving.

5. Edit the content

If the file is new or empty: copy and paste the whole block below. If the file already has content: do NOT overwrite it wholesale — that would delete your existing agent / permission / plugin / theme settings (OpenCode merges its config files rather than replacing them); instead, merge the two providers inside the "provider" block below into the "provider" block of your existing config (if there is no "provider" block yet, add the whole block).

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "myai168": {
      "name": "MyAI168",
      "npm": "@ai-sdk/openai",
      "options": {
        "baseURL": "https://www.myai168.com/en/api/openai/v1",
        "apiKey": "YOUR_API_KEY"
      },
      "models": {
        "gpt-6.1-sol": { "name": "GPT-6.1 Sol" }
      }
    },
    "myai168_claude": {
      "name": "MyAI168 Claude",
      "npm": "@ai-sdk/anthropic",
      "options": {
        "baseURL": "https://www.myai168.com/en/api/anthropic/v1",
        "apiKey": "YOUR_API_KEY"
      },
      "models": {
        "claude-opus-5-5": { "name": "Claude Opus 5.5" }
      }
    }
  }
}

The only thing you need to fill in: replace both occurrences of YOUR_API_KEY with your actual API key (use the same key in both places). Do not change anything else.

6. Save the file

Press Ctrl + S to save.

* Note: after saving, make sure the file name is still opencode.json and the extension has not been changed to .txt. If Notepad accidentally saves it as opencode.json.txt, delete the extra .txt.

7. Reopen OpenCode

After reopening OpenCode, type /models in the prompt box (or use the model menu in the desktop app) and you will see two models:

  • MyAI168 → GPT-6.1 Sol
  • MyAI168 Claude → Claude Opus 5.5

Pick one and verify with an arithmetic question: What is 123456 times 789? Reply with the number only. — if it answers 97406784 and the API usage on the Developer API Key page increases, the call went through MyAI168 (do not verify with "Who are you?"; a model's self-description is unreliable).

(Optional) To make OpenCode start with a MyAI168 model by default, add "model": "myai168/gpt-6.1-sol", at the top level of the config file (the same level as "provider"). The format is "provider ID/model ID"; for Claude use "myai168_claude/claude-opus-5-5".

Common Notes
  • Always fully quit the app before editing settings. This is the most common cause of errors.
  • It is normal that the two model URLs end differently: the OpenAI one ends with /openai/v1 and the Claude one ends with /anthropic/v1. Do not unify or change them.
  • To add a model later, add a line in the corresponding models block following the existing format (remember to add a comma at the end of the previous line).
  • MyAI168 does not appear in the model menu → the config file has a JSON error, most often a missing or extra comma or quotes turned into curly quotes. Compare it line by line with the example in "5. Edit the content", or run opencode in a terminal to see the error message.
  • 401 responses → the key is wrong, or the key has reached its credit limit (API key credit limit reached!); check the Developer API Key page.
  • No pricing info! Please use other models! → a model ID in the models block is not on this site's accepted list; use this site's model IDs (list them with GET https://www.myai168.com/en/api/openai/v1/models).
  • This guide uses the simplified "API key directly in the config file" approach. You can instead store the key with OpenCode's /connect command (choose Other at the bottom of the list and enter the provider ID myai168 or myai168_claude, which must match the config file) — OpenCode then keeps the key itself and you can omit apiKey from options. Another option is "apiKey": "{env:MYAI168_API_KEY}", which reads the key from an environment variable.
Advanced settings and useful commands

Everything below is optional and goes in %USERPROFILE%\.config\opencode\opencode.json. OpenCode merges its config files, so the snippets show only what to add or change — merge them into your existing content instead of overwriting it.

Default model and small background model

model is the model used on start-up. small_model handles light jobs such as generating conversation titles; without it those jobs also go to the main model, which costs one extra main-model call per new conversation. The small model must be listed under models of its provider:

{
  "model": "myai168_claude/claude-opus-5-5",
  "small_model": "myai168/gpt-5.4-mini",
  "provider": {
    "myai168": {
      "models": {
        "gpt-6.1-sol": { "name": "GPT-6.1 Sol" },
        "gpt-5.4-mini": { "name": "GPT-5.4 mini" }
      }
    }
  }
}

Models are always written as "provider/model"; the usable model IDs are those returned by GET https://www.myai168.com/en/api/openai/v1/models.

Using the command line

opencode models myai168
opencode run "Explain the layout of this project"
opencode run -m myai168/gpt-6.1-sol "Write unit tests for the utils module"
opencode run -c "Turn those changes into a commit message"

opencode models myai168 lists the models of that provider from your config — a quick way to confirm the file is being read; opencode run performs one task without opening the UI, -m selects a model and -c continues the previous conversation.

Project instructions: AGENTS.md

Type /init in a conversation inside your project; OpenCode analyses it and creates AGENTS.md. Keep build and test commands and coding style there, and every later conversation picks it up.

Response timeout

If long answers or long reasoning get cut off, add timeout (milliseconds) to that provider's options:

{
  "provider": {
    "myai168": {
      "options": {
        "timeout": 600000
      }
    }
  }
}

Connect MYAI168 MCP

To let OpenCode use this site's AI modules as tools, see the "OpenCode" section of the MYAI168 MCP CLI page.

‹ Previous page: OpenCode macOSNext page: OpenCode Linux ›
↑
Question link copied.

Other FAQ pages

API Documentation

  • API Quick Start
  • OpenAI ChatGPT API
  • Anthropic (Claude) API
  • Google Gemini API
  • Google Search API
  • Google News API
  • OpenRouter API
  • API Pricing

CLI & Agent Guides

  • cc-switch macOS
  • cc-switch Windows
  • cc-switch Linux
  • OpenCode macOS
  • OpenCode Linux
  • OpenClaw macOS
  • OpenClaw Windows
  • OpenClaw Linux
  • Hermes Agent macOS
  • Hermes Agent Windows
  • Hermes Agent Linux
  • Claude Code CLI macOS
  • Claude Code CLI Windows
  • Claude Code CLI Linux
  • Codex CLI macOS
  • Codex CLI Windows
  • Codex CLI Linux

MYAI168 API & MCP

  • MYAI168 Chat API Guide
  • MYAI168 MCP CLI
  • MYAI168 MCP Web & App