OpenCode

How to fix an invalid OpenCode opencode.json

Confirm the file path, then validate the complete JSON without deleting unrelated Providers to force it to parse.

Start with these checks

OpenCode cannot parse the current configuration file.

  • Startup reports a JSON parse error, or /models does not change after saving.
  • A comma or bracket was lost while merging
  • Back up the current opencode.json
JSON parse error

01

Confirm the symptom

A JSON parse error or a config that never loads usually means the file was not parsed.

02

Repair the config in order

Back up and validate the whole file, then merge both top-level model and provider fields.

  1. 1Back up the current opencode.json
  2. 2Validate the complete file as JSON

03

Confirm recovery and prevent recurrence

The target Provider appears in /models after reopening; keep a backup and validate JSON after future edits.

  1. 1Validate the complete file as JSON
  2. 2Merge both model and provider from the generated content

If it is still not fixed

Sources

Reconfigure

Return to the integration center and continue the setup steps.

Return to the related setup step