Skip to main content
Glama
README.md
<p align="center">
  <a href="https://zils.ai">
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset=".github/assets/zils-wordmark-periwinkle.svg">
      <img alt="Zils" src=".github/assets/zils-wordmark-purple.svg" width="200">
    </picture>
  </a>
</p>

<p align="center">
  <strong>Small models for the decisions your app asks an LLM to make.</strong><br>
  Yes or no, pick one of a list, a score: Zils answers with a probability,<br>
  and you can train your own model on your data.
</p>

<p align="center">
  <a href="https://github.com/ooo-hq/zils-sdk/actions/workflows/checks.yml"><img alt="Checks" src="https://github.com/ooo-hq/zils-sdk/actions/workflows/checks.yml/badge.svg?branch=main"></a>
  <a href="https://www.npmjs.com/package/@zils/cli"><img alt="@zils/cli on npm" src="https://img.shields.io/npm/v/@zils/cli?label=%40zils%2Fcli&color=4b44c8"></a>
  <a href="https://www.npmjs.com/package/@zils/sdk"><img alt="@zils/sdk on npm" src="https://img.shields.io/npm/v/@zils/sdk?label=%40zils%2Fsdk&color=4b44c8"></a>
  <a href="https://registry.modelcontextprotocol.io/v0/servers?search=ai.zils/zils"><img alt="MCP Registry: ai.zils/zils" src="https://img.shields.io/badge/MCP%20Registry-ai.zils%2Fzils-8f88ff"></a>
  <a href="LICENSE"><img alt="MIT licence" src="https://img.shields.io/badge/licence-MIT-ff7a2f"></a>
</p>

<p align="center">
  <a href="https://zils.ai">Website</a> ·
  <a href="https://docs.zils.ai">Docs</a> ·
  <a href="https://docs.zils.ai/getting-started/quickstart">Quickstart</a> ·
  <a href="https://zils.ai/playground">Playground</a> ·
  <a href="docs/developer-tools.md">SDK guide</a> ·
  <a href="https://discord.gg/a9PJ9wchGK">Discord</a> ·
  <a href="https://github.com/ooo-hq/zils-sdk/issues">Issues</a>
</p>

This repository holds the `zils` command, the Python and TypeScript clients, and
an MCP server for coding agents.

