fenra 0.1.0__py3-none-any.whl → 0.1.2__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.
fenra/_core.py CHANGED
@@ -221,6 +221,21 @@ def enqueue_transaction(transaction: dict[str, Any]) -> None:
221
221
  if not config.enabled:
222
222
  return
223
223
 
224
+ # Ensure billable_customer_id is set (required by API)
225
+ if "context" not in transaction:
226
+ transaction["context"] = {}
227
+ if not transaction["context"].get("billable_customer_id"):
228
+ transaction["context"]["billable_customer_id"] = "unknown"
229
+ logger.warning(
230
+ "Fenra: billable_customer_id not set. "
231
+ "Use fenra.set_context(billable_customer_id='...') for customer attribution."
232
+ )
233
+
234
+ logger.debug(
235
+ f"Fenra: Enqueuing transaction - provider={transaction.get('provider')}, "
236
+ f"model={transaction.get('model')}, context={transaction.get('context')}"
237
+ )
238
+
224
239
  _get_queue().put_nowait(transaction)
225
240
  except queue.Full:
226
241
  logger.warning("Fenra transaction queue is full, dropping transaction")
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: fenra
3
- Version: 0.1.0
4
- Summary: Privacy-first AI cost tracking library
3
+ Version: 0.1.2
4
+ Summary: FinOps platform for AI cost visibility
5
5
  Author: Ajdin Ahmetovic
6
6
  Author-email: Ajdin Ahmetovic <ahmetovicajdin@gmail.com>
7
7
  Requires-Dist: requests>=2.28.0
@@ -13,7 +13,7 @@ Requires-Dist: mypy>=1.0.0 ; extra == 'dev'
13
13
  Requires-Dist: ruff>=0.1.0 ; extra == 'dev'
14
14
  Requires-Dist: google-genai>=1.0.0 ; extra == 'gemini'
15
15
  Requires-Dist: openai>=1.0.0 ; extra == 'openai'
16
- Requires-Python: >=3.11
16
+ Requires-Python: >=3.10
17
17
  Provides-Extra: all
18
18
  Provides-Extra: anthropic
19
19
  Provides-Extra: dev
@@ -22,7 +22,7 @@ Provides-Extra: openai
22
22
  Description-Content-Type: text/markdown
23
23
 
24
24
  <p align="center">
25
- <img src="https://fenra.io/fenra-text.svg" alt="Fenra" width="200">
25
+ <img src="https://assets.fenra.io/public/header.png" alt="Fenra" width="100%">
26
26
  </p>
27
27
 
28
28
  # Fenra Python SDK
@@ -57,7 +57,17 @@ response = client.chat.completions.create(
57
57
  )
58
58
  ```
59
59
 
60
- Works with Anthropic and Gemini the same way.
60
+ Works with Anthropic (Claude) and Google (Gemini) the same way.
61
+
62
+ Set context for cost attribution:
63
+
64
+ ```python
65
+ fenra.set_context(
66
+ billable_customer_id="cust_123", # recommended
67
+ environment="production",
68
+ feature="chat",
69
+ )
70
+ ```
61
71
 
62
72
  For custom providers or manual tracking:
63
73
 
@@ -76,6 +86,13 @@ To disable auto-tracking:
76
86
  export FENRA_DISABLE_AUTO_TRACK=1
77
87
  ```
78
88
 
89
+ To enable debug logging:
90
+
91
+ ```python
92
+ import logging
93
+ logging.getLogger("fenra").setLevel(logging.DEBUG)
94
+ ```
95
+
79
96
  ## Support
80
97
 
81
98
  - [Documentation](https://docs.fenra.io)
@@ -1,11 +1,11 @@
1
1
  fenra/__init__.py,sha256=Ca79xn2mRrRZDhUghMxUzhy9edqWcHdsrFm57P8KhoY,5138
2
2
  fenra/_context.py,sha256=x7zbjHUKTLMXw-n9appBtNPfZd_Ba3nKaHnCUkQ9yz8,1311
3
- fenra/_core.py,sha256=ij7aUAPG0_knUKSbhizDmaE5BsqEVTcH-j7QgKhrWpo,6915
3
+ fenra/_core.py,sha256=V0A9RNS_sGXlvEAbr1aZIOfSLKikuZwCrQPbW1sZeNY,7596
4
4
  fenra/integrations/__init__.py,sha256=oDeG8jysIubwSMbDvrGeTkf3A5GW171HDGqGt8VMZ_M,51
5
5
  fenra/integrations/anthropic/__init__.py,sha256=1_a3doBJEXT6G660J4EGzE1_8_Bz0CCfzsrX3uzIoTk,22461
6
6
  fenra/integrations/gemini/__init__.py,sha256=omKiqPG597WPQ4ShN7ovUfkhuZyJgC8cisg5iT06i1g,16625
7
7
  fenra/integrations/openai/__init__.py,sha256=xrynFDj3WgzXbHY5qghKlFCSzY16u3iwoLn-y5j1NdY,29537
8
8
  fenra/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- fenra-0.1.0.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
10
- fenra-0.1.0.dist-info/METADATA,sha256=ZXJvxjZIAvOl3HSYkshza_RXCBWGK6iZUEcRLsYV930,2237
11
- fenra-0.1.0.dist-info/RECORD,,
9
+ fenra-0.1.2.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
10
+ fenra-0.1.2.dist-info/METADATA,sha256=KeqZVA3yIhL47ueBxgJIe6Q08zS9XVnrmTSVwO3-HYQ,2546
11
+ fenra-0.1.2.dist-info/RECORD,,
File without changes