Skip to main content

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: Wave 2 target, not yet published. 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-v1
  • openai-cross-underscore-v1

Install

Until the first PyPI release is published, install from a local checkout:

pip install ./packages/python

After publish, the install command will be:

pip install tokid

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 text
  • transport: best when the ID must survive URLs, JSON, logs, or APIs
  • envelope: best when the ID must be stored, exchanged, validated, and parsed later

If you only remember one rule, use this one:

  • use envelope at 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 core surface 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tokid-0.1.0a3.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tokid-0.1.0a3-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file tokid-0.1.0a3.tar.gz.

File metadata

  • Download URL: tokid-0.1.0a3.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tokid-0.1.0a3.tar.gz
Algorithm Hash digest
SHA256 15628d732d5e46dd194241004270b0ec24753764ed904b55410856c30f1a9e7c
MD5 19315728cc4fc9cd3b2a1db0f2a59793
BLAKE2b-256 17a6fb18f511128328fdddb4593ef84eed7a4de9b463725bee052c00d227d7bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for tokid-0.1.0a3.tar.gz:

Publisher: publish.yml on Tetra-Research/tokid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tokid-0.1.0a3-py3-none-any.whl.

File metadata

  • Download URL: tokid-0.1.0a3-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

Hashes for tokid-0.1.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 283c71e07249b32e44096d02e631070e88e71388bf3745b6bacbc7ecce23ea00
MD5 e911529b5d893594c448bbec0eb35f2f
BLAKE2b-256 2bea9fdf7e76f43b9bfc695358d7e1e4b0dae2bfdc54f7d0d5f5c13f60f41aaf

See more details on using hashes here.

Provenance

The following attestation bundles were made for tokid-0.1.0a3-py3-none-any.whl:

Publisher: publish.yml on Tetra-Research/tokid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page