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/ozskywalker/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.1.tar.gz (21.3 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.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: opencode_sync-0.1.1.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for opencode_sync-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5714f174ce6e596e8f7585838aaabc640a62d3e23c30f99df0315b7f20f20fff
MD5 70e15152ee590cf4df2938806a8812cd
BLAKE2b-256 9f8ac1b6523ffe3ecf362347037c9eb389916bb774177351baba73ce7e1cc0f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for opencode_sync-0.1.1.tar.gz:

Publisher: release.yml on ozskywalker/opencode-sync

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: opencode_sync-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for opencode_sync-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cfd837ec2ebbb7947911fef25a9c1acea2cda95d562cf040d3615d415ad74d59
MD5 53eb62b30c4b85ee9fb369deb5792fe0
BLAKE2b-256 06df833baa70fbdee4e37ac55c57b9b383a469602d8cbcbf88795aa5cc7ee17c

See more details on using hashes here.

Provenance

The following attestation bundles were made for opencode_sync-0.1.1-py3-none-any.whl:

Publisher: release.yml on ozskywalker/opencode-sync

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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