tokenbee-sdk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tokenbee_sdk-0.1.0/PKG-INFO +87 -0
- tokenbee_sdk-0.1.0/README.md +72 -0
- tokenbee_sdk-0.1.0/pyproject.toml +22 -0
- tokenbee_sdk-0.1.0/setup.cfg +4 -0
- tokenbee_sdk-0.1.0/setup.py +23 -0
- tokenbee_sdk-0.1.0/tokenbee/__init__.py +99 -0
- tokenbee_sdk-0.1.0/tokenbee_sdk.egg-info/PKG-INFO +87 -0
- tokenbee_sdk-0.1.0/tokenbee_sdk.egg-info/SOURCES.txt +9 -0
- tokenbee_sdk-0.1.0/tokenbee_sdk.egg-info/dependency_links.txt +1 -0
- tokenbee_sdk-0.1.0/tokenbee_sdk.egg-info/requires.txt +1 -0
- tokenbee_sdk-0.1.0/tokenbee_sdk.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tokenbee-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for TokenBee LLM inference gateway and observability.
|
|
5
|
+
Author: TokenBee Inc.
|
|
6
|
+
Author-email: "TokenBee Inc." <hello@tokenbee.dev>
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: httpx>=0.23.0
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: requires-python
|
|
15
|
+
|
|
16
|
+
# TokenBee Python SDK
|
|
17
|
+
|
|
18
|
+
Official Python SDK for [TokenBee](https://tokenbee.dev) - The Intelligent LLM Inference Gateway with Observability, Compression, and Privacy.
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- **Unified API**: Access multiple LLM providers (OpenAI, Anthropic, Google, Mistral, etc.) through a single interface.
|
|
23
|
+
- **Intelligent Compression**: Reduce token usage and latency with context-aware compression.
|
|
24
|
+
- **Privacy Guard**: Automatic PII masking and privacy-preserving inference.
|
|
25
|
+
- **Built-in Observability**: Automatic tracking of latency, costs, and token usage.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install tokenbee-sdk
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from tokenbee import TokenBee, TokenBeeModel, CompressionRate
|
|
37
|
+
|
|
38
|
+
# Initialize the client
|
|
39
|
+
client = TokenBee(
|
|
40
|
+
api_key="your_api_key_here",
|
|
41
|
+
compression="auto",
|
|
42
|
+
rate=CompressionRate.MEDIUM
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Send a request
|
|
46
|
+
response = client.send(
|
|
47
|
+
model=TokenBeeModel.OPENAI_GPT_4O,
|
|
48
|
+
input={
|
|
49
|
+
"messages": [
|
|
50
|
+
{"role": "user", "content": "Explain quantum entanglement in simple terms."}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
print(response["choices"][0]["message"]["content"])
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Advanced Usage
|
|
59
|
+
|
|
60
|
+
### Compression Control
|
|
61
|
+
|
|
62
|
+
You can specify the compression rate and method per request:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
response = client.send(
|
|
66
|
+
model=TokenBeeModel.ANTHROPIC_CLAUDE_3_5_SONNET,
|
|
67
|
+
input={
|
|
68
|
+
"messages": [...],
|
|
69
|
+
"compression": "on",
|
|
70
|
+
"rate": CompressionRate.HIGH,
|
|
71
|
+
"privacy": True
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Supported Models
|
|
77
|
+
|
|
78
|
+
The SDK provides a `TokenBeeModel` enum with popular models:
|
|
79
|
+
|
|
80
|
+
- `TokenBeeModel.OPENAI_GPT_4O`
|
|
81
|
+
- `TokenBeeModel.ANTHROPIC_CLAUDE_3_5_SONNET`
|
|
82
|
+
- `TokenBeeModel.GEMINI_2_0_FLASH`
|
|
83
|
+
- ... and many others.
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
MIT
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# TokenBee Python SDK
|
|
2
|
+
|
|
3
|
+
Official Python SDK for [TokenBee](https://tokenbee.dev) - The Intelligent LLM Inference Gateway with Observability, Compression, and Privacy.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Unified API**: Access multiple LLM providers (OpenAI, Anthropic, Google, Mistral, etc.) through a single interface.
|
|
8
|
+
- **Intelligent Compression**: Reduce token usage and latency with context-aware compression.
|
|
9
|
+
- **Privacy Guard**: Automatic PII masking and privacy-preserving inference.
|
|
10
|
+
- **Built-in Observability**: Automatic tracking of latency, costs, and token usage.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install tokenbee-sdk
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from tokenbee import TokenBee, TokenBeeModel, CompressionRate
|
|
22
|
+
|
|
23
|
+
# Initialize the client
|
|
24
|
+
client = TokenBee(
|
|
25
|
+
api_key="your_api_key_here",
|
|
26
|
+
compression="auto",
|
|
27
|
+
rate=CompressionRate.MEDIUM
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Send a request
|
|
31
|
+
response = client.send(
|
|
32
|
+
model=TokenBeeModel.OPENAI_GPT_4O,
|
|
33
|
+
input={
|
|
34
|
+
"messages": [
|
|
35
|
+
{"role": "user", "content": "Explain quantum entanglement in simple terms."}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
print(response["choices"][0]["message"]["content"])
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Advanced Usage
|
|
44
|
+
|
|
45
|
+
### Compression Control
|
|
46
|
+
|
|
47
|
+
You can specify the compression rate and method per request:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
response = client.send(
|
|
51
|
+
model=TokenBeeModel.ANTHROPIC_CLAUDE_3_5_SONNET,
|
|
52
|
+
input={
|
|
53
|
+
"messages": [...],
|
|
54
|
+
"compression": "on",
|
|
55
|
+
"rate": CompressionRate.HIGH,
|
|
56
|
+
"privacy": True
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Supported Models
|
|
62
|
+
|
|
63
|
+
The SDK provides a `TokenBeeModel` enum with popular models:
|
|
64
|
+
|
|
65
|
+
- `TokenBeeModel.OPENAI_GPT_4O`
|
|
66
|
+
- `TokenBeeModel.ANTHROPIC_CLAUDE_3_5_SONNET`
|
|
67
|
+
- `TokenBeeModel.GEMINI_2_0_FLASH`
|
|
68
|
+
- ... and many others.
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
MIT
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tokenbee-sdk"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="TokenBee Inc.", email="hello@tokenbee.dev" },
|
|
10
|
+
]
|
|
11
|
+
description = "Official Python SDK for TokenBee LLM inference gateway and observability."
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.7"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"httpx>=0.23.0",
|
|
21
|
+
]
|
|
22
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
this_directory = Path(__file__).parent
|
|
5
|
+
long_description = (this_directory / "README.md").read_text()
|
|
6
|
+
|
|
7
|
+
setup(
|
|
8
|
+
name="tokenbee-sdk",
|
|
9
|
+
version="0.1.0",
|
|
10
|
+
packages=find_packages(),
|
|
11
|
+
install_requires=["httpx>=0.23.0"],
|
|
12
|
+
author="TokenBee Inc.",
|
|
13
|
+
author_email="hello@tokenbee.dev",
|
|
14
|
+
description="Official Python SDK for TokenBee LLM inference gateway and observability.",
|
|
15
|
+
long_description=long_description,
|
|
16
|
+
long_description_content_type="text/markdown",
|
|
17
|
+
python_requires=">=3.7",
|
|
18
|
+
classifiers=[
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
],
|
|
23
|
+
)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import httpx
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
class CompressionRate(str, Enum):
|
|
5
|
+
LOW = "0.75"
|
|
6
|
+
MEDIUM = "0.5"
|
|
7
|
+
HIGH = "0.33"
|
|
8
|
+
EXTREME = "0.2"
|
|
9
|
+
|
|
10
|
+
class TokenBeeModel(str, Enum):
|
|
11
|
+
# OpenAI
|
|
12
|
+
OPENAI_GPT_4O = "openai/gpt-4o"
|
|
13
|
+
OPENAI_GPT_4O_MINI = "openai/gpt-4o-mini"
|
|
14
|
+
OPENAI_O1 = "openai/o1"
|
|
15
|
+
OPENAI_O1_MINI = "openai/o1-mini"
|
|
16
|
+
OPENAI_O3_MINI = "openai/o3-mini"
|
|
17
|
+
|
|
18
|
+
# Anthropic
|
|
19
|
+
ANTHROPIC_CLAUDE_4_6_SONNET = "anthropic/claude-4-6-sonnet-latest"
|
|
20
|
+
ANTHROPIC_CLAUDE_4_6_OPUS = "anthropic/claude-4-6-opus-latest"
|
|
21
|
+
ANTHROPIC_CLAUDE_3_5_SONNET = "anthropic/claude-3-5-sonnet-latest"
|
|
22
|
+
ANTHROPIC_CLAUDE_3_5_HAIKU = "anthropic/claude-3-5-haiku-latest"
|
|
23
|
+
ANTHROPIC_CLAUDE_3_OPUS = "anthropic/claude-3-opus-latest"
|
|
24
|
+
|
|
25
|
+
# Google
|
|
26
|
+
GEMINI_3_1_PRO = "google/gemini-3.1-pro"
|
|
27
|
+
GEMINI_3_1_FLASH = "google/gemini-3.1-flash"
|
|
28
|
+
GEMINI_2_0_FLASH = "google/gemini-2.0-flash"
|
|
29
|
+
GEMINI_2_0_PRO = "google/gemini-2.0-pro-exp"
|
|
30
|
+
GEMINI_1_5_PRO = "google/gemini-1.5-pro"
|
|
31
|
+
GEMINI_1_5_FLASH = "google/gemini-1.5-flash"
|
|
32
|
+
|
|
33
|
+
# Mistral
|
|
34
|
+
MISTRAL_LARGE = "mistral/mistral-large-latest"
|
|
35
|
+
MISTRAL_SMALL = "mistral/mistral-small-latest"
|
|
36
|
+
PIXTRAL_LARGE = "mistral/pixtral-large-latest"
|
|
37
|
+
MISTRAL_NEMO = "mistral/open-mistral-nemo"
|
|
38
|
+
|
|
39
|
+
# Perplexity
|
|
40
|
+
PERPLEXITY_SONAR = "perplexity/sonar"
|
|
41
|
+
PERPLEXITY_SONAR_PRO = "perplexity/sonar-pro"
|
|
42
|
+
PERPLEXITY_SONAR_REASONING = "perplexity/sonar-reasoning"
|
|
43
|
+
|
|
44
|
+
# Groq
|
|
45
|
+
GROQ_LLAMA_3_3_70B = "groq/llama-3.3-70b-versatile"
|
|
46
|
+
GROQ_LLAMA_3_1_8B = "groq/llama-3.1-8b-instant"
|
|
47
|
+
GROQ_MIXTRAL_8X7B = "groq/mixtral-8x7b-32768"
|
|
48
|
+
GROQ_GEMMA2_9B = "groq/gemma2-9b-it"
|
|
49
|
+
|
|
50
|
+
class TokenBee:
|
|
51
|
+
def __init__(
|
|
52
|
+
self,
|
|
53
|
+
api_key: str,
|
|
54
|
+
base_url: str = "https://api.tokenbee.dev/v1",
|
|
55
|
+
compression: str = "auto",
|
|
56
|
+
rate: str = CompressionRate.MEDIUM,
|
|
57
|
+
model: str = "",
|
|
58
|
+
provider: str = "",
|
|
59
|
+
privacy: bool = False
|
|
60
|
+
):
|
|
61
|
+
self.api_key = api_key
|
|
62
|
+
self.base_url = base_url
|
|
63
|
+
self.headers = {
|
|
64
|
+
"Authorization": f"Bearer {api_key}",
|
|
65
|
+
"X-TokenBee-Compression": compression,
|
|
66
|
+
"X-TokenBee-Rate": rate,
|
|
67
|
+
"X-TokenBee-Privacy": str(privacy).lower()
|
|
68
|
+
}
|
|
69
|
+
if model:
|
|
70
|
+
self.headers["X-TokenBee-Model"] = model
|
|
71
|
+
if provider:
|
|
72
|
+
self.headers["X-TokenBee-Provider"] = provider
|
|
73
|
+
|
|
74
|
+
self.client = httpx.Client(headers=self.headers, base_url=self.base_url)
|
|
75
|
+
|
|
76
|
+
def send(self, model: str, input: dict):
|
|
77
|
+
parts = model.split("/")
|
|
78
|
+
provider = parts[0] if len(parts) > 1 else self.headers.get("X-TokenBee-Provider", "openai")
|
|
79
|
+
model_name = "/".join(parts[1:]) if len(parts) > 1 else parts[0]
|
|
80
|
+
|
|
81
|
+
headers = self.headers.copy()
|
|
82
|
+
headers["X-TokenBee-Model"] = model_name
|
|
83
|
+
headers["X-TokenBee-Provider"] = provider
|
|
84
|
+
|
|
85
|
+
if "compression" in input:
|
|
86
|
+
headers["X-TokenBee-Compression"] = str(input["compression"])
|
|
87
|
+
if "rate" in input:
|
|
88
|
+
headers["X-TokenBee-Rate"] = str(input["rate"])
|
|
89
|
+
if "privacy" in input:
|
|
90
|
+
headers["X-TokenBee-Privacy"] = str(input["privacy"]).lower()
|
|
91
|
+
|
|
92
|
+
payload = input.copy()
|
|
93
|
+
payload.pop("compression", None)
|
|
94
|
+
payload.pop("rate", None)
|
|
95
|
+
payload.pop("privacy", None)
|
|
96
|
+
|
|
97
|
+
response = self.client.post("/chat/completions", json=payload, headers=headers)
|
|
98
|
+
response.raise_for_status()
|
|
99
|
+
return response.json()
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tokenbee-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for TokenBee LLM inference gateway and observability.
|
|
5
|
+
Author: TokenBee Inc.
|
|
6
|
+
Author-email: "TokenBee Inc." <hello@tokenbee.dev>
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: httpx>=0.23.0
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: requires-python
|
|
15
|
+
|
|
16
|
+
# TokenBee Python SDK
|
|
17
|
+
|
|
18
|
+
Official Python SDK for [TokenBee](https://tokenbee.dev) - The Intelligent LLM Inference Gateway with Observability, Compression, and Privacy.
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- **Unified API**: Access multiple LLM providers (OpenAI, Anthropic, Google, Mistral, etc.) through a single interface.
|
|
23
|
+
- **Intelligent Compression**: Reduce token usage and latency with context-aware compression.
|
|
24
|
+
- **Privacy Guard**: Automatic PII masking and privacy-preserving inference.
|
|
25
|
+
- **Built-in Observability**: Automatic tracking of latency, costs, and token usage.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install tokenbee-sdk
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from tokenbee import TokenBee, TokenBeeModel, CompressionRate
|
|
37
|
+
|
|
38
|
+
# Initialize the client
|
|
39
|
+
client = TokenBee(
|
|
40
|
+
api_key="your_api_key_here",
|
|
41
|
+
compression="auto",
|
|
42
|
+
rate=CompressionRate.MEDIUM
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Send a request
|
|
46
|
+
response = client.send(
|
|
47
|
+
model=TokenBeeModel.OPENAI_GPT_4O,
|
|
48
|
+
input={
|
|
49
|
+
"messages": [
|
|
50
|
+
{"role": "user", "content": "Explain quantum entanglement in simple terms."}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
print(response["choices"][0]["message"]["content"])
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Advanced Usage
|
|
59
|
+
|
|
60
|
+
### Compression Control
|
|
61
|
+
|
|
62
|
+
You can specify the compression rate and method per request:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
response = client.send(
|
|
66
|
+
model=TokenBeeModel.ANTHROPIC_CLAUDE_3_5_SONNET,
|
|
67
|
+
input={
|
|
68
|
+
"messages": [...],
|
|
69
|
+
"compression": "on",
|
|
70
|
+
"rate": CompressionRate.HIGH,
|
|
71
|
+
"privacy": True
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Supported Models
|
|
77
|
+
|
|
78
|
+
The SDK provides a `TokenBeeModel` enum with popular models:
|
|
79
|
+
|
|
80
|
+
- `TokenBeeModel.OPENAI_GPT_4O`
|
|
81
|
+
- `TokenBeeModel.ANTHROPIC_CLAUDE_3_5_SONNET`
|
|
82
|
+
- `TokenBeeModel.GEMINI_2_0_FLASH`
|
|
83
|
+
- ... and many others.
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
httpx>=0.23.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tokenbee
|