| Package | What it is | Install | Source |
|---|---|---|---|
| [`@zils/cli`](https://www.npmjs.com/package/@zils/cli) | `zils` command and MCP server | `npm install -g @zils/cli` | [packages/cli](packages/cli) |
| [`@zils/sdk`](https://www.npmjs.com/package/@zils/sdk) | TypeScript/JavaScript client | `npm install @zils/sdk` | [packages/typescript](packages/typescript) |
| `zils-sdk` | Python client, CLI and MCP server | from this repository ([below](#install)) | [packages/python](packages/python) |

**Contents:** [Where Zils fits](#where-does-zils-fit-in-your-code) ·
[Replace a classifier prompt](#replace-a-classifier-prompt) ·
[Train your own model](#train-your-own-model) ·
[Merge models](#merge-models-on-your-machine) ·
[Rank](#rank-a-short-list) · [MCP](#use-from-an-agent-mcp) ·
[Install](#install) · [Mining](#mining) · [Development](#development)

## Where does Zils fit in your code?

Paste this into Claude Code, Cursor or Codex in your project:

> Use `npx -y @zils/cli fit agent` to install the Zils skill, then see where Zils fits in this repo.

The agent finds the model calls in your code that make a decision rather than
write text, writes test cases from your app's own rules, asks Zils, and reports
what Zils would handle and where it disagrees. You only approve the Zils sign-in
in your browser.

To do it yourself, run `zils fit` in your project. `zils fit scan` lists the
calls, `record` logs what they receive and answer in normal use, and
`zils fit run` replays that log on Zils to show how much of the traffic it can
take. See [zils fit](docs/fit.md).

## Replace a classifier prompt

A typical LLM decision is a prompt and a string to parse:

```python
reply = openai.chat.completions.create(
    model="...",
    messages=[{"role": "user", "content": f"Does this customer want a refund? Answer yes or no.\n\n{ticket}"}],
)
wants_refund = reply.choices[0].message.content.strip().lower().startswith("yes")
```

With Zils the question is typed and the answer is a probability:

```python
from zils_sdk import Choice, Noul, ZilsClient

with ZilsClient() as client:
    result = client.system_one(
        state={"message": ticket},
        questions={
            "refund": Noul(instructions="Does the customer request a refund?"),
            "team": Choice(
                instructions="Which team?",
                criteria={"billing": "Payment problems", "support": "Product help"},
            ),
        },
    )
wants_refund = result.nouls["refund"].noul > 0.5  # probability of yes
team = result.choices["team"].choice
```

The same call in TypeScript:

```ts
import { ZilsClient, choice, noul } from '@zils/sdk';

const client = new ZilsClient();
const result = await client.systemOne({
  state: { message: ticket },
  questions: {
    refund: noul('Does the customer request a refund?'),
    team: choice('Which team?', { billing: 'Payment problems', support: 'Product help' }),
  },
});
```

Set `ZILS_API_KEY` on your server (create a key in the Zils dashboard). Questions
use `noul` (yes/no), `choice` and `score`. See the
[developer guide](docs/developer-tools.md) for every option.

## Train your own model

When the shared model is not accurate enough on your question, train one on your
labeled examples:

```sh
# Sign in with your browser
zils login

# What to decide before you train
zils train guide

# Split your labeled export into train, calibration and test files
zils train prepare tickets.csv \
  --decide team --read message --group customer_id \
  --out data

# Start the training job
zils train submit --name ticket-routing \
  --train data/train.jsonl \
  --calibration data/calibration.jsonl \
  --test data/test.jsonl \
  --min-accuracy 0.8 --min-brier-improvement 0.01 \
  --allow-training-data-export

# Follow the job
zils train status JOB_ID --watch
```

`prepare` turns a CSV or JSON export into the three training files. Submitting
uses your account's training credit. See the [training guide](docs/training-cli.md).

## Merge models on your machine

`zils merge` blends 2–5 fine-tunes of the same base model into a new model
folder: a soup, like the one the Zils network builds every day. Each model is a
local folder or a Hugging Face repo id. Nothing is uploaded, hosted or scored,
and it needs no account:

```sh
zils merge vllm-sr/d3-lite eljiwo/jiwo-0.8b cribl-ai/cribl-decision-2-0.8B --out ./my-soup
zils merge ./model-a ./model-b ./model-c --weights 2,1,1 --out ./my-soup
zils merge ./model-a ./model-b --method slerp --weight 0.3 --out ./my-mix
```

- By default every model gets an even portion. `--weights` sets portions in
  order (normalised to sum to one); with two models, `--weight` is the second
  model's share.
- `--method slerp` follows the arc between exactly two models.
- The output keeps the first model's files and layout (config, tokenizer, any
  answer layer), and `merge.json` records the recipe. Every other model's
  licence is copied as `LICENSE-model-2`, `LICENSE-model-3`, …; check them
  before you share the result.
- Weight names line up across `model.` and `model.language_model.` prefixes,
  so text-only fine-tunes merge into a multimodal model. Weights not every
  model has are kept from the first. Other models' extra output heads
  (`mtp.*`, `lm_head`) and vision towers are ignored when the first model has
  none, so a d3 model merges with its Qwen base.
- Hugging Face models download into `zils/models` in your cache folder,
  resume if interrupted, and are checked against the Hub's SHA-256.
  Set `HF_TOKEN` for gated or private models.
- It refuses models whose shapes differ, weights the first model lacks, and
  repeated or identical models.

### Submit a merge to a network pool

To submit the result to a soup pool, add `--pool d3-lite` (or `d3-mini`): with
the Zils miner installed, the miner's body check runs on the new folder and says
whether it is a valid soup body, and why not. A body must be the full Qwen3.5
model with its vision tower, so list a full checkpoint (such as
`vllm-sr/d3-lite`) first; a merge of text-only exports alone needs the Qwen
parent's vision tower added before it can be a body. A mix of listed public
models is paid the scout rate, not the trainer rate.

To submit a text-only public fine-tune (such as a listed cousin) as a body, give
its Qwen parent a zero portion. The result has the cousin's exact language
weights and the parent's unchanged vision tower; edit the copied README to
credit the cousin before you upload it:

```sh
zils merge Qwen/Qwen3.5-0.8B cribl-ai/cribl-decision-2-0.8B --weights 0,1 --pool d3-lite --out ./cribl-body
```

## Rank a short list

`rank(...)` orders 2–10 JSON items against a criterion using Choice decisions,
comparing each pair in both orders and fitting relative strengths locally.
`group_size=4` (Python) or `groupSize: 4` (TypeScript) uses overlapping groups
instead: 10 judgments for 10 items rather than 90. Ranking is experimental:
scores are relative strengths, and accuracy needs task-specific evaluation. See
the [ranking guide](docs/developer-tools.md#ranking).

## Use from an agent (MCP)

```sh
claude mcp add zils -- npx -y @zils/cli mcp
```

The server is listed in the official MCP Registry as `ai.zils/zils`. See the
[CLI package guide](packages/cli/README.md) for other agents.

## Install

The CLI needs Node.js 20+ and Python 3.11+:

```sh
npm install -g @zils/cli    # or run any command with npx @zils/cli
npm install @zils/sdk       # TypeScript/JavaScript client
```

First use of the CLI sets up its bundled Python code in a private cache;
dependencies come from PyPI. The Python SDK installs from this repository:

```sh
python -m pip install "./packages/python[mcp]"
```

Automatic retries are off: a request whose reply is lost may already have been
billed. Browser sign-in (`zils login`) is for training; inference uses API keys,
and signing in does not create one.

## Mining

Miners use the same `zils` command: `zils setup`, `zils doctor`,
`zils commit-candidate` and the other miner commands run `zils-miner` from the
Zils miner install (`curl -fsSL https://zils.ai/install.sh | sh`, a separate
GPU-side install from the [Zils repository](https://github.com/ooo-hq/zils)).
Without it, those commands print the install line; `zils --help` lists both
groups.

## Development

```sh
python -m pip install -r requirements/dev.txt "./packages/python[mcp,merge]"
npm ci --prefix packages/typescript
make check PYTHON=python
```

`make check` runs ruff (lint and format) on the Python and CLI code, the
TypeScript tests, and the Python suite in [`packages/python/tests`](packages/python/tests):
the clients, CLI, MCP protocol, `fit`, `merge`, ranking and training commands,
against local HTTP fixtures. It sends no hosted requests and uses no credit.
[CI](.github/workflows/checks.yml) runs the same checks on every pull request,
then builds the Python package and tests the installed npm CLI
([`packages/cli/test`](packages/cli/test)).

## Community and support

- [Discord](https://discord.gg/a9PJ9wchGK): questions, ideas and announcements
- [GitHub issues](https://github.com/ooo-hq/zils-sdk/issues): bugs and feature requests for the SDK, CLI and MCP server
- [Contact form](https://zils.ai/contact): accounts, billing and anything private
- [X (@zils_ai)](https://x.com/zils_ai): news

## Related

- [Zils](https://github.com/ooo-hq/zils): models, miners and validators
- [zils-agent-skills](https://github.com/ooo-hq/zils-agent-skills): the Claude Code and Cursor plugin
- [zils-docs](https://github.com/ooo-hq/zils-docs): the source of [docs.zils.ai](https://docs.zils.ai)
- [zils-brand](https://github.com/ooo-hq/zils-brand): logos and colors

## Licence

MIT. Each package carries its licence and a `THIRD_PARTY_NOTICES.md` for adapted
code.