Token-native IDs for LLM-facing systems
Project description
tokid Python SDK
Python SDK for the tokid portable profile format.
tokid is for the narrow case where identifiers regularly pass through prompts, tool calls, JSON payloads, logs, or URLs and token cost matters.
It is not a shorter UUID.
It is not a universal replacement for uuid, ulid, nanoid, or sqids.
Status: early alpha.
Capability tier: core.
Runtime target: Python 3.11+.
Registry readiness: publish-now.
Registry status: live on PyPI as 0.1.0a4.
Package name: tokid on PyPI.
What You Get
This SDK supports the stable day-to-day surface:
- generate tokids in prompt, transport, or envelope format
- parse and validate existing tokids
- convert between prompt, transport, and envelope renderings
- pin a profile once with a factory
The current alpha ships two built-in profiles:
openai-cross-v1openai-cross-underscore-v1
Install
pip install tokid
For local development against a checkout:
pip install ./packages/python
Quick Start
from tokid import generate, is_tokid, to_prompt, to_transport
tokid = generate()
if not is_tokid(tokid):
raise ValueError("invalid tokid")
prompt = to_prompt(tokid)
transport = to_transport(tokid)
generate() returns the durable envelope form by default. That is the form you should store, exchange, and pass across boundaries unless you have a strong reason not to.
Factory API
Bind profile choice and default length once:
from tokid import create_tokid_factory
tokid = create_tokid_factory(
profile="openai-cross-v1",
length=8,
)
identifier = tokid.generate()
logical = tokid.parse(identifier)
prompt = tokid.prompt(identifier)
transport = tokid.transport(identifier)
You can also inspect the active profile:
profile = tokid.profile()
Prompt, Transport, Envelope
Every tokid has one logical identity and three useful renderings:
prompt: best when a human or LLM reads the ID in natural texttransport: best when the ID must survive URLs, JSON, logs, or APIsenvelope: best when the ID must be stored, exchanged, validated, and parsed later
If you only remember one rule, use this one:
- use
envelopeat persistence and network boundaries
Profile Choice
openai-cross-v1
Default profile.
- prompt uses spaces
- transport uses raw concatenation
- best when token cost is the main concern
openai-cross-underscore-v1
Opt-in profile.
- prompt still uses spaces
- transport uses
_ - best when visual segmentation matters more than the last bit of transport efficiency
Example:
from tokid import create_tokid_factory
tokid = create_tokid_factory(profile="openai-cross-underscore-v1")
identifier = tokid.generate()
transport = tokid.transport(identifier)
When To Use It
Use tokid when most of these are true:
- your application regularly sends IDs through prompts or tool calls
- you care about token cost inside JSON, logs, URLs, or text-heavy transports
- you want a stable external envelope plus alternate prompt and transport renderings
- you are comfortable pinning an explicit profile in your application
Choose something else when minimal byte length, ecosystem standardization, sortable IDs, or authentication-grade secrets matter more than token behavior.
Runtime Notes
- Python
3.11+ - the current built-in profiles are OpenAI-derived
- this SDK intentionally documents the
coresurface first even though lower-level runtime types exist
Maintainer Release
Dry-run:
npm run release:pypi:dry-run
Official upload:
npm run release:pypi
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 tokid-0.1.0a4.tar.gz.
File metadata
- Download URL: tokid-0.1.0a4.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7da7ecc360dc0411792dbe808cc8d6f88cbe792cefffa3e7ad963a6f270501f8
|
|
| MD5 |
00f316e1226b7313daddef18c748dc49
|
|
| BLAKE2b-256 |
0c7dfe349639ec33b17d8218625cd78db862832335ce4d9df7e30c0bd6b4ac1a
|
Provenance
The following attestation bundles were made for tokid-0.1.0a4.tar.gz:
Publisher:
publish.yml on Tetra-Research/tokid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tokid-0.1.0a4.tar.gz -
Subject digest:
7da7ecc360dc0411792dbe808cc8d6f88cbe792cefffa3e7ad963a6f270501f8 - Sigstore transparency entry: 1454517934
- Sigstore integration time:
-
Permalink:
Tetra-Research/tokid@6c84c6e708f9f6ab9a10ad81941a5db9f0ba6d1e -
Branch / Tag:
refs/tags/v0.1.0-alpha.4 - Owner: https://github.com/Tetra-Research
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6c84c6e708f9f6ab9a10ad81941a5db9f0ba6d1e -
Trigger Event:
push
-
Statement type:
File details
Details for the file tokid-0.1.0a4-py3-none-any.whl.
File metadata
- Download URL: tokid-0.1.0a4-py3-none-any.whl
- Upload date:
- Size: 23.4 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 |
2346ff8c4d2dbfcb7e6013a0088cf1958dc436f20c7c71c79db8d36dacd2a431
|
|
| MD5 |
e7f017b91b2597e91d74676527cbd6d3
|
|
| BLAKE2b-256 |
c7798e9891c633fe1e6e31380dc7d00c5ae4ca3adc13f0e0b8b5b55152016b2a
|
Provenance
The following attestation bundles were made for tokid-0.1.0a4-py3-none-any.whl:
Publisher:
publish.yml on Tetra-Research/tokid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tokid-0.1.0a4-py3-none-any.whl -
Subject digest:
2346ff8c4d2dbfcb7e6013a0088cf1958dc436f20c7c71c79db8d36dacd2a431 - Sigstore transparency entry: 1454518001
- Sigstore integration time:
-
Permalink:
Tetra-Research/tokid@6c84c6e708f9f6ab9a10ad81941a5db9f0ba6d1e -
Branch / Tag:
refs/tags/v0.1.0-alpha.4 - Owner: https://github.com/Tetra-Research
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6c84c6e708f9f6ab9a10ad81941a5db9f0ba6d1e -
Trigger Event:
push
-
Statement type: