A native Rust provider plugin for zcalld. The dynamic library supplies the gateway's provider transport. The companion command signs in with OAuth Authorization Code and S256 PKCE, lists the authorized model catalog, and revokes authorization. Both use the same explicit local account. Native credential storage is implemented on Unix.
The live api.lmm.best issuer currently does not advertise the dedicated lmm-zcalld OAuth client. Login needs the LMM issuer's client registration and an enabled budget policy. The command reports a missing registration during discovery. The loopback TLS fixture exercises the client without a real account or paid requests.
cargo build --locked --release
target/release/lmm-oauth login "$HOME/.config/zcalld/lmm-accounts" work
target/release/lmm-oauth catalog "$HOME/.config/zcalld/lmm-accounts" workOpen the URL printed by the login command in your browser. The command listens only on IPv4 loopback and accepts a callback with the expected host, state and issuer. Each account is stored under the supplied directory with private Unix permissions. To revoke the account, use logout with the same directory and name. All these commands accept an optional final issuer argument. The default is https://api.lmm.best.
The catalog command fills missing capability fields from the current models.dev catalog. Exact model IDs and aliases take precedence over normalized names and unambiguous dated snapshots. The catalog keeps the authorized model and group IDs as issued by LMM, including when reference metadata is unavailable. metadata.context_window is the default planning window, set to half of metadata.max_context_window and bounded by a known input limit. Configure your chat client's context budgeting with that value when needed. zcalld's native provider interface receives completed request bodies and does not manage conversation budgeting.
Add the native plugin to the zcalld configuration. Replace the paths with absolute paths on your machine and CATALOG_MODEL_ID with the exact lmm:… identifier from catalog.
[plugin lmm-oauth]
path = /absolute/path/target/release/liblmm_oauth.so
provider_id = lmm-oauth
config = {"issuer":"https://api.lmm.best","accounts_dir":"/absolute/path/lmm-accounts"}
[provider lmm]
base_url = https://api.lmm.best/v1
protocol = chat
plugin = lmm-oauth
plugin_account = work
[route work-model]
provider = lmm
model = CATALOG_MODEL_IDUse protocol = chat, responses, or anthropic according to the model's corresponding advertised API. The gateway sends its configured model and protocol to the plugin. For every request, the plugin checks that exact pair against the account-scoped catalog, substitutes the upstream model ID and sends the catalog's group header. When LMM advertises gateway_max_output_tokens, it caps an explicit requested output length. Catalog discovery adds one upstream request per generation. Generation requests follow the gateway deadline, support bounded streaming and terminate on cancellation. The plugin disables redirects and automatic retries. The local refresh journal records a one-shot token before exchange so an ambiguous failure is resolved by signing in again.
cargo test --locked
cargo clippy --locked --all-targets -- -D warnings
python3 scripts/test-native.py \
--auth target/debug/lmm-oauth \
--plugin target/debug/liblmm_oauth.so \
--zcalld /absolute/path/zcalldThe integration test needs Python 3, OpenSSL, and a zcalld build with native named-provider dispatch. It creates its own CA and OAuth fixture on loopback. It tests issuer refusal, callback state and PKCE, account refresh, catalog validation, model/group relay and streamed completion.
Pass --require-models-dev to also verify live public metadata and the default context window without using a real OAuth account or a paid model request.
Licensed under AGPL-3.0-only. See LMM OAuth contracts and the OpenCode/Magpie LMM plugin for the related wire protocol and host adapters.