tokenbee-sdk 1.2.2__tar.gz → 1.3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tokenbee-sdk
3
- Version: 1.2.2
3
+ Version: 1.3.0
4
4
  Summary: Official Python SDK for TokenBee LLM inference gateway and observability.
5
5
  Author: TokenBee Inc.
6
6
  Author-email: "TokenBee Inc." <founders@tokenbee.io>
@@ -73,20 +73,26 @@ TokenBee is a **stateless** gateway. We do not store your LLM provider API keys
73
73
 
74
74
  ### Compression Control
75
75
 
76
- You can specify the compression rate and method per request:
76
+ You can specify the compression rate and method per request. TokenBee uses an intelligent semantic engine to reduce token usage while preserving meaning.
77
77
 
78
78
  ```python
79
79
  response = client.send(
80
80
  model=TokenBeeModel.ANTHROPIC_CLAUDE_3_5_SONNET,
81
81
  input={
82
82
  "messages": [...],
83
- "compression": "on",
84
- "rate": CompressionRate.HIGH,
83
+ "compression": "auto", # "auto" (default), "on", or "off"
84
+ "rate": CompressionRate.HIGH, # MEDIUM (0.5), HIGH (0.33), etc.
85
85
  "privacy": True
86
86
  }
87
87
  )
88
88
  ```
89
89
 
90
+ - **`compression`**: Set to `"auto"` to let TokenBee decide when to compress, or `"off"` to bypass the compression engine entirely for high-precision tasks.
91
+ - **`rate`**: Controls the aggressiveness of compression. `HIGH` aims for ~67% token reduction.
92
+ - **`sessionId`**: (Optional) String ID to group multiple requests into a single replayable session in the dashboard.
93
+ - **`userId`**: (Optional) String ID to track usage and costs per unique end-user.
94
+ - **`privacy`**: (Optional) Set to `True` to disable payload logging and session replays for this request. Metadata (latency, tokens) will still be recorded for observability.
95
+
90
96
  ### Supported Models
91
97
 
92
98
  The SDK provides a `TokenBeeModel` enum with popular models:
@@ -55,20 +55,26 @@ TokenBee is a **stateless** gateway. We do not store your LLM provider API keys
55
55
 
56
56
  ### Compression Control
57
57
 
58
- You can specify the compression rate and method per request:
58
+ You can specify the compression rate and method per request. TokenBee uses an intelligent semantic engine to reduce token usage while preserving meaning.
59
59
 
60
60
  ```python
61
61
  response = client.send(
62
62
  model=TokenBeeModel.ANTHROPIC_CLAUDE_3_5_SONNET,
63
63
  input={
64
64
  "messages": [...],
65
- "compression": "on",
66
- "rate": CompressionRate.HIGH,
65
+ "compression": "auto", # "auto" (default), "on", or "off"
66
+ "rate": CompressionRate.HIGH, # MEDIUM (0.5), HIGH (0.33), etc.
67
67
  "privacy": True
68
68
  }
69
69
  )
70
70
  ```
71
71
 
72
+ - **`compression`**: Set to `"auto"` to let TokenBee decide when to compress, or `"off"` to bypass the compression engine entirely for high-precision tasks.
73
+ - **`rate`**: Controls the aggressiveness of compression. `HIGH` aims for ~67% token reduction.
74
+ - **`sessionId`**: (Optional) String ID to group multiple requests into a single replayable session in the dashboard.
75
+ - **`userId`**: (Optional) String ID to track usage and costs per unique end-user.
76
+ - **`privacy`**: (Optional) Set to `True` to disable payload logging and session replays for this request. Metadata (latency, tokens) will still be recorded for observability.
77
+
72
78
  ### Supported Models
73
79
 
74
80
  The SDK provides a `TokenBeeModel` enum with popular models:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tokenbee-sdk"
7
- version = "1.2.2"
7
+ version = "1.3.0"
8
8
  authors = [
9
9
  { name="TokenBee Inc.", email="founders@tokenbee.io" },
10
10
  ]
@@ -6,7 +6,7 @@ long_description = (this_directory / "README.md").read_text()
6
6
 
