Skip to main content

🧰 Check OpenCode Free Models

CI Python Dependencies Tests PyPI License

🌐 English · Türkçe

check-opencode-free-models is a tiny, dependency-free CLI that keeps the free chat models published by the OpenCode Console in sync with ~/.config/opencode/opencode.jsonc.

⚡ In one line: fetch → filter free chat models → diff against the config → optionally rewrite the block with a timestamped backup and an atomic write. Nothing else is read or written.


📖 Overview

Source Reference
📚 Free models documentation https://opencode.ai/docs/models/#free-models
🖥️ OpenCode Desktop https://opencode.ai/desktop
🌐 Live endpoint (no auth) https://opencode.ai/inference/v1/models

Filter rule: type == "chat" and cost.text.input.price == 0 and cost.text.output.price == 0. Decision models (type: decision, e.g. Jev) are never written to the opencode-api block; skipped free non-chat models are reported as a warning.

flowchart LR
    A["🌐 Live endpoint<br/>inference/v1/models"] --> B["🔍 Filter<br/>chat + zero cost"]
    B --> C["📄 Read config<br/>opencode-api.models"]
    C --> D{"Diff?"}
    D -->|"no drift"| E["✅ exit 0"]
    D -->|"drift"| F["⚠️ exit 1<br/>added / removed"]
    F --> G{"--apply?"}
    G -->|"no"| H["⏭️ report only"]
    G -->|"yes"| I["💾 backup + atomic rewrite<br/>validate-before-write"]
    I --> J["✅ exit 0 · APPLIED"]

✨ Features

  • 🔄 Drift detection — lists models to add / remove, exits 0 in sync and 1 on drift.
  • 🛡️ Safe apply — timestamped backup, JSONC-aware validation before writing, and an atomic os.replace write.
  • ♚ Idempotent — re-running --apply reports no drift.
  • 🎛️ Configurable — --config PATH or OPENCODE_CONFIG_PATH; endpoint via OPENCODE_MODELS_URL.
  • 🧪 44 tests, stdlib only — smoke / sanity / unit / regression / integration / e2e / UI, plus GitHub Actions CI.
  • 🌐 English + Türkçe docs.

🚀 Quick start

1. Requirements

Requirement Notes
Python 3.10+ (standard library only — no pip install needed)
Target OpenCode Desktop's own ~/.config/opencode/opencode.jsonc

2. Run

python3 check-opencode-free-models.py                  # drift report
python3 check-opencode-free-models.py --apply          # update, with backup
python3 check-opencode-free-models.py --dry-run        # report only, never write
python3 check-opencode-free-models.py --config PATH    # use another config file
python3 check-opencode-free-models.py --version        # print version and exit

3. Flags

Flag Effect
(none) Drift report; exit 0 in sync, 1 on drift. No writes.
--apply Rewrite the models block after backup + validation.
--dry-run Force report-only (overrides --apply).
--config PATH Override OPENCODE_CONFIG_PATH / default config path.
--version Print version, exit immediately.

4. Example output

live free chat models: 10
config models            : 10
to add     : -
to remove  : -
RESULT: in sync, no drift.

🧠 How it works

  1. 🔍 Fetch — fetch_free_ids() reads the endpoint (3 retries on transient failures). Only zero-cost chat models are kept.
  2. 📄 Read — read_config_models() parses the id → name map from provider.opencode-api.models.
  3. 🧮 Diff — compare live IDs with config IDs → added / removed.
  4. 🛡️ Apply (only with --apply):
    • timestamped backup opencode.jsonc.bak-YYYY-MM-DD-HH_MM_SS (shutil.copy2);
    • build_block() joins entries with commas (no trailing comma);
    • validate-before-write — the rewritten JSONC is normalized and parsed before the file is touched;
    • atomic write — temp file in the same directory + os.replace.

Existing name values are preserved on update. Idempotent: a second --apply reports no drift.


🗂️ What gets pulled from where

Source What Target
🌐 Live endpoint (no auth) Free chat models (type == "chat", zero input/output price) — id + name ~/.config/opencode/opencode.jsonc → provider.opencode-api.models
📄 Existing config Already-stored name values merged into the rewritten block
💾 --apply Rewrites the block; timestamped backup same file

The example config opencode-free-models.config.example.jsonc shows the shape of the opencode-api block (redacted, no secrets).


🤖 Current free chat models

