Skip to main content

Sync opencode config with models served by a vLLM/llama.cpp server

Project description

opencode-sync

Keep opencode's model list in sync with your local vLLM or llama.cpp server.

When you swap models on your inference server, opencode-sync queries /v1/models, updates opencode.jsonc, and preserves any display names you've customised. Run it once manually, or install the shell wrapper so it happens automatically every time you start opencode.

Requirements

  • Python 3.8+
  • No runtime dependencies (pure stdlib)

Install

pip install opencode-sync

Or from source:

git clone https://github.com/<you>/opencode-sync
cd opencode-sync
pip install -e .

Usage

Sync against the URL already in your config (never changes the stored URL — safe to run any time):

opencode-sync

Point at a specific server and update the stored URL:

opencode-sync --host llm-server.local --port 8000

Preview changes without writing anything:

opencode-sync --dry-run

Auto-sync on every opencode launch

Install a shell wrapper once:

opencode-sync install

This writes ~/.local/bin/opencode — a small script that runs opencode-sync silently, then execs the real opencode binary. opencode always starts with a fresh model list, and still launches normally if the inference server is unreachable.

Make sure ~/.local/bin is earlier in your $PATH than the real opencode binary. The installer warns you if it isn't.

opencode-sync install [--wrapper PATH] [--opencode-bin PATH] [--force] [--dry-run]

How it works

On each run, opencode-sync:

  1. Fetches the live model list from GET /v1/models
  2. Rebuilds provider.models — existing IDs keep their current display name; new IDs get a generated name from the model ID
  3. If model or small_model in your config is no longer served, updates it to the first available model
  4. Writes the updated config

The model/small_model fields are always written in opencode's expected provider/model-id format (e.g. vllm/org/model-name), so opencode resolves them correctly.

URL behaviour

Invocation Server queried baseURL in config
opencode-sync Existing baseURL (fallback: localhost:8000) Unchanged
opencode-sync --host X http://X:8000/v1 Updated
opencode-sync --host X --no-url-update http://X:8000/v1 Unchanged

Display names are preserved

// Before sync
"models": { "org/Qwen3-27B": { "name": "My Qwen label" } }

// After sync (model still served)
"models": { "org/Qwen3-27B": { "name": "My Qwen label" } }  // kept

All options

opencode-sync [--host HOST] [--port PORT] [--provider ID] [--config PATH]
              [--dry-run] [--no-url-update] [--no-model-update] [--timeout SECONDS]
Flag Default Description
--host HOST from config vLLM server hostname
--port PORT from config vLLM server port
--provider ID auto-detect Provider key to update (required only with multiple providers)
--config PATH auto-detect Path to opencode.jsonc
--dry-run off Show changes without writing
--no-url-update off Don't update baseURL even when --host/--port is given
--no-model-update off Don't update model/small_model if the active model is removed
--timeout SECONDS 10 HTTP request timeout

Config file locations

Auto-detected in this order:

Platform Paths checked
Linux $XDG_CONFIG_HOME/opencode/opencode.jsonc, ~/.config/opencode/opencode.jsonc
macOS XDG paths above, then ~/Library/Application Support/opencode/opencode.jsonc
Windows %APPDATA%\opencode\opencode.jsonc, %LOCALAPPDATA%\opencode\opencode.jsonc, ~/.config/…

Override on any platform with --config PATH.

Development

pip install -e ".[dev]"
python -m pytest                      # 113 tests
python -m pytest --cov=opencode_sync  # with coverage

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opencode_sync-0.1.0.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opencode_sync-0.1.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file opencode_sync-0.1.0.tar.gz.

File metadata

  • Download URL: opencode_sync-0.1.0.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for opencode_sync-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6181b607ff428cdc65458fe9a02e148f928fd95af18995cf2f1f7128ffe9d58b
MD5 bf30980b0c4bfc996fa302d5bfd88954
BLAKE2b-256 d3625c4b407e411c077984e836137465fbf2874d82182f6e5c3ef1801e8a36f7

See more details on using hashes here.

File details

Details for the file opencode_sync-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: opencode_sync-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for opencode_sync-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d4bf6895aaf0324962f1064045067c9a771ba9c6092e3cf2627ad49663bf0eb
MD5 4b60254e22b4ac4a93b3d851cde23e1f
BLAKE2b-256 8cff641d0d7e951f06265efb567926360234b2f7794df7c09559922d95d38354

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page