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: 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-v1
  • openai-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 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.0a4.tar.gz (20.6 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.0a4-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

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

Hashes for tokid-0.1.0a4.tar.gz
Algorithm Hash digest
SHA256 7da7ecc360dc0411792dbe808cc8d6f88cbe792cefffa3e7ad963a6f270501f8
MD5 00f316e1226b7313daddef18c748dc49
BLAKE2b-256 0c7dfe349639ec33b17d8218625cd78db862832335ce4d9df7e30c0bd6b4ac1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tokid-0.1.0a4.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.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

Hashes for tokid-0.1.0a4-py3-none-any.whl
Algorithm Hash digest
SHA256 2346ff8c4d2dbfcb7e6013a0088cf1958dc436f20c7c71c79db8d36dacd2a431
MD5 e7f017b91b2597e91d74676527cbd6d3
BLAKE2b-256 c7798e9891c633fe1e6e31380dc7d00c5ae4ca3adc13f0e0b8b5b55152016b2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tokid-0.1.0a4-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