conifer-sdk 0.1.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.
- conifer_sdk/__init__.py +132 -0
- conifer_sdk/client.py +956 -0
- conifer_sdk/errors.py +284 -0
- conifer_sdk/portability.py +555 -0
- conifer_sdk/receipt.py +113 -0
- conifer_sdk/receipts.py +252 -0
- conifer_sdk/types.py +279 -0
- conifer_sdk-0.1.0.dist-info/METADATA +580 -0
- conifer_sdk-0.1.0.dist-info/RECORD +11 -0
- conifer_sdk-0.1.0.dist-info/WHEEL +5 -0
- conifer_sdk-0.1.0.dist-info/top_level.txt +1 -0
conifer_sdk/__init__.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"""The Conifer gateway SDK for Python.
|
|
2
|
+
|
|
3
|
+
Same cards as the TypeScript SDK (``sdk/cards/``), same laws:
|
|
4
|
+
|
|
5
|
+
* the receipt is parsed absence-preserving — a header the gateway omitted stays
|
|
6
|
+
``None``, because zero-filling turns "we do not know" into a wrong number;
|
|
7
|
+
* retries are narrow (transport faults and 429/502/503/504 only) and always
|
|
8
|
+
carry one idempotency key, so a retry cannot double-bill;
|
|
9
|
+
* a portability input Conifer cannot honor raises rather than being dropped.
|
|
10
|
+
|
|
11
|
+
Standard library only, so ``pip install`` pulls no tree and the SDK works in a
|
|
12
|
+
lambda, a Slack bot, or a locked-down build image unchanged.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from .client import (
|
|
16
|
+
Conifer,
|
|
17
|
+
DEFAULT_BASE_URL,
|
|
18
|
+
DEFAULT_TIMEOUT_SECONDS,
|
|
19
|
+
MIN_DEFER_WINDOW_SECONDS,
|
|
20
|
+
decode_vector,
|
|
21
|
+
to_deferred_job,
|
|
22
|
+
with_cost,
|
|
23
|
+
turn_identity,
|
|
24
|
+
parse_frame,
|
|
25
|
+
resolve_base_url,
|
|
26
|
+
)
|
|
27
|
+
from .errors import (
|
|
28
|
+
ConiferAuthError,
|
|
29
|
+
ConiferBadRequestError,
|
|
30
|
+
ConiferByokKeyError,
|
|
31
|
+
ConiferConflictError,
|
|
32
|
+
ConiferConnectionError,
|
|
33
|
+
ConiferCostCeilingError,
|
|
34
|
+
ConiferKeySpendCapError,
|
|
35
|
+
ConiferError,
|
|
36
|
+
ConiferModelNotFoundError,
|
|
37
|
+
ConiferPaymentError,
|
|
38
|
+
ConiferPortabilityError,
|
|
39
|
+
ConiferRateLimitError,
|
|
40
|
+
ConiferTimeoutError,
|
|
41
|
+
ConiferUnavailableError,
|
|
42
|
+
ConiferUpstreamError,
|
|
43
|
+
error_from,
|
|
44
|
+
)
|
|
45
|
+
from .receipt import CostComponents, Receipt, nano_usd_to_usd_string, read_receipt
|
|
46
|
+
from .portability import (
|
|
47
|
+
attribution_from_openrouter,
|
|
48
|
+
ceiling_from_policy,
|
|
49
|
+
conifer_openai_compatible_config,
|
|
50
|
+
from_helicone_headers,
|
|
51
|
+
from_openrouter,
|
|
52
|
+
from_vercel_provider_options,
|
|
53
|
+
parse_fallbacks,
|
|
54
|
+
)
|
|
55
|
+
from .receipts import (
|
|
56
|
+
ObservedReceipt,
|
|
57
|
+
ReceiptCollector,
|
|
58
|
+
ReceiptTotal,
|
|
59
|
+
SpendBudget,
|
|
60
|
+
SpendBudgetExceeded,
|
|
61
|
+
)
|
|
62
|
+
from .types import (
|
|
63
|
+
Balance,
|
|
64
|
+
DeferredJob,
|
|
65
|
+
TERMINAL_JOB_STATUSES,
|
|
66
|
+
is_terminal_job,
|
|
67
|
+
CatalogModel,
|
|
68
|
+
ChatRequest,
|
|
69
|
+
Completion,
|
|
70
|
+
Embedding,
|
|
71
|
+
EmbeddingsRequest,
|
|
72
|
+
EmbeddingsResponse,
|
|
73
|
+
vector_of,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
__all__ = [
|
|
77
|
+
"Conifer",
|
|
78
|
+
"DEFAULT_BASE_URL",
|
|
79
|
+
"DEFAULT_TIMEOUT_SECONDS",
|
|
80
|
+
"resolve_base_url",
|
|
81
|
+
"parse_frame",
|
|
82
|
+
"decode_vector",
|
|
83
|
+
"ReceiptCollector",
|
|
84
|
+
"ObservedReceipt",
|
|
85
|
+
"ReceiptTotal",
|
|
86
|
+
"SpendBudget",
|
|
87
|
+
"SpendBudgetExceeded",
|
|
88
|
+
"MIN_DEFER_WINDOW_SECONDS",
|
|
89
|
+
"DeferredJob",
|
|
90
|
+
"TERMINAL_JOB_STATUSES",
|
|
91
|
+
"is_terminal_job",
|
|
92
|
+
"to_deferred_job",
|
|
93
|
+
"with_cost",
|
|
94
|
+
"turn_identity",
|
|
95
|
+
"Embedding",
|
|
96
|
+
"EmbeddingsRequest",
|
|
97
|
+
"EmbeddingsResponse",
|
|
98
|
+
"vector_of",
|
|
99
|
+
"ConiferError",
|
|
100
|
+
"ConiferAuthError",
|
|
101
|
+
"ConiferPaymentError",
|
|
102
|
+
"ConiferCostCeilingError",
|
|
103
|
+
"ConiferKeySpendCapError",
|
|
104
|
+
"ConiferBadRequestError",
|
|
105
|
+
"ConiferModelNotFoundError",
|
|
106
|
+
"ConiferConflictError",
|
|
107
|
+
"ConiferByokKeyError",
|
|
108
|
+
"ConiferRateLimitError",
|
|
109
|
+
"ConiferUpstreamError",
|
|
110
|
+
"ConiferUnavailableError",
|
|
111
|
+
"ConiferTimeoutError",
|
|
112
|
+
"ConiferConnectionError",
|
|
113
|
+
"ConiferPortabilityError",
|
|
114
|
+
"error_from",
|
|
115
|
+
"Receipt",
|
|
116
|
+
"CostComponents",
|
|
117
|
+
"read_receipt",
|
|
118
|
+
"nano_usd_to_usd_string",
|
|
119
|
+
"ChatRequest",
|
|
120
|
+
"Completion",
|
|
121
|
+
"CatalogModel",
|
|
122
|
+
"Balance",
|
|
123
|
+
"from_openrouter",
|
|
124
|
+
"attribution_from_openrouter",
|
|
125
|
+
"from_helicone_headers",
|
|
126
|
+
"from_vercel_provider_options",
|
|
127
|
+
"conifer_openai_compatible_config",
|
|
128
|
+
"ceiling_from_policy",
|
|
129
|
+
"parse_fallbacks",
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
__version__ = "0.1.0"
|