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:
- Fetches the live model list from
GET /v1/models - Rebuilds
provider.models— existing IDs keep their current display name; new IDs get a generated name from the model ID - If
modelorsmall_modelin your config is no longer served, updates it to the first available model - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5714f174ce6e596e8f7585838aaabc640a62d3e23c30f99df0315b7f20f20fff
|
|
| MD5 |
70e15152ee590cf4df2938806a8812cd
|
|
| BLAKE2b-256 |
9f8ac1b6523ffe3ecf362347037c9eb389916bb774177351baba73ce7e1cc0f2
|
Provenance
The following attestation bundles were made for opencode_sync-0.1.1.tar.gz:
Publisher:
release.yml on ozskywalker/opencode-sync
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opencode_sync-0.1.1.tar.gz -
Subject digest:
5714f174ce6e596e8f7585838aaabc640a62d3e23c30f99df0315b7f20f20fff - Sigstore transparency entry: 1608910110
- Sigstore integration time:
-
Permalink:
ozskywalker/opencode-sync@e1ca9ef86873582eeecccd24acc55017853f2fb9 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ozskywalker
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e1ca9ef86873582eeecccd24acc55017853f2fb9 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfd837ec2ebbb7947911fef25a9c1acea2cda95d562cf040d3615d415ad74d59
|
|
| MD5 |
53eb62b30c4b85ee9fb369deb5792fe0
|
|
| BLAKE2b-256 |
06df833baa70fbdee4e37ac55c57b9b383a469602d8cbcbf88795aa5cc7ee17c
|
Provenance
The following attestation bundles were made for opencode_sync-0.1.1-py3-none-any.whl:
Publisher:
release.yml on ozskywalker/opencode-sync
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opencode_sync-0.1.1-py3-none-any.whl -
Subject digest:
cfd837ec2ebbb7947911fef25a9c1acea2cda95d562cf040d3615d415ad74d59 - Sigstore transparency entry: 1608910244
- Sigstore integration time:
-
Permalink:
ozskywalker/opencode-sync@e1ca9ef86873582eeecccd24acc55017853f2fb9 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ozskywalker
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e1ca9ef86873582eeecccd24acc55017853f2fb9 -
Trigger Event:
push
-
Statement type: