Home›FAQ›OpenCode

OpenCode

General FAQFAQAccountFeaturesPrivacy
API DocumentationOpenAI ChatGPT APIAnthropic Claude APIGoogle Gemini APIGoogle News APIOpenRouter APIAPI Pricing
CLI & Agent GuidesOpenCodeOpenClawHermes AgentClaude Code CLICodex CLI
MYAI168 API & MCPMYAI168 MCP CLIMYAI168 MCP Web & App
No matching questions on this page. Search the whole site
OpenCode Setup Overview#

OpenCode Setup Guide

This guide covers macOS, Windows and Linux. It explains how to open and edit the OpenCode config file opencode.jsonc 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.

1. First install: launch the app once (important)#

If you just installed OpenCode and have never opened it, the config folder and opencode.jsonc may not exist yet, so later steps will not find the file.

So before your first setup, please do this:

  1. Open OpenCode once normally (wait until the main screen fully loads).
  2. Then fully quit it following "Step 2".

Only after launching it once will the app automatically create the config folder and opencode.jsonc, so the later steps can find the file.

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

* Even after launching once, some environments may still not have generated opencode.jsonc. If you still cannot find it in "Step 3", see the note at the end of that step to create it manually.

2. Fully quit OpenCode first#

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

macOS

Press Cmd + Q to close the window, and make sure there is no OpenCode icon in the menu bar at the top-right (if there is, click it and choose Quit).

Windows

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).

Linux

Close the window, and make sure there is no OpenCode icon in the system tray / top status bar (if there is, right-click it and choose Quit). If you are not sure whether it is fully closed, open a terminal and run the following command to force quit:

pkill -f opencode
3. Open the folder containing the config file#

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

macOS

  1. Open "Terminal" (in Applications → Utilities).
  2. Paste this line and press Enter:
open ~/.config/opencode/

Finder will open that folder, and opencode.jsonc is inside it.

Windows

  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.jsonc is inside it.

Linux

  1. Open a "Terminal".
  2. Paste this line and press Enter (it opens the folder in your default file manager):
xdg-open ~/.config/opencode/

The file manager will open that folder, and opencode.jsonc is inside it.

* If you cannot find opencode.jsonc in the folder, search for the file name opencode.jsonc directly in the file manager / Finder search box.

* On Linux, hidden folders (those starting with a dot) are not shown by default; in the file manager you can press Ctrl + H to toggle showing hidden files.

If you still cannot find opencode.jsonc (the folder is empty or does not exist): the app has not auto-generated the config file yet, so create it manually.

macOS / Linux

Open a terminal, paste the following two lines and press Enter after each:

mkdir -p ~/.config/opencode
touch ~/.config/opencode/opencode.jsonc

Then open the folder as described above and you will see the newly created empty opencode.jsonc.

Windows

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.jsonc"

Then open the folder as described above and you will see the newly created empty opencode.jsonc.

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#

macOS

Right-click opencode.jsonc → "Open With" → choose "TextEdit".

Windows

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

Linux

Right-click opencode.jsonc → "Open With" → choose a plain text editor (e.g. gedit, Kate, Text Editor, depending on your desktop environment). Or open it directly with an editor in the terminal, for example:

nano ~/.config/opencode/opencode.jsonc

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

5. Edit the content#

Change the file content to the following (you can copy and paste the whole block to overwrite):

{
  "$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-5.5": { "name": "GPT-5.5" }
      }
    },
    "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-4-8": { "name": "Claude Opus 4.8" }
      }
    }
  }
}

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#

macOS

Press Cmd + S to save. If TextEdit asks about the format, choose "Use Plain Text".

Windows

Press Ctrl + S to save.

Linux

Press Ctrl + S to save. If you are using nano, press Ctrl + O then Enter to save, then Ctrl + X to exit.

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

7. Reopen OpenCode#

After reopening the app, you will see two models in the model selection menu:

  • MyAI168 → GPT-5.5
  • MyAI168 Claude → Claude Opus 4.8

Choose either one to start using it.

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).
  • Do not use the in-app "Custom provider" interface to reconfigure, otherwise it may overwrite this carefully tuned config file.
‹ Previous page: API PricingNext page: OpenClaw ›
↑

Other FAQ pages

General FAQ

  • FAQ
  • Account
  • Features
  • Privacy

API Documentation

  • OpenAI ChatGPT API
  • Anthropic Claude API
  • Google Gemini API
  • Google News API
  • OpenRouter API
  • API Pricing

CLI & Agent Guides

  • OpenClaw
  • Hermes Agent
  • Claude Code CLI
  • Codex CLI

MYAI168 API & MCP

  • MYAI168 MCP CLI
  • MYAI168 MCP Web & App