This guide explains how to install OpenCode on macOS 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.
If OpenCode is not installed yet, open Terminal and run one of the following (official docs: https://opencode.ai/docs/):
# Option 1: official install script (recommended)
curl -fsSL https://opencode.ai/install | bash
# Option 2: Homebrew (recommended tap, most up to date)
brew install anomalyco/tap/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.
Always quit the app before editing, otherwise your changes may be overwritten by the old settings.
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).
The config file is named opencode.json and lives in a hidden directory inside your user home folder.
open ~/.config/opencode/
Finder 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 Finder 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 a terminal, paste the following two lines and press Enter after each:
mkdir -p ~/.config/opencode
touch ~/.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.
Right-click opencode.json → "Open With" → choose "TextEdit".
* 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.
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-5.6-sol": { "name": "GPT-5.6 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-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.
Press Cmd + S to save. If TextEdit asks about the format, choose "Use Plain Text".
* Note: after saving, make sure the file name is still opencode.json and the extension has not been changed to .txt.
After reopening the app, you will see two models in the model selection menu:
Choose either one to start using it.
/openai/v1 and the Claude one ends with /anthropic/v1. Do not unify or change them.models block following the existing format (remember to add a comma at the end of the previous line)./connect command inside OpenCode (credentials are saved to ~/.local/share/opencode/auth.json, not in the config file), then configure the provider in the config. Either approach works; if you use /connect, you can omit the apiKey field from options in the config.