tokin makes any agent harness token-native. Train an agent in the harness it ships with, on exactly the tokens it sampled. Point the harness at tokin instead of the inference engine and nothing else changes: it keeps speaking text over chat completions, while the engine only ever sees token ids. tokin keeps each session as a tree of turns, so every rollout a trainer collects is token-in, token-out at every prefix.
Quick start
Serve a model with sglang, and put tokin in front of it, each in its own terminal:
pip install tokin
python -m sglang.launch_server --model-path Qwen/Qwen3.5-0.8B --port 30000
tokin serve --model-path Qwen/Qwen3.5-0.8B --engine-url http://localhost:30000
Open a session for each sample. It prints the base URL the harness takes:
URL=$(tokin open --params '{"return_logprobs": true}')
For pi, add that URL as a provider in ~/.pi/agent/models.json, then run
pi as usual:
{
"providers": {
"tokin": {
"baseUrl": "<URL>",
"api": "openai-completions",
"apiKey": "tokin",
"models": [{ "id": "Qwen/Qwen3.5-0.8B" }]
}
}
}
pi --provider tokin --model Qwen/Qwen3.5-0.8B "Write a haiku about tokens to haiku.txt."
Collect the session, one JSON line per rollout with its token_ids, loss_mask and
logprobs:
tokin collect "$URL" -o rollouts.jsonl
Examples
examples/harbor_eval: evaluate mini-swe-agent, opencode or pi through tokin on Harbor.examples/pi_mimo_rl: train pi with slime on MiMo-V2.6-RL-oss.
Metadata
Release files for tokin 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tokin-0.1.0.tar.gz | 60.9 kB | With provenance | Details for tokin-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tokin-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for tokin-0.1.0-py3-none-any.whl |
Total release size: 104.8 kB
Release files / tokin-0.1.0.tar.gz
| Download URL | tokin-0.1.0.tar.gz |
|---|---|
| Size | 60.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5d9139a928a6d4768cd29d86210dd159c5caa0e62094167d03444c020e64fc93
|
|
BLAKE2b-256 checksum How to use checksums |
63b4323ee41def692d74d62ee0dc8ac6b80716571d5f74edf5d79ff3a017302a
|
| 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 Nov 11, 2026.
Transparency logRelease files / tokin-0.1.0-py3-none-any.whl
| Download URL | tokin-0.1.0-py3-none-any.whl |
|---|---|
| Size | 43.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce38c52894b283ac172d29108fbe926f12da5a0765239f0d49622807380c001c
|
|
BLAKE2b-256 checksum How to use checksums |
377a94363fa565f33cc59a08d6b2522b8ab20e7310c34c019ebf3e9f54851e96
|
| 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 Nov 11, 2026.
Transparency logSecurity for tokin 0.1.0
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
Both files in this release have been uploaded with provenance metadata.
Attestation for tokin-0.1.0.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 Nov 11, 2026.
Transparency logA 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.