Skip to main content

grayling (Python)

Word suggestions as you type, in about 200 languages, on your own computer: the rest of the word being typed, the next one, and the right word for one typed wrong. This is the Python package of Grayling: the Rust engine in your process (PyO3, one wheel for every Python from 3.9 on), and a client of the engine host that the apps share.

pip install grayling
python -m grayling download          # the small model, about 314 MB, once
python -m grayling try "Please let me know if you have any ques"
'Please let me know if you have any ques'
   word='tions.'  confidence=0.48  needed=0.24  show=True
   next word=' Thanks.'  show=False

Nothing you type leaves your computer. The wheel has no network code at all; download() is a few lines of Python's urllib, and it is the only thing in the package that opens a connection (to huggingface.co, once, for the model).

The engine, in your process

from grayling import Engine, download

engine = Engine.load(download())          # a release folder; download() makes (or finds) the pinned one
a = engine.suggest({"surface": "text", "text": "Please let me know if you have any ques", "precision": 0.3})
a["word"], a["show"]                      # ('tions.', True)

# the same, with keyword arguments; None leaves a field out
a = engine.suggest(text="I will definately ", fix=True, after=None, precision=0.2)
a["fix"]                                  # {'back': 11, 'typed': 'definately', 'word': 'definitely', 'conf': 0.95}

A request and its answer are dicts of the engine's own JSON (api.rs, typed in grayling.types). word is what to add after the cursor (the rest of the word being typed; when the text ends in a space, the next word); next is the word after it; conf is the chance that word is right and theta the chance it needs; show says whether it is sure enough. precision is the share of shown suggestions meant to be right (0.2 shows more, 0.5 fewer and surer ones). A field that does not exist (presicion) is an error, not ignored.