7
7
  setup(
8
8
  name="tokenbee-sdk",
9
- version="1.2.2",
9
+ version="1.3.0",
10
10
  packages=find_packages(),
11
11
  install_requires=["httpx>=0.23.0"],
12
12
  author="TokenBee Inc.",
@@ -8,6 +8,17 @@ class CompressionRate(str, Enum):
8
8
  HIGH = "0.33"
9
9
  EXTREME = "0.2"
10
10
 
11
+ class CompressionStrategy(str, Enum):
12
+ HIVE = "hive_v1"
13
+ SMART = "smart_v1"
14
+
15
+ class TokenBeeContext(str, Enum):
16
+ AUTO = "auto"
17
+ CONVERSATION = "conversation"
18
+ DOCUMENT = "document"
19
+ AGENT = "agent"
20
+ CODE = "code"
21
+
11
22
  class TokenBeeModel(str, Enum):
12
23
  # OpenAI
13
24
  OPENAI_GPT_4_5 = "openai/gpt-4.5-preview"
@@ -60,6 +71,8 @@ class TokenBee:
60
71
  llm_key: str,
61
72
  compression: str = "auto",
62
73
  rate: str = CompressionRate.MEDIUM,
74
+ strategy: str = CompressionStrategy.SMART,
75
+ context: str = TokenBeeContext.AUTO,
63
76
  model: str = "",
64
77
  provider: str = "",
65
78
  privacy: bool = False
@@ -74,6 +87,8 @@ class TokenBee:
74
87
  "X-LLM-Key": llm_key,
75
88
  "X-TokenBee-Compression": compression,
76
89
  "X-TokenBee-Rate": rate,
90
+ "X-TokenBee-Strategy": strategy,
91
+ "X-TokenBee-Context": context,
77
92
  "X-TokenBee-Privacy": str(privacy).lower()
78
93
  }
79
94
  if model:
@@ -96,14 +111,26 @@ class TokenBee:
96
111
  headers["X-TokenBee-Compression"] = str(input["compression"])
97
112
  if "rate" in input:
98
113
  headers["X-TokenBee-Rate"] = str(input["rate"])
114
+ if "strategy" in input:
115
+ headers["X-TokenBee-Strategy"] = str(input["strategy"])
116
+ if "context" in input:
117
+ headers["X-TokenBee-Context"] = str(input["context"])
99
118
  if "privacy" in input:
100
119
  headers["X-TokenBee-Privacy"] = str(input["privacy"]).lower()
120
+ if "sessionId" in input:
121
+ headers["X-TB-Session-Id"] = str(input["sessionId"])
122
+ if "userId" in input:
123
+ headers["X-TB-User-Id"] = str(input["userId"])
101
124
 
102
125
  payload = input.copy()
103
126
  payload["model"] = model_name
104
127
  payload.pop("compression", None)
105
128
  payload.pop("rate", None)
129
+ payload.pop("strategy", None)
130
+ payload.pop("context", None)
106
131
  payload.pop("privacy", None)
132
+ payload.pop("sessionId", None)
133
+ payload.pop("userId", None)
107
134
 
108
135
  response = self.client.post("/chat/completions", json=payload, headers=headers)
109
136
  response.raise_for_status()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tokenbee-sdk
3
- Version: 1.2.2
3
+ Version: 1.3.0
4
4
  Summary: Official Python SDK for TokenBee LLM inference gateway and observability.
5
5
  Author: TokenBee Inc.
6
6
  Author-email: "TokenBee Inc." <founders@tokenbee.io>
@@ -73,20 +73,26 @@ TokenBee is a **stateless** gateway. We do not store your LLM provider API keys
73
73
 
74
74
  ### Compression Control
75
75
 
76
- You can specify the compression rate and method per request:
76
+ You can specify the compression rate and method per request. TokenBee uses an intelligent semantic engine to reduce token usage while preserving meaning.
77
77
 
78
78
  ```python
79
79
  response = client.send(
80
80
  model=TokenBeeModel.ANTHROPIC_CLAUDE_3_5_SONNET,
81
81
  input={
82
82
  "messages": [...],
83
- "compression": "on",
84
- "rate": CompressionRate.HIGH,
83
+ "compression": "auto", # "auto" (default), "on", or "off"
84
+ "rate": CompressionRate.HIGH, # MEDIUM (0.5), HIGH (0.33), etc.
85
85
  "privacy": True
86
86
  }
87
87
  )
88
88
  ```
89
89
 
90
+ - **`compression`**: Set to `"auto"` to let TokenBee decide when to compress, or `"off"` to bypass the compression engine entirely for high-precision tasks.
91
+ - **`rate`**: Controls the aggressiveness of compression. `HIGH` aims for ~67% token reduction.
92
+ - **`sessionId`**: (Optional) String ID to group multiple requests into a single replayable session in the dashboard.
93
+ - **`userId`**: (Optional) String ID to track usage and costs per unique end-user.
94
+ - **`privacy`**: (Optional) Set to `True` to disable payload logging and session replays for this request. Metadata (latency, tokens) will still be recorded for observability.
95
+
90
96
  ### Supported Models
91
97
 
92
98
  The SDK provides a `TokenBeeModel` enum with popular models:
File without changes