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.
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:
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.
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).
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).
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
The config file is named opencode.jsonc and lives in a hidden directory inside your user home folder.
open ~/.config/opencode/
Finder will open that folder, and opencode.jsonc is inside it.
Win + R to open "Run".%USERPROFILE%\.config\opencode\
File Explorer will open that folder, and opencode.jsonc is inside it.
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.
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.
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.
Right-click opencode.jsonc → "Open With" → choose "TextEdit".
Right-click opencode.jsonc → "Open with" → choose "Notepad".
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.
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.
Press Cmd + S to save. If TextEdit asks about the format, choose "Use Plain Text".
Press Ctrl + S to save.
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.
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).