Engine.load(path, personal=None, llm_url=None, threads=0, fix=True, word_conf="marg") loads a release folder. personal: a personal model's folder, loaded beside it. llm_url: llama.cpp's llama-server with Qwen3.5-0.8B-Base (http://127.0.0.1:8080), mixed in word piece by word piece; without it the small model answers alone (about 30 ms). threads=0: from the computer's cores. words=FILE: a word list (training/scripts/build_wordlist.py); a request with words={} then chooses the word among the listed words that begin with the letters typed (min_prefix, m, lam, weigh, budget; docs/suggestions.md)
engine.suggest(request=None, /, **fields) the suggestion
engine.session("chat-1", ["earlier text", …], own=[True, …]) the earlier texts of a chat, for requests with "session": "chat-1" (surface="chat")
engine.encode(text), engine.percentile(0.5), engine.set_llm(url) Qwen token ids; the median request time in ms; another language model
engine.model, .loaded, .pinned, .requests, .llm_error, .calibration what is loaded and how it went

Engine.load lets go of Python's lock while it loads, and so does suggest: threads can use one engine, and a second thread waits its turn. The engine answers one request at a time.

The thresholds. On the pinned release (the one download() fetches, found by its calibration.json) the thresholds are the ones measured for it, for word_conf="marg" (how sure the whole word is, over all its spellings: what the apps use) and for "greedy" (along the decoded tokens: what the model card prints). They live in one place, crates/grayling-pins, and grayling.pins() shows them. For another folder, "marg" has no thresholds of its own: give calibration_marg={plan: {precision: threshold}}, or use word_conf="greedy" (the folder's own calibration.json).

The engine host

On a computer with the Grayling app (or anything else that uses Grayling) there is one engine host that all of them share, so the model is in memory once, learns from everything the person writes, and has the person's settings. Client talks to it (docs/protocol.md); it needs the grayling program (the apps carry it; npm i grayling, a release archive, or cargo install; found as GRAYLING_BIN, then <data>/bin/<version>/, then the PATH, see grayling.find_program()).

from grayling import Client

with Client.connect() as c:                # starts the host when it is not running (start=False: only connect)
    a = c.suggest(text="Please let me know if you have any ques", precision=0.3)   # None while the host is starting
    c.state()["status"]["state"]           # 'ready'
    c.set(llm="off", threads=2)            # settings are shared by every program
    c.usage({"shown": 3, "taken": 1})      # counts of what was shown and taken; never any text

suggest gives None when there is nothing to give (the host is starting, or off, or a newer request of the same tab replaced this one); suggest_raw says why. Also warm(), state(), set(), session(), usage(), keep(word), info(), stop(), and request(op, **fields) for anything else in the protocol. An error answer is a HostError with a code; no host, a closed connection or no answer in time is a HostUnavailable.

Downloading

path = download()                          # the pinned small model → the cache folder the host uses
path = download(llm=True, quant="q8",      # and Qwen3.5-0.8B-Base as GGUF (834 MB; "q4": 563 MB) for llama-server
                progress=lambda done, total, name: print(done, total, name))

It goes to the same folder as the host's (GRAYLING_HOME, ~/.cache/grayling, ~/Library/Caches/Grayling, %USERPROFILE%\.grayling\cache), so a host finds what Python fetched and the other way round. Every file's size and SHA-256 are checked against the pins (which come from the extension, so there is one list), a download that stopped is resumed, and what is there is not fetched again. Only https is used (and plain http to this computer, for tests); HF_ENDPOINT names a mirror. The language model also needs llama.cpp's llama-server, which the grayling program fetches (grayling setup).

asyncio

Everything blocks, and the engine and the client let go of the interpreter's lock, so call them in a thread:

answer = await asyncio.to_thread(engine.suggest, text=text, precision=0.3)
path = await asyncio.to_thread(download)

What is not in the wheel

python/grayling_train in the repository is how the engine host learns from a person's writing (PyTorch, started by the host in a Python of its own). It is not part of this package and needs nothing from it.

Building and testing

uv venv .venv && . .venv/bin/activate && uv pip install maturin pytest
maturin develop --release                 # needs Rust (rust-toolchain.toml) and nothing else: no C compiler
GRAYLING_TEST_PROGRAM=../../target/debug/grayling pytest        # after `cargo build -p grayling-host` at the top

The crate is outside the Cargo workspace (it needs Python's headers), with a Cargo.lock of its own. The tests run the tiny golden models against the Python engine's answers, two threads at once, errors, the client against a fake host and (with GRAYLING_TEST_PROGRAM) the real program with GRAYLING_FAKE=1, and download() against a local server. Where the real release is on the computer (GRAYLING_REAL_RELEASE, GRAYLING_REAL_JSON) they also check the model card's seven texts and the Python engine's answers on real requests.

Wheels (.github/workflows/release.yml): manylinux 2014 and musllinux 1.2 for x86_64 and aarch64, macOS 11+ (arm64, x86_64), Windows (x64, arm64), and the sdist. Licence: AGPL-3.0-only, as the rest of Grayling.

Metadata

Release files for grayling 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grayling 0.1.11
File Size Uploaded Provenance Actions
grayling-0.1.11.tar.gz 290.8 kB With provenance Details for grayling-0.1.11.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for grayling 0.1.11
File Actions
grayling-0.1.11-cp39-abi3-win_arm64.whl CPython 3.9 abi3 Windows ARM64 Details for grayling-0.1.11-cp39-abi3-win_arm64.whl
grayling-0.1.11-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for grayling-0.1.11-cp39-abi3-win_amd64.whl
grayling-0.1.11-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for grayling-0.1.11-cp39-abi3-musllinux_1_2_x86_64.whl
grayling-0.1.11-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details for grayling-0.1.11-cp39-abi3-musllinux_1_2_aarch64.whl
grayling-0.1.11-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for grayling-0.1.11-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
grayling-0.1.11-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for grayling-0.1.11-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
grayling-0.1.11-cp39-abi3-macosx_11_0_x86_64.whl CPython 3.9 abi3 macOS 11.0+ x86-64 Details for grayling-0.1.11-cp39-abi3-macosx_11_0_x86_64.whl
grayling-0.1.11-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for grayling-0.1.11-cp39-abi3-macosx_11_0_arm64.whl

Total release size: 19.7 MB

Release files / grayling-0.1.11.tar.gz

Download URL grayling-0.1.11.tar.gz
Size 290.8 kB
Tags Source
SHA-256 checksum
How to use checksums
39fb84f1d15e6f5cab361b01721a2dcd1cf0caed0e47636fc26b5d95c884db7f
BLAKE2b-256 checksum
How to use checksums
aca42efcdc45f0c513dcd4743d9280e50372fd0da168118bca37393e648025ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / grayling-0.1.11-cp39-abi3-win_arm64.whl

Download URL grayling-0.1.11-cp39-abi3-win_arm64.whl
Size 2.3 MB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
f54e99b854711d2f866a9dddd8a441e7d1adb40360f5d7b6cd566d9dbf4bcfa4
BLAKE2b-256 checksum
How to use checksums
2abce2efaa2227c5de5816b116600b92188ab56438df9ee3c901d565e88f3999
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / grayling-0.1.11-cp39-abi3-win_amd64.whl

Download URL grayling-0.1.11-cp39-abi3-win_amd64.whl
Size 2.5 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c14477aec9f8c6a44b046c3bca7b8bac84fefc2085d6b1021ff3b6615164e9e2
BLAKE2b-256 checksum
How to use checksums
506a331b097a5d8f7e3ca21d2daac8062b837c1e7a73e2fdb3975f37f4de1f1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / grayling-0.1.11-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL grayling-0.1.11-cp39-abi3-musllinux_1_2_x86_64.whl
Size 2.7 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
c627c8c68c985233f86554c7d8297d0b9fa0f2aea03a90baac9bf97cb6d78c47
BLAKE2b-256 checksum
How to use checksums
bf7bb5fefd302fdd7aace91b821fadd88b5dc230eba554506e480ed9c131c551
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / grayling-0.1.11-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL grayling-0.1.11-cp39-abi3-musllinux_1_2_aarch64.whl
Size 2.5 MB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
cbe48402ff8dcc648f0c648751f725a7ca683b8d5e707c8c38937f0f03e03261
BLAKE2b-256 checksum
How to use checksums
ed4ceac9344ce118f22774ea80d9bbaacb6f4bdc714a5522ca8bad7101e6b6d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / grayling-0.1.11-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grayling-0.1.11-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 2.5 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
0b1fff438b479033bb65d13eb749f6d8a4070c3e1170045573563d3a42c328d2
BLAKE2b-256 checksum
How to use checksums
cd6834279c73527cd753c46e3461bbf98df0eee3d1c9784e4a74559e2c33a237
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / grayling-0.1.11-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grayling-0.1.11-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 2.3 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
f61d58f33fde9f7fba9ba942165cabb120b018335b17415afbf766d8d1b8af2e
BLAKE2b-256 checksum
How to use checksums
3725c463007d9d7f6db8f90828289677b4b661533ab70e331afc4cb31497deb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / grayling-0.1.11-cp39-abi3-macosx_11_0_x86_64.whl

Download URL grayling-0.1.11-cp39-abi3-macosx_11_0_x86_64.whl
Size 2.3 MB
Tags CPython 3.9 abi3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
85bcccb1c4535fe6d6f83cd5ea79f8de8aed5c1f778fd25e4dc5d45c13f29da5
BLAKE2b-256 checksum
How to use checksums
f7a78f926ef6e7aa504d8d76636b097b80648cb11b529dbf720fafa4b1c221ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / grayling-0.1.11-cp39-abi3-macosx_11_0_arm64.whl

Download URL grayling-0.1.11-cp39-abi3-macosx_11_0_arm64.whl
Size 2.2 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a958b34e75040ae844696f14c9ccbcb163844f1b0a7b958e959bf9efee2d2b64
BLAKE2b-256 checksum
How to use checksums
d2bd4a4a7bd8da87198e604a5451fc2ec8f63d7cf605304f8b234cacee8e2add
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Security for grayling 0.1.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 9 files in this release have been uploaded with provenance metadata.

Select from 9 files

Attestation for grayling-0.1.11.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page