tokenbee-sdk 0.1.0__tar.gz → 0.2.1__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,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tokenbee-sdk
3
- Version: 0.1.0
3
+ Version: 0.2.1
4
4
  Summary: Official Python SDK for TokenBee LLM inference gateway and observability.
5
5
  Author: TokenBee Inc.
6
- Author-email: "TokenBee Inc." <hello@tokenbee.dev>
6
+ Author-email: "TokenBee Inc." <founders@tokenbee.io>
7
7
  Classifier: Programming Language :: Python :: 3
8
8
  Classifier: License :: OSI Approved :: MIT License
9
9
  Classifier: Operating System :: OS Independent
@@ -35,9 +35,11 @@ pip install tokenbee-sdk
35
35
  ```python
36
36
  from tokenbee import TokenBee, TokenBeeModel, CompressionRate
37
37
 
38
- # Initialize the client
38
+ # Initialize the client with your TokenBee API key
39
+ # AND your LLM provider key (Bring Your Own Key - BYOK)
39
40
  client = TokenBee(
40
- api_key="your_api_key_here",
41
+ api_key="your_tokenbee_api_key",
42
+ llm_key="your_llm_provider_key", # e.g. OpenAI or Anthropic key
41
43
  compression="auto",
42
44
  rate=CompressionRate.MEDIUM
43
45
  )
@@ -55,6 +57,10 @@ response = client.send(
55
57
  print(response["choices"][0]["message"]["content"])
56
58
  ```
57
59
 
60
+ ## Bring Your Own Key (BYOK)
61
+
62
+ 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.
63
+
58
64
  ## Advanced Usage
59
65
 
60
66
  ### Compression Control
