kalibr 1.1.3a0__py3-none-any.whl → 1.4.0__py3-none-any.whl

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.
kalibr/trace_capsule.py CHANGED
@@ -28,6 +28,7 @@ Usage:
28
28
  """
29
29
 
30
30
  import json
31
+ import threading
31
32
  import uuid
32
33
  from datetime import datetime, timezone
33
34
  from typing import Any, Dict, List, Optional
@@ -85,12 +86,16 @@ class TraceCapsule:
85
86
  # Phase 3C: Context token propagation (keep as UUID for consistency)
86
87
  self.context_token = context_token or str(uuid.uuid4())
87
88
  self.parent_context_token = parent_context_token
89
+ # Thread-safety: Lock for protecting concurrent append_hop operations
90
+ self._lock = threading.Lock()
88
91
 
89
92
  def append_hop(self, hop: Dict[str, Any]) -> None:
90
93
  """Append a new hop to the capsule.
91
94
 
92
95
  Maintains a rolling window of last N hops to keep payload compact.
93
96
  Updates aggregate metrics automatically.
97
+
98
+ Thread-safe: Uses internal lock to protect concurrent modifications.
94
99
 
95
100
  Args:
96
101
  hop: Dictionary containing hop metadata
@@ -111,22 +116,24 @@ class TraceCapsule:
111
116
  "agent_name": "code-writer"
112
117
  })
113
118
  """
114
- # Add hop_index
115
- hop["hop_index"] = len(self.last_n_hops)
119
+ # Thread-safe update of capsule state
120
+ with self._lock:
121
+ # Add hop_index
122
+ hop["hop_index"] = len(self.last_n_hops)
116
123
 
117
- # Append to history
118
- self.last_n_hops.append(hop)
124
+ # Append to history
125
+ self.last_n_hops.append(hop)
119
126
 
120
- # Maintain rolling window (keep last N hops)
121
- if len(self.last_n_hops) > self.MAX_HOPS:
122
- self.last_n_hops.pop(0)
127
+ # Maintain rolling window (keep last N hops)
128
+ if len(self.last_n_hops) > self.MAX_HOPS:
129
+ self.last_n_hops.pop(0)
123
130
 
124
- # Update aggregates
125
- self.aggregate_cost_usd += hop.get("cost_usd", 0.0)
126
- self.aggregate_latency_ms += hop.get("duration_ms", 0.0)
131
+ # Update aggregates
132
+ self.aggregate_cost_usd += hop.get("cost_usd", 0.0)
133
+ self.aggregate_latency_ms += hop.get("duration_ms", 0.0)
127
134
 
128
- # Update timestamp
129
- self.timestamp = datetime.now(timezone.utc).isoformat()
135
+ # Update timestamp
136
+ self.timestamp = datetime.now(timezone.utc).isoformat()
130
137
 
131
138
  def get_last_hop(self) -> Optional[Dict[str, Any]]:
132
139
  """Get the most recent hop.
kalibr/utils.py CHANGED
@@ -38,8 +38,8 @@ def load_config_from_env() -> Dict[str, str]:
38
38
  "workflow_id": os.getenv("KALIBR_WORKFLOW_ID", "default-workflow"),
39
39
  "sandbox_id": os.getenv("SANDBOX_ID", "local"),
40
40
  "runtime_env": os.getenv("RUNTIME_ENV", "local"),
41
- "api_endpoint": os.getenv("KALIBR_API_ENDPOINT", "https://api.kalibr.systems/api/v1/traces"),
42
- "collector_url": os.getenv("KALIBR_COLLECTOR_URL", "https://api.kalibr.systems/api/ingest"),
41
+ "api_endpoint": os.getenv("KALIBR_API_ENDPOINT", "https://kalibr-backend.fly.dev/api/v1/traces"),
42
+ "collector_url": os.getenv("KALIBR_COLLECTOR_URL", "https://kalibr-backend.fly.dev/api/ingest"),
43
43
  }
44
44
  return config