As of 2026-11-24 the Console lists 10 free chat models (run the script to refresh — the live endpoint is the source of truth):

  • beam-free — Beam Free
  • big-pickle — Big Pickle
  • deepseek-v4.1-flash-free — DeepSeek V4.1 Flash Free
  • flint-40b-free — Flint 40B Free
  • hy4-flash-free — Hy4 flash Free
  • iceman-free — Iceman Free
  • mimo-v2.6-flash-free — MiMo-V2.6-Flash Free
  • nemotron-3.5-lightning-free — Nemotron 3.5 Lightning Free
  • nemotron-3.5-super-vl-free — Nemotron 3.5 Super VL Free
  • tidepool-alpha-free — Tidepool Alpha Free

⏰ Desktop & crontab

The tool targets OpenCode Desktop's own ~/.config/opencode/opencode.jsonc — it never touches any other config file. Apply updates with --apply, or run a daily drift check from crontab:

0 6 * * * /path/to/check-opencode-free-models/check-opencode-free-models.py

Exit codes: 1 on drift (RESULT: drift found. Update with --apply.), 0 when in sync (RESULT: in sync, no drift.).


📂 Project structure

check-opencode-free-models/
├── check-opencode-free-models.py         # working script (fetch · drift · apply · backup)
├── opencode-free-models.config.example.jsonc
├── README.md · README.tr.md              # this tour / Türkçe tur
├── CHANGELOG.md · SECURITY.md · CONTRIBUTING.md · LICENSE
├── pyproject.toml
├── .github/workflows/ci.yml              # py_compile + stdlib test runner
├── test/                                 # 7 suites + runners + README.md
│   ├── run-tests.py                      # importlib-based stdlib runner
│   ├── run-all-tests.sh                  # shell wrapper
│   ├── test-smoke.py · test-sanity.py · test-unit.py
│   ├── test-regression.py · test-integration.py
│   └── test-e2e.py · test-automated-ui.py
└── docs/
    ├── README.md
    └── testing/TESTING.md

🧪 Testing & CI

Standard-library-only automated suites under test/:

python3 test/run-tests.py               # all suites
./test/run-all-tests.sh unit            # one suite via shell wrapper

unittest discover cannot import hyphenated module names, so the runner loads each test-*.py file by path via importlib.

Suite File Focus
💨 Smoke test-smoke.py Compile, module load, JSONC basics.
✅ Sanity test-sanity.py Constants, example config, generated block.
🔬 Unit test-unit.py Pure functions with mocks; CLI flags.
🩹 Regression test-regression.py JSONC bug + apply idempotency.
🔗 Integration test-integration.py Local HTTP server + full pipeline.
🎯 E2E test-e2e.py Real CLI subprocess, isolated HOME.
🖥️ UI test-automated-ui.py Output, messages, exit codes.

Before a change: python3 -m py_compile check-opencode-free-models.py and the full suite above. CI runs both on every push and pull request.


📚 Documentation


🔮 Roadmap

  • ✅ Done: atomic write, robust type filter, decision-model WARN, env overrides, --dry-run, --config / --version, network retries, CI.
  • Remaining: recommended_api routing — the systemone endpoint currently returns 404.

📄 License

MIT — see LICENSE.

Metadata

Release files for check-opencode-free-models 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for check-opencode-free-models 1.0.4
File Size Uploaded Provenance Actions
check_opencode_free_models-1.0.4.tar.gz 13.4 kB Without provenance Details for check_opencode_free_models-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for check-opencode-free-models 1.0.4
File Interpreter ABI Platform Actions
check_opencode_free_models-1.0.4-py3-none-any.whl Python 3 none any Details for check_opencode_free_models-1.0.4-py3-none-any.whl

Total release size: 23.2 kB

Release files / check_opencode_free_models-1.0.4.tar.gz

Download URL check_opencode_free_models-1.0.4.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
686bf5b2f34197ccc607aff4c34a3d552fed51e3faa6db5c27b64ff823fca7a7
BLAKE2b-256 checksum
How to use checksums
fdac4437ac7e7851fc3c7353122d040a40057ee1165d39bc2f573bdc1c9a20f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / check_opencode_free_models-1.0.4-py3-none-any.whl

Download URL check_opencode_free_models-1.0.4-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a68c0ba0328ecee37f9537b549babbb8d3f11eb67c978a660ce566bf56b31d4
BLAKE2b-256 checksum
How to use checksums
9a1c6856786c20c530a7bdb309bb87d715d450d92843d17e4a0ab44b1d0608b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for check-opencode-free-models 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page