Skip to main content

TokenLab Python SDK

Lightweight Python client for TokenLab discovery, OpenAI-compatible APIs, and native endpoint families.

Install from PyPI:

pip install tokenlab-ai

Usage

from tokenlab import TokenLabClient

with TokenLabClient(api_key="YOUR_TOKENLAB_API_KEY") as tokenlab:
    models = tokenlab.list_models(category="chat")
    response = tokenlab.create_response({
        "model": "gpt-5.5",
        "input": "Hello from TokenLab",
    })

Native Endpoints

tokenlab.create_anthropic_message({
    "model": "claude-sonnet-5",
    "max_tokens": 512,
    "messages": [{"role": "user", "content": "Hello"}],
})

tokenlab.create_gemini_content("gemini-3.5-flash", {
    "contents": [{"role": "user", "parts": [{"text": "Hello"}]}],
})

Discovery Helpers

tokenlab.get_models_json()
tokenlab.get_pricing_json()
tokenlab.get_integrations_json()

System One decisions

Discover tokenlab.list_models(category="decision") and inspect the selected model with get_model() first. Decision models declare the systemone public operation, not a chat format.

with TokenLabClient(timeout=60.0) as tokenlab:
    decision = tokenlab.evaluate_decisions({
        "model": "jev-1.13",
        "state": {"ticket": "Please refund my duplicate charge."},
        "questions": {"refund": {"type": "noul", "instructions": "Is a refund requested?"}},
    })
    print(decision["answers"], decision["usage"])

The client reads TOKENLAB_API_KEY from the environment. This synchronous /v1/systemone call preserves typed answers, probabilities, optional confidence, and usage. It is not Chat, streaming, or Batch. A decision does not authorize a refund or another side effect. Errors are returned without automatic resubmission. Available in SDK 0.1.2+.

Base URLs

  • API: https://api.tokenlab.sh
  • OpenAI-compatible SDK base URL: https://api.tokenlab.sh/v1
  • OpenAPI: https://docs.tokenlab.sh/openapi.json

Release files for tokenlab-ai 0.1.2

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

Source distribution (sdist)

Source distribution for tokenlab-ai 0.1.2
File Size Uploaded
tokenlab_ai-0.1.2.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tokenlab-ai 0.1.2
File Interpreter ABI Platform
tokenlab_ai-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.2 kB

Release files / tokenlab_ai-0.1.2.tar.gz

Download URL tokenlab_ai-0.1.2.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1db29b881da14580423e66b2da8d0d5b3f99500afde569d9742465728ca5bf89
BLAKE2b-256 checksum
How to use checksums
2abb0399616dd7d807b158c86dc4271b3f22e5a31371f67b21cca23de1d81341
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / tokenlab_ai-0.1.2-py3-none-any.whl

Download URL tokenlab_ai-0.1.2-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07c1782ae945aa4e5b4bad014046807d133781ce05731c5e8558bd16b440d56a
BLAKE2b-256 checksum
How to use checksums
50512c9579f62555010676eff2fea6aace7d06aa8f6824edeb9d45fac8b3d125
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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