45
45
 
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 Kalibr Systems Inc.
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,306 @@
1
+ Metadata-Version: 2.2
2
+ Name: kalibr
3
+ Version: 1.4.0
4
+ Summary: Adaptive routing for AI agents. Learns which models work best and routes automatically.
5
+ Author-email: Kalibr Team <support@kalibr.systems>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/kalibr-ai/kalibr-sdk-python
8
+ Project-URL: Documentation, https://kalibr.systems/docs
9
+ Project-URL: Repository, https://github.com/kalibr-ai/kalibr-sdk-python
10
+ Project-URL: Issues, https://github.com/kalibr-ai/kalibr-sdk-python/issues
11
+ Keywords: ai,mcp,gpt,claude,gemini,copilot,openai,anthropic,google,microsoft,observability,telemetry,tracing,llm,schema-generation,api,multi-model,langchain,crewai
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: httpx>=0.27.0
25
+ Requires-Dist: fastapi>=0.110.1
26
+ Requires-Dist: uvicorn>=0.25.0
27
+ Requires-Dist: pydantic>=2.6.4
28
+ Requires-Dist: typer>=0.9.0
29
+ Requires-Dist: python-multipart>=0.0.9
30
+ Requires-Dist: rich>=10.0.0
31
+ Requires-Dist: requests>=2.31.0
32
+ Requires-Dist: opentelemetry-api>=1.20.0
33
+ Requires-Dist: opentelemetry-sdk>=1.20.0
34
+ Requires-Dist: opentelemetry-exporter-otlp>=1.20.0
35
+ Provides-Extra: tokens
36
+ Requires-Dist: tiktoken>=0.8.0; extra == "tokens"
37
+ Provides-Extra: langchain
38
+ Requires-Dist: langchain-core>=0.1.0; extra == "langchain"
39
+ Provides-Extra: langchain-openai
40
+ Requires-Dist: langchain-core>=0.1.0; extra == "langchain-openai"
41
+ Requires-Dist: langchain-openai>=0.1.0; extra == "langchain-openai"
42
+ Provides-Extra: langchain-anthropic
43
+ Requires-Dist: langchain-core>=0.1.0; extra == "langchain-anthropic"
44
+ Requires-Dist: langchain-anthropic>=0.1.0; extra == "langchain-anthropic"
45
+ Provides-Extra: langchain-google
46
+ Requires-Dist: langchain-core>=0.1.0; extra == "langchain-google"
47
+ Requires-Dist: langchain-google-genai>=0.0.10; extra == "langchain-google"
48
+ Provides-Extra: langchain-all
49
+ Requires-Dist: langchain-core>=0.1.0; extra == "langchain-all"
50
+ Requires-Dist: langchain-openai>=0.1.0; extra == "langchain-all"
51
+ Requires-Dist: langchain-anthropic>=0.1.0; extra == "langchain-all"
52
+ Requires-Dist: langchain-google-genai>=0.0.10; extra == "langchain-all"
53
+ Provides-Extra: crewai
54
+ Requires-Dist: crewai>=0.28.0; extra == "crewai"
55
+ Provides-Extra: openai-agents
56
+ Requires-Dist: openai-agents>=0.0.3; extra == "openai-agents"
57
+ Provides-Extra: integrations
58
+ Requires-Dist: langchain-core>=0.1.0; extra == "integrations"
59
+ Requires-Dist: crewai>=0.28.0; extra == "integrations"
60
+ Requires-Dist: openai-agents>=0.0.3; extra == "integrations"
61
+ Provides-Extra: dev
62
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
63
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
64
+ Requires-Dist: black>=23.0.0; extra == "dev"
65
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
66
+
67
+ # Kalibr
68
+
69
+ Adaptive routing for AI agents. Kalibr learns which models work best for your tasks and routes automatically.
70
+
71
+ [![PyPI](https://img.shields.io/pypi/v/kalibr)](https://pypi.org/project/kalibr/)
72
+ [![Python](https://img.shields.io/pypi/pyversions/kalibr)](https://pypi.org/project/kalibr/)
73
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
74
+
75
+ ## Requirements
76
+
77
+ - Python 3.10 or higher
78
+ - pip 21.0 or higher
79
+
80
+ ## Installation
81
+ ```bash
82
+ pip install kalibr
83
+ ```
84
+
85
+ For accurate token counting, install with:
86
+ ```bash
87
+ pip install kalibr[tokens]
88
+ ```
89
+
90
+ ## Setup
91
+
92
+ Get your credentials from [dashboard.kalibr.systems/settings](https://dashboard.kalibr.systems/settings), then:
93
+ ```bash
94
+ export KALIBR_API_KEY=your-api-key
95
+ export KALIBR_TENANT_ID=your-tenant-id
96
+ export OPENAI_API_KEY=sk-... # or ANTHROPIC_API_KEY for Claude models
97
+ ```
98
+
99
+ ## Quick Start
100
+ ```python
101
+ from kalibr import Router
102
+
103
+ router = Router(
104
+ goal="extract_company",
105
+ paths=["gpt-4o", "claude-sonnet-4-20250514"]
106
+ )
107
+
108
+ response = router.completion(
109
+ messages=[{"role": "user", "content": "Extract the company: Hi, I'm Sarah from Stripe."}]
110
+ )
111
+
112
+ router.report(success=True)
113
+ ```
114
+
115
+ Kalibr picks the best model, makes the call, and learns from the outcome.
116
+
117
+ ## How It Works
118
+
119
+ 1. **You define paths** - models (and optionally tools/params) that can handle your task
120
+ 2. **Kalibr picks** - uses Thompson Sampling to balance exploration vs exploitation
121
+ 3. **You report outcomes** - tell Kalibr if it worked
122
+ 4. **Kalibr learns** - routes more traffic to what works
123
+
124
+ ## Paths
125
+
126
+ A path is a model + optional tools + optional params:
127
+ ```python
128
+ # Just models
129
+ paths = ["gpt-4o", "claude-sonnet-4-20250514", "gpt-4o-mini"]
130
+
131
+ # With tools
132
+ paths = [
133
+ {"model": "gpt-4o", "tools": ["web_search"]},
134
+ {"model": "claude-sonnet-4-20250514", "tools": ["web_search", "browser"]},
135
+ ]
136
+
137
+ # With params
138
+ paths = [
139
+ {"model": "gpt-4o", "params": {"temperature": 0.7}},
140
+ {"model": "gpt-4o", "params": {"temperature": 0.2}},
141
+ ]
142
+ ```
143
+
144
+ ## Advanced Path Configuration
145
+
146
+ ### Routing Between Parameters
147
+
148
+ Kalibr can route between different parameter configurations of the same model:
149
+ ```python
150
+ from kalibr import Router
151
+
152
+ router = Router(
153
+ goal="creative_writing",
154
+ paths=[
155
+ {"model": "gpt-4o", "params": {"temperature": 0.3}},
156
+ {"model": "gpt-4o", "params": {"temperature": 0.9}},
157
+ {"model": "claude-sonnet-4-20250514", "params": {"temperature": 0.7}}
158
+ ]
159
+ )
160
+
161
+ response = router.completion(messages=[...])
162
+ router.report(success=True)
163
+ ```
164
+
165
+ Each unique `(model, params)` combination is tracked separately. Kalibr learns which configuration works best for your specific goal.
166
+
167
+ ### Routing Between Tools
168
+ ```python
169
+ router = Router(
170
+ goal="research_task",
171
+ paths=[
172
+ {"model": "gpt-4o", "tools": ["web_search"]},
173
+ {"model": "gpt-4o", "tools": ["code_interpreter"]},
174
+ {"model": "claude-sonnet-4-20250514"}
175
+ ]
176
+ )
177
+ ```
178
+
179
+ ### When to Use get_policy() Instead of Router
180
+
181
+ For most use cases, use `Router`. It handles provider dispatching and response conversion automatically.
182
+
183
+ Use `get_policy()` for advanced scenarios:
184
+ - Integrating with frameworks like LangChain that wrap LLM calls
185
+ - Custom retry logic or provider-specific features
186
+ - Building tools that need fine-grained control
187
+ ```python
188
+ from kalibr import get_policy, report_outcome
189
+
190
+ policy = get_policy(goal="summarize")
191
+ model = policy["recommended_model"]
192
+
193
+ # You call the provider yourself
194
+ if model.startswith("gpt"):
195
+ client = OpenAI()
196
+ response = client.chat.completions.create(model=model, messages=[...])
197
+
198
+ report_outcome(trace_id=trace_id, goal="summarize", success=True)
199
+ ```
200
+
201
+ ## Outcome Reporting
202
+
203
+ ### Automatic (with success_when)
204
+ ```python
205
+ router = Router(
206
+ goal="summarize",
207
+ paths=["gpt-4o", "claude-sonnet-4-20250514"],
208
+ success_when=lambda output: len(output) > 100
209
+ )
210
+
211
+ response = router.completion(messages=[...])
212
+ # Outcome reported automatically based on success_when
213
+ ```
214
+
215
+ ### Manual
216
+ ```python
217
+ router = Router(goal="book_meeting", paths=["gpt-4o", "claude-sonnet-4-20250514"])
218
+ response = router.completion(messages=[...])
219
+
220
+ meeting_created = check_calendar_api()
221
+ router.report(success=meeting_created)
222
+ ```
223
+
224
+ ## LangChain Integration
225
+ ```bash
226
+ pip install kalibr[langchain]
227
+ ```
228
+ ```python
229
+ from kalibr import Router
230
+
231
+ router = Router(goal="summarize", paths=["gpt-4o", "claude-sonnet-4-20250514"])
232
+ llm = router.as_langchain()
233
+
234
+ chain = prompt | llm | parser
235
+ ```
236
+
237
+ ## Auto-Instrumentation
238
+
239
+ Kalibr auto-instruments OpenAI, Anthropic, and Google SDKs on import:
240
+ ```python
241
+ import kalibr # Must be first import
242
+ from openai import OpenAI
243
+
244
+ client = OpenAI()
245
+ response = client.chat.completions.create(model="gpt-4o", messages=[...])
246
+ # Traced automatically
247
+ ```
248
+
249
+ Disable with `KALIBR_AUTO_INSTRUMENT=false`.
250
+
251
+ ## Low-Level API
252
+
253
+ For advanced use cases, you can use the intelligence API directly:
254
+ ```python
255
+ from kalibr import register_path, decide, report_outcome
256
+
257
+ # Register paths
258
+ register_path(goal="book_meeting", model_id="gpt-4o")
259
+ register_path(goal="book_meeting", model_id="claude-sonnet-4-20250514")
260
+
261
+ # Get routing decision
262
+ decision = decide(goal="book_meeting")
263
+ model = decision["model_id"]
264
+
265
+ # Make your own LLM call, then report
266
+ report_outcome(trace_id="...", goal="book_meeting", success=True)
267
+ ```
268
+
269
+ ## Other Integrations
270
+ ```bash
271
+ pip install kalibr[tokens] # Accurate token counting (tiktoken)
272
+ pip install kalibr[crewai] # CrewAI
273
+ pip install kalibr[openai-agents] # OpenAI Agents SDK
274
+ pip install kalibr[langchain-all] # LangChain with all providers
275
+ ```
276
+
277
+ ## Configuration
278
+
279
+ | Variable | Description | Default |
280
+ |----------|-------------|---------|
281
+ | `KALIBR_API_KEY` | API key from dashboard | Required |
282
+ | `KALIBR_TENANT_ID` | Tenant ID from dashboard | Required |
283
+ | `KALIBR_AUTO_INSTRUMENT` | Auto-instrument LLM SDKs | `true` |
284
+ | `KALIBR_INTELLIGENCE_URL` | Intelligence service URL | `https://kalibr-intelligence.fly.dev` |
285
+
286
+ ## Development
287
+ ```bash
288
+ git clone https://github.com/kalibr-ai/kalibr-sdk-python.git
289
+ cd kalibr-sdk-python
290
+ pip install -e ".[dev]"
291
+ pytest
292
+ ```
293
+
294
+ ## Contributing
295
+
296
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
297
+
298
+ ## License
299
+
300
+ Apache-2.0
301
+
302
+ ## Links
303
+
304
+ - [Docs](https://kalibr.systems/docs)
305
+ - [Dashboard](https://dashboard.kalibr.systems)
306
+ - [GitHub](https://github.com/kalibr-ai/kalibr-sdk-python)
@@ -0,0 +1,52 @@
1
+ kalibr/__init__.py,sha256=XyXmJHqHs3-bW8pbAMlJDrVjOD0X6-KvqcoI7YmGtPA,5189
2
+ kalibr/__main__.py,sha256=jO96I4pqinwHg7ONRvNVKbySBh5pSIhOAiNrgSQrNlY,110
3
+ kalibr/capsule_middleware.py,sha256=pXG_wORgCqo3wHjtkn_zY4doLyiDmTwJtB7XiZNnbPk,3163
4
+ kalibr/client.py,sha256=oiGN4DrdLuNVLFC_KEUjEYACcLAlcErAcB9dSyx2wYA,9736
5
+ kalibr/collector.py,sha256=2iQ_NQgO-rZHirwlWbfDWf_4koGSRoa_56ngattWvaU,12817
6
+ kalibr/context.py,sha256=FgN9-WyMQMDgg2Vqwje4r2_jKRvnMeI8t4fIE1VRn_8,4777
7
+ kalibr/cost_adapter.py,sha256=uHcJpndNx895EcY68YFSZisRnO8j4i13L3iskg4bIco,4484
8
+ kalibr/decorators.py,sha256=m-XBXxWMDVrzaNsljACiGmeGhgiHj_MqSfj6OGK3L5I,4380
9
+ kalibr/intelligence.py,sha256=Pky43AMB2VW4FogRvTtc2JXjvD2Ov9_TazHHb2byVXE,22865
10
+ kalibr/kalibr.py,sha256=cNXC3W_TX5SvGsy1lRopkwFqsHOpyd1kkVjEMOz1Yr4,6084
11
+ kalibr/kalibr_app.py,sha256=ItZwEh0FZPx9_BE-zPQajC2yxI2y9IHYwJD0k9tbHvY,2773
12
+ kalibr/models.py,sha256=HwD_-iysZMSnCzMQYO1Qcf0aeXySupY7yJeBwl_dLS0,1024
13
+ kalibr/pricing.py,sha256=wY0GzcrZdXuHlZoq2e74RkX0scd6somk_KYbr-RSHdE,8844
14
+ kalibr/redaction.py,sha256=XibxX4Lv1Ci0opE6Tb5ZI2GLbO0a8E9U66MAg60llnc,1139
15
+ kalibr/router.py,sha256=UCRw5qBzA46c1dmPnw05P2-_2DqnElSeeDhI2N3AD9A,20975
16
+ kalibr/schemas.py,sha256=XLZNLkXca6jbj9AF6gDIyGVnIcr1SVOsNYaKvW-wbgE,3669
17
+ kalibr/simple_tracer.py,sha256=oiwXtiYaIqZxqCNV-b79_dsiJT0D3XvKhNT_LF6bRD4,9736
18
+ kalibr/tokens.py,sha256=ug4y6h8gBaMLIfS0v9LQ-TzFaik5u5h4WANfOC7xV6U,1675
19
+ kalibr/trace_capsule.py,sha256=SEfTE-GXvM9kcGCOZ5uEQSD8AnbmRRA0UUu0X8c8isw,10492
20
+ kalibr/trace_models.py,sha256=9o7VJQk3gCrvdfXPrNh3Ptkq5sRgA9_qrLLE3jNkSBg,7304
21
+ kalibr/tracer.py,sha256=jwWBpZbGXn6fEv4pw25BLFCH-22QUbyzofPWp1Iwdkk,11911
22
+ kalibr/types.py,sha256=cna4-akpdwfHXfOJCtVIq5lO_jaoG2Am3BRrXi0Vo34,895
23
+ kalibr/utils.py,sha256=NQbC9ygJJWZUNfkUW7FheftraBs8QT6sDzwuNeQklxM,5060
24
+ kalibr/cli/__init__.py,sha256=FmRGaDMhM9DhrKg1ONkF0emIrJcjFWjlFBl_oenvpsk,77
25
+ kalibr/cli/capsule_cmd.py,sha256=I3vm5-V0T36ykiKunIxhbCdmxG4xMwFrFFC2pBfKD_0,6109
26
+ kalibr/cli/deploy_cmd.py,sha256=kV4uqCN2IdQev1vPBY5qqIHsEhjGBZ7y_rLx8RGAL_4,5178
27
+ kalibr/cli/main.py,sha256=FrOSIACNARkrvq-J2SZhyPNWNCdNEMZlD69PEV3uCMA,1924
28
+ kalibr/cli/run.py,sha256=ZbfJB2TtsLi-T2noKkAaRJMm6xfO6ytwTGAWEolqKE8,6441
29
+ kalibr/cli/serve.py,sha256=71Xha35qrBNkcQxuUkwC-ixbOriHGUIEgxl7C_qERQo,2085
30
+ kalibr/instrumentation/__init__.py,sha256=YnUJ4gUH8WNxdVv5t1amn0l2WUULJG2MuQIL2ZZhn04,354
31
+ kalibr/instrumentation/anthropic_instr.py,sha256=ChH4-0PSALwXl_UJnXzf1KsuyjpKjmxDepmP60AfAVs,9601
32
+ kalibr/instrumentation/base.py,sha256=EW3kRJo11HzuiOwgvJESSzk_Roo1r2oKz51c-PZH3KM,3666
33
+ kalibr/instrumentation/google_instr.py,sha256=hfczy4ofNtdqPujD7yUCWf-T3TztaNnK-vUajIVBxZo,10073
34
+ kalibr/instrumentation/openai_instr.py,sha256=qIXNzCZtco7kfWTL1u6fMojtLerZ0K_ilr8noj-wDkQ,9287
35
+ kalibr/instrumentation/registry.py,sha256=uOlbEDHmrlItFYV69ANSRzD_722Ym5cZ57dyejuDY1E,5645
36
+ kalibr/middleware/__init__.py,sha256=qyDUn_irAX67MS-IkuDVxg4RmFnJHDf_BfIT3qfGoBI,115
37
+ kalibr/middleware/auto_tracer.py,sha256=pFwGiwDhaEQ6x35TpMX8Y0DD2tjajO2JZADvkzlMVR0,13041
38
+ kalibr_crewai/__init__.py,sha256=b0HFTiE80eArtSMBOIEKu1JM6KU0tCjEylKCVVVF29Q,1796
39
+ kalibr_crewai/callbacks.py,sha256=_d1M4J-6XfKqrVIxnOgOQu57jpFKVv-VIsmPV0HNgZ4,20419
40
+ kalibr_crewai/instrumentor.py,sha256=-G_-xaqE3Op70MSEIaZjPYioGDxKRagwLbZmcmmvzFg,26793
41
+ kalibr_langchain/__init__.py,sha256=voHgdkcZ6oo336YK_uAFBHyOB11EBbnDS92UDoXRZiI,1448
42
+ kalibr_langchain/async_callback.py,sha256=_Mj_YrKbULNtfxixZ7iwiHyWEV9l178ZA5Oy5A5Pakk,27748
43
+ kalibr_langchain/callback.py,sha256=SNM1aHOXdG55grHmGyTwbXOeM6hjZTub2REiZD2H-d8,35216
44
+ kalibr_langchain/chat_model.py,sha256=Y4xsZGx9gZpDUF8NP-edJuYam4k0NBySdA6B5484MKk,3190
45
+ kalibr_openai_agents/__init__.py,sha256=wL59LzGstptKigfQDrKKt_7hcMO1JGVQtVAsE0lz-Zw,1367
46
+ kalibr_openai_agents/processor.py,sha256=F550sdRf3rpguP1yOlgAUQWDLPBy4hSACV3-zOyCpOU,18257
47
+ kalibr-1.4.0.dist-info/LICENSE,sha256=5mwAnB38l3_PjmOQn6_L6cZnJvus143DUjMBPIH1yso,10768
48
+ kalibr-1.4.0.dist-info/METADATA,sha256=xyDkq8f65JLaUddRwCzJf98L57w1MFrS7YPuh6OND14,9458
49
+ kalibr-1.4.0.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
50
+ kalibr-1.4.0.dist-info/entry_points.txt,sha256=Kojlc6WRX8V1qS9lOMdDPZpTUVHCtzGtHqXusErgmLY,47
51
+ kalibr-1.4.0.dist-info/top_level.txt,sha256=dIfBOWUnnHGFDwgz5zfIx5_0bU3wOUgAbYr4JcFHZmo,59
52
+ kalibr-1.4.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (76.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
kalibr_crewai/__init__.py CHANGED
@@ -46,7 +46,7 @@ Usage with Auto-Instrumentation:
46
46
 
47
47
  Environment Variables:
48
48
  KALIBR_API_KEY: API key for authentication
49
- KALIBR_ENDPOINT: Backend endpoint URL
49
+ KALIBR_COLLECTOR_URL: Backend endpoint URL
50
50
  KALIBR_TENANT_ID: Tenant identifier
51
51
  KALIBR_ENVIRONMENT: Environment (prod/staging/dev)
52
52
  KALIBR_SERVICE: Service name