Skip to main content

Official Python SDK for TokenBee LLM inference gateway and observability.

Project description

TokenBee Python SDK

Official Python SDK for TokenBee - The Intelligent LLM Inference Gateway with Observability, Compression, and Privacy.

Features

  • Unified API: Access multiple LLM providers (OpenAI, Anthropic, Google, Mistral, etc.) through a single interface.
  • Intelligent Compression: Reduce token usage and latency with context-aware compression.
  • Privacy Guard: Automatic PII masking and privacy-preserving inference.
  • Built-in Observability: Automatic tracking of latency, costs, and token usage.

Installation

pip install tokenbee-sdk

Quick Start

from tokenbee import TokenBee, TokenBeeModel, CompressionRate

# Initialize the client with your TokenBee API key 
# AND your LLM provider key (Bring Your Own Key - BYOK)
client = TokenBee(
    api_key="your_tokenbee_api_key",
    llm_key="your_llm_provider_key", # e.g. OpenAI or Anthropic key
    compression="auto",
    rate=CompressionRate.MEDIUM
)

# Send a request
response = client.send(
    model=TokenBeeModel.OPENAI_GPT_4O,
    input={
        "messages": [
            {"role": "user", "content": "Explain quantum entanglement in simple terms."}
        ]
    }
)

print(response["choices"][0]["message"]["content"])

Bring Your Own Key (BYOK)

TokenBee is a stateless gateway. We do not store your LLM provider API keys in our database. You pass your provider key (OpenAI, Anthropic, etc.) through the SDK's llm_key parameter. The SDK sends this in the X-LLM-Key header, allowing the TokenBee proxy to forward requests to the provider on your behalf while you maintain full control over your billing and security.

Advanced Usage

Compression Control

You can specify the compression rate and method per request:

response = client.send(
    model=TokenBeeModel.ANTHROPIC_CLAUDE_3_5_SONNET,
    input={
        "messages": [...],
        "compression": "on",
        "rate": CompressionRate.HIGH,
        "privacy": True
    }
)

Supported Models

The SDK provides a TokenBeeModel enum with popular models:

  • TokenBeeModel.OPENAI_GPT_4O
  • TokenBeeModel.ANTHROPIC_CLAUDE_3_5_SONNET
  • TokenBeeModel.GEMINI_2_0_FLASH
  • ... and many others.

License

MIT

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

tokenbee_sdk-0.2.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

tokenbee_sdk-0.2.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file tokenbee_sdk-0.2.1.tar.gz.

File metadata

  • Download URL: tokenbee_sdk-0.2.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for tokenbee_sdk-0.2.1.tar.gz
Algorithm Hash digest
SHA256 dd51390393dad5cb3ec25f92ab486d1b8c0e0654a23d900b67d043e1c10e5b16
MD5 fdd0bba6d85ae3c9ec18069b0748d4c4
BLAKE2b-256 d7e3d94cf6cd4ec0a30a8939c8fa1d56838afd5fb566443324e492645d440228

See more details on using hashes here.

File details

Details for the file tokenbee_sdk-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: tokenbee_sdk-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for tokenbee_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6ab6e2bf4b98aad07499a014c1379788826dfd22b4fe9432b7a7247575a95d7d
MD5 7de18695b997001ed12d06458faa1fe0
BLAKE2b-256 e52df063ed9c554527879657ec7d7b37e3ddeff74de75abd2eddddd6a4d8dfae

See more details on using hashes here.

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