@@ -1,72 +1,78 @@
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
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 with your TokenBee API key
24
+ # AND your LLM provider key (Bring Your Own Key - BYOK)
25
+ client = TokenBee(
26
+ api_key="your_tokenbee_api_key",
27
+ llm_key="your_llm_provider_key", # e.g. OpenAI or Anthropic key
28
+ compression="auto",
29
+ rate=CompressionRate.MEDIUM
30
+ )
31
+
32
+ # Send a request
33
+ response = client.send(
34
+ model=TokenBeeModel.OPENAI_GPT_4O,
35
+ input={
36
+ "messages": [
37
+ {"role": "user", "content": "Explain quantum entanglement in simple terms."}
38
+ ]
39
+ }
40
+ )
41
+
42
+ print(response["choices"][0]["message"]["content"])
43
+ ```
44
+
45
+ ## Bring Your Own Key (BYOK)
46
+
47
+ 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.
48
+
49
+ ## Advanced Usage
50
+
51
+ ### Compression Control
52
+
53
+ You can specify the compression rate and method per request:
54
+
55
+ ```python
56
+ response = client.send(
57
+ model=TokenBeeModel.ANTHROPIC_CLAUDE_3_5_SONNET,
58
+ input={
59
+ "messages": [...],
60
+ "compression": "on",
61
+ "rate": CompressionRate.HIGH,
62
+ "privacy": True
63
+ }
64
+ )
65
+ ```
66
+
67
+ ### Supported Models
68
+
69
+ The SDK provides a `TokenBeeModel` enum with popular models:
70
+
71
+ - `TokenBeeModel.OPENAI_GPT_4O`
72
+ - `TokenBeeModel.ANTHROPIC_CLAUDE_3_5_SONNET`
73
+ - `TokenBeeModel.GEMINI_2_0_FLASH`
74
+ - ... and many others.
75
+
76
+ ## License
77
+
78
+ MIT
@@ -1,22 +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
-
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "tokenbee-sdk"
7
+ version = "0.2.1"
8
+ authors = [
9
+ { name="TokenBee Inc.", email="founders@tokenbee.io" },
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
+
@@ -1,23 +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
- ],
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.2.1",
10
+ packages=find_packages(),
11
+ install_requires=["httpx>=0.23.0"],
12
+ author="TokenBee Inc.",
13
+ author_email="founders@tokenbee.io",
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
23
  )
@@ -1,99 +1,102 @@
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()
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
+ llm_key: str,
55
+ base_url: str = "https://api.tokenbee.dev/v1",
56
+ compression: str = "auto",
57
+ rate: str = CompressionRate.MEDIUM,
58
+ model: str = "",
59
+ provider: str = "",
60
+ privacy: bool = False
61
+ ):
62
+ self.api_key = api_key
63
+ self.llm_key = llm_key
64
+ self.base_url = base_url
65
+ self.headers = {
66
+ "Authorization": f"Bearer {api_key}",
67
+ "X-LLM-Key": llm_key,
68
+ "X-TokenBee-Compression": compression,
69
+ "X-TokenBee-Rate": rate,
70
+ "X-TokenBee-Privacy": str(privacy).lower()
71
+ }
72
+ if model:
73
+ self.headers["X-TokenBee-Model"] = model
74
+ if provider:
75
+ self.headers["X-TokenBee-Provider"] = provider
76
+
77
+ self.client = httpx.Client(headers=self.headers, base_url=self.base_url)
78
+
79
+ def send(self, model: str, input: dict):
80
+ parts = model.split("/")
81
+ provider = parts[0] if len(parts) > 1 else self.headers.get("X-TokenBee-Provider", "openai")
82
+ model_name = "/".join(parts[1:]) if len(parts) > 1 else parts[0]
83
+
84
+ headers = self.headers.copy()
85
+ headers["X-TokenBee-Model"] = model_name
86
+ headers["X-TokenBee-Provider"] = provider
87
+
88
+ if "compression" in input:
89
+ headers["X-TokenBee-Compression"] = str(input["compression"])
90
+ if "rate" in input:
91
+ headers["X-TokenBee-Rate"] = str(input["rate"])
92
+ if "privacy" in input:
93
+ headers["X-TokenBee-Privacy"] = str(input["privacy"]).lower()
94
+
95
+ payload = input.copy()
96
+ payload.pop("compression", None)
97
+ payload.pop("rate", None)
98
+ payload.pop("privacy", None)
99
+
100
+ response = self.client.post("/chat/completions", json=payload, headers=headers)
101
+ response.raise_for_status()
102
+ return response.json()
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tokenbee-sdk
3
- Version: 0.1.0
3
+ Version: 0.2.1
4
4
  Summary: Official Python SDK for TokenBee LLM inference gateway and observability.
5
5
  Author: TokenBee Inc.
6
- Author-email: "TokenBee Inc." <hello@tokenbee.dev>
6
+ Author-email: "TokenBee Inc." <founders@tokenbee.io>
7
7
  Classifier: Programming Language :: Python :: 3
8
8
  Classifier: License :: OSI Approved :: MIT License
9
9
  Classifier: Operating System :: OS Independent
@@ -35,9 +35,11 @@ pip install tokenbee-sdk
35
35
  ```python
36
36
  from tokenbee import TokenBee, TokenBeeModel, CompressionRate
37
37
 
38
- # Initialize the client
38
+ # Initialize the client with your TokenBee API key
39
+ # AND your LLM provider key (Bring Your Own Key - BYOK)
39
40
  client = TokenBee(
40
- api_key="your_api_key_here",
41
+ api_key="your_tokenbee_api_key",
42
+ llm_key="your_llm_provider_key", # e.g. OpenAI or Anthropic key
41
43
  compression="auto",
42
44
  rate=CompressionRate.MEDIUM
43
45
  )
@@ -55,6 +57,10 @@ response = client.send(
55
57
  print(response["choices"][0]["message"]["content"])
56
58
  ```
57
59
 
60
+ ## Bring Your Own Key (BYOK)
61
+
62
+ 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.
63
+
58
64
  ## Advanced Usage
59
65
 
60
66
  ### Compression Control
File without changes