llm-optimizer 0.4.1__tar.gz → 0.4.2__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.
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/PKG-INFO +8 -4
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/README.md +7 -3
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/bedrock.py +5 -5
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/client.py +1 -1
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/pricing.json +224 -187
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer.egg-info/PKG-INFO +8 -4
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/pyproject.toml +1 -1
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/tests/test_llm_optimizer.py +6 -6
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/__init__.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/analytics.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/batcher.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/bedrock_cache.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/budget.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/cache.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/caching.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/cross_provider_cache.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/few_shot.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/history.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/models.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/optimizer.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/output_repair.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/pii.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/prefill.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/router.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/semantic_cache.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/streaming.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer/tracker.py +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer.egg-info/SOURCES.txt +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer.egg-info/dependency_links.txt +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer.egg-info/entry_points.txt +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer.egg-info/requires.txt +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/llm_optimizer.egg-info/top_level.txt +0 -0
- {llm_optimizer-0.4.1 → llm_optimizer-0.4.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: llm-optimizer
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: Reduce LLM API costs by up to 90% — prompt caching, smart routing, batch processing, and more
|
|
5
5
|
Author-email: Somnath Banerjee <banerjso30@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -500,7 +500,7 @@ from llm_optimizer.bedrock import make_bedrock_client
|
|
|
500
500
|
|
|
501
501
|
# Option 1 — AWS profile (local dev)
|
|
502
502
|
bedrock = make_bedrock_client(
|
|
503
|
-
profile_name="
|
|
503
|
+
profile_name="my-profile",
|
|
504
504
|
region="us-east-1",
|
|
505
505
|
discount_pct=16.0, # apply your negotiated AWS discount to cost estimates
|
|
506
506
|
enable_caching=True, # auto-translates cache_control → Bedrock cachePoint
|
|
@@ -866,6 +866,10 @@ tests/
|
|
|
866
866
|
|
|
867
867
|
## Changelog
|
|
868
868
|
|
|
869
|
+
### v0.4.2
|
|
870
|
+
|
|
871
|
+
- Sanitize docs, examples, and tests — replace org-specific AWS profile names with generic placeholders; Bedrock integration tests read `AWS_PROFILE` from the environment
|
|
872
|
+
|
|
869
873
|
### v0.4.1
|
|
870
874
|
|
|
871
875
|
- BUG FIX
|
|
@@ -894,7 +898,7 @@ tests/
|
|
|
894
898
|
- Bedrock cachePoint translation — auto-translates Anthropic `cache_control` → Bedrock `cachePoint` format
|
|
895
899
|
- TTL preservation on Bedrock — fixes open LiteLLM bug (GitHub #20326, Feb 2026)
|
|
896
900
|
- `make_bedrock_client()` accepts `enable_caching` and `cache_ttl` parameters
|
|
897
|
-
- Correct model IDs matching
|
|
901
|
+
- Correct model IDs matching Bedrock account format (`anthropic.claude-haiku-4-5-20251001-v1:0`)
|
|
898
902
|
- Negotiated discount support via `discount_pct`
|
|
899
903
|
|
|
900
904
|
**Test suite: 172 tests — all unit tests, no real API calls required**
|
|
@@ -916,7 +920,7 @@ tests/
|
|
|
916
920
|
### v0.3.0
|
|
917
921
|
|
|
918
922
|
- AWS Bedrock support — `BedrockClient` and `make_bedrock_client()` factory
|
|
919
|
-
- Both auth patterns — AWS profile (`profile_name="
|
|
923
|
+
- Both auth patterns — AWS profile (`profile_name="my-profile"`) and env vars / IAM role
|
|
920
924
|
- Bedrock pricing added to `pricing.json` with negotiated discount support
|
|
921
925
|
- `Provider.BEDROCK` added, Bedrock entries in `TIER_DEFAULTS` for all complexity tiers
|
|
922
926
|
- Note: Bedrock cachePoint translation was added in v0.4.0; this version stripped `cache_control` silently
|
|
@@ -461,7 +461,7 @@ from llm_optimizer.bedrock import make_bedrock_client
|
|
|
461
461
|
|
|
462
462
|
# Option 1 — AWS profile (local dev)
|
|
463
463
|
bedrock = make_bedrock_client(
|
|
464
|
-
profile_name="
|
|
464
|
+
profile_name="my-profile",
|
|
465
465
|
region="us-east-1",
|
|
466
466
|
discount_pct=16.0, # apply your negotiated AWS discount to cost estimates
|
|
467
467
|
enable_caching=True, # auto-translates cache_control → Bedrock cachePoint
|
|
@@ -827,6 +827,10 @@ tests/
|
|
|
827
827
|
|
|
828
828
|
## Changelog
|
|
829
829
|
|
|
830
|
+
### v0.4.2
|
|
831
|
+
|
|
832
|
+
- Sanitize docs, examples, and tests — replace org-specific AWS profile names with generic placeholders; Bedrock integration tests read `AWS_PROFILE` from the environment
|
|
833
|
+
|
|
830
834
|
### v0.4.1
|
|
831
835
|
|
|
832
836
|
- BUG FIX
|
|
@@ -855,7 +859,7 @@ tests/
|
|
|
855
859
|
- Bedrock cachePoint translation — auto-translates Anthropic `cache_control` → Bedrock `cachePoint` format
|
|
856
860
|
- TTL preservation on Bedrock — fixes open LiteLLM bug (GitHub #20326, Feb 2026)
|
|
857
861
|
- `make_bedrock_client()` accepts `enable_caching` and `cache_ttl` parameters
|
|
858
|
-
- Correct model IDs matching
|
|
862
|
+
- Correct model IDs matching Bedrock account format (`anthropic.claude-haiku-4-5-20251001-v1:0`)
|
|
859
863
|
- Negotiated discount support via `discount_pct`
|
|
860
864
|
|
|
861
865
|
**Test suite: 172 tests — all unit tests, no real API calls required**
|
|
@@ -877,7 +881,7 @@ tests/
|
|
|
877
881
|
### v0.3.0
|
|
878
882
|
|
|
879
883
|
- AWS Bedrock support — `BedrockClient` and `make_bedrock_client()` factory
|
|
880
|
-
- Both auth patterns — AWS profile (`profile_name="
|
|
884
|
+
- Both auth patterns — AWS profile (`profile_name="my-profile"`) and env vars / IAM role
|
|
881
885
|
- Bedrock pricing added to `pricing.json` with negotiated discount support
|
|
882
886
|
- `Provider.BEDROCK` added, Bedrock entries in `TIER_DEFAULTS` for all complexity tiers
|
|
883
887
|
- Note: Bedrock cachePoint translation was added in v0.4.0; this version stripped `cache_control` silently
|
|
@@ -11,7 +11,7 @@ Supports two auth patterns:
|
|
|
11
11
|
from llm_optimizer.bedrock import BedrockClient
|
|
12
12
|
|
|
13
13
|
client = OptimizedClient(
|
|
14
|
-
bedrock_client=BedrockClient(profile_name="
|
|
14
|
+
bedrock_client=BedrockClient(profile_name="my-profile", region="us-east-1"),
|
|
15
15
|
preferred_provider=Provider.BEDROCK,
|
|
16
16
|
)
|
|
17
17
|
|
|
@@ -83,7 +83,7 @@ class BedrockClient:
|
|
|
83
83
|
|
|
84
84
|
Args:
|
|
85
85
|
region: AWS region (default: us-east-1)
|
|
86
|
-
profile_name: AWS profile from ~/.aws/config (e.g. "
|
|
86
|
+
profile_name: AWS profile from ~/.aws/config (e.g. "my-profile")
|
|
87
87
|
session: Pre-configured boto3.Session — overrides profile_name
|
|
88
88
|
discount_pct: Your negotiated AWS discount (e.g. 16.0).
|
|
89
89
|
Applied to cost estimates only — does not affect API calls.
|
|
@@ -101,7 +101,7 @@ class BedrockClient:
|
|
|
101
101
|
"""
|
|
102
102
|
Args:
|
|
103
103
|
region: AWS region (default: us-east-1)
|
|
104
|
-
profile_name: AWS profile from ~/.aws/config (e.g. "
|
|
104
|
+
profile_name: AWS profile from ~/.aws/config (e.g. "my-profile")
|
|
105
105
|
session: Pre-configured boto3.Session — overrides profile_name
|
|
106
106
|
discount_pct: Negotiated AWS discount % for cost estimates (e.g. 16.0)
|
|
107
107
|
enable_caching: Enable Bedrock prompt caching (default: True)
|
|
@@ -360,10 +360,10 @@ def make_bedrock_client(
|
|
|
360
360
|
|
|
361
361
|
Usage:
|
|
362
362
|
# Profile-based (most team devs) — caching on by default
|
|
363
|
-
bedrock = make_bedrock_client(profile_name="
|
|
363
|
+
bedrock = make_bedrock_client(profile_name="my-profile", discount_pct=16.0)
|
|
364
364
|
|
|
365
365
|
# With 1-hour TTL (Claude 4.5 models only)
|
|
366
|
-
bedrock = make_bedrock_client(profile_name="
|
|
366
|
+
bedrock = make_bedrock_client(profile_name="my-profile", cache_ttl="1h")
|
|
367
367
|
|
|
368
368
|
# Env-var / IAM role (CI/CD, Lambda)
|
|
369
369
|
bedrock = make_bedrock_client()
|
|
@@ -871,7 +871,7 @@ class OptimizedClient:
|
|
|
871
871
|
raise RuntimeError(
|
|
872
872
|
"No Bedrock client. Pass bedrock_client=BedrockClient() to OptimizedClient.\n"
|
|
873
873
|
"from llm_optimizer.bedrock import BedrockClient\n"
|
|
874
|
-
"bedrock = BedrockClient(region='us-east-1', profile_name='
|
|
874
|
+
"bedrock = BedrockClient(region='us-east-1', profile_name='my-profile')"
|
|
875
875
|
)
|
|
876
876
|
return self._bedrock.messages.create(
|
|
877
877
|
model=model_config.model_id,
|
|
@@ -1,188 +1,225 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_meta": {
|
|
3
|
-
"version": "2026-07-
|
|
4
|
-
"last_updated": "2026-07-
|
|
5
|
-
"warning": "Provider pricing changes without notice. Verify at provider pricing pages before relying on cost estimates.",
|
|
6
|
-
"sources": {
|
|
7
|
-
"anthropic": "https://www.anthropic.com/pricing",
|
|
8
|
-
"openai": "https://openai.com/pricing",
|
|
9
|
-
"google": "https://ai.google.dev/pricing",
|
|
10
|
-
"bedrock": "https://aws.amazon.com/bedrock/pricing/"
|
|
11
|
-
},
|
|
12
|
-
"bedrock_note": "Bedrock prices = AWS list price. If your account has a negotiated discount (e.g. 16%), set discount_pct in BedrockClient to apply it to cost estimates."
|
|
13
|
-
},
|
|
14
|
-
"models": {
|
|
15
|
-
"claude-haiku-4-5": {
|
|
16
|
-
"model_id": "claude-haiku-4-5-20251001",
|
|
17
|
-
"provider": "anthropic",
|
|
18
|
-
"display_name": "Claude Haiku 4.5",
|
|
19
|
-
"input_cost_per_1m": 1.0,
|
|
20
|
-
"output_cost_per_1m": 5.0,
|
|
21
|
-
"cached_input_cost_per_1m": 0.1,
|
|
22
|
-
"context_window": 200000,
|
|
23
|
-
"supports_caching": true,
|
|
24
|
-
"supports_batch": true,
|
|
25
|
-
"complexity_tiers": [
|
|
26
|
-
"simple",
|
|
27
|
-
"medium"
|
|
28
|
-
],
|
|
29
|
-
"max_output_tokens": 8192
|
|
30
|
-
},
|
|
31
|
-
"claude-haiku-3-5": {
|
|
32
|
-
"model_id": "claude-haiku-3-5-20241022",
|
|
33
|
-
"provider": "anthropic",
|
|
34
|
-
"display_name": "Claude Haiku 3.5",
|
|
35
|
-
"input_cost_per_1m": 0.8,
|
|
36
|
-
"output_cost_per_1m": 4.0,
|
|
37
|
-
"cached_input_cost_per_1m": 0.08,
|
|
38
|
-
"context_window": 200000,
|
|
39
|
-
"supports_caching": true,
|
|
40
|
-
"supports_batch": true,
|
|
41
|
-
"complexity_tiers": [
|
|
42
|
-
"simple",
|
|
43
|
-
"medium"
|
|
44
|
-
],
|
|
45
|
-
"max_output_tokens": 8192
|
|
46
|
-
},
|
|
47
|
-
"claude-sonnet-4": {
|
|
48
|
-
"model_id": "claude-sonnet-4-5",
|
|
49
|
-
"provider": "anthropic",
|
|
50
|
-
"display_name": "Claude Sonnet 4.5",
|
|
51
|
-
"input_cost_per_1m": 3.0,
|
|
52
|
-
"output_cost_per_1m": 15.0,
|
|
53
|
-
"cached_input_cost_per_1m": 0.3,
|
|
54
|
-
"context_window": 200000,
|
|
55
|
-
"supports_caching": true,
|
|
56
|
-
"supports_batch": true,
|
|
57
|
-
"complexity_tiers": [
|
|
58
|
-
"simple",
|
|
59
|
-
"medium",
|
|
60
|
-
"complex"
|
|
61
|
-
],
|
|
62
|
-
"max_output_tokens": 8192
|
|
63
|
-
},
|
|
64
|
-
"claude-opus-4": {
|
|
65
|
-
"model_id": "claude-opus-4-5",
|
|
66
|
-
"provider": "anthropic",
|
|
67
|
-
"display_name": "Claude Opus 4.5",
|
|
68
|
-
"input_cost_per_1m": 5.0,
|
|
69
|
-
"output_cost_per_1m": 25.0,
|
|
70
|
-
"cached_input_cost_per_1m": 0.5,
|
|
71
|
-
"context_window": 200000,
|
|
72
|
-
"supports_caching": true,
|
|
73
|
-
"supports_batch": true,
|
|
74
|
-
"complexity_tiers": [
|
|
75
|
-
"simple",
|
|
76
|
-
"medium",
|
|
77
|
-
"complex",
|
|
78
|
-
"expert"
|
|
79
|
-
],
|
|
80
|
-
"max_output_tokens": 8192
|
|
81
|
-
},
|
|
82
|
-
"gpt-5-mini": {
|
|
83
|
-
"model_id": "gpt-5-mini",
|
|
84
|
-
"provider": "openai",
|
|
85
|
-
"display_name": "GPT-5 Mini",
|
|
86
|
-
"input_cost_per_1m": 0.25,
|
|
87
|
-
"output_cost_per_1m": 2.0,
|
|
88
|
-
"cached_input_cost_per_1m": 0.025,
|
|
89
|
-
"context_window": 400000,
|
|
90
|
-
"supports_caching": true,
|
|
91
|
-
"supports_batch": true,
|
|
92
|
-
"complexity_tiers": [
|
|
93
|
-
"simple",
|
|
94
|
-
"medium"
|
|
95
|
-
],
|
|
96
|
-
"max_output_tokens": 16384
|
|
97
|
-
},
|
|
98
|
-
"gpt-5": {
|
|
99
|
-
"model_id": "gpt-5",
|
|
100
|
-
"provider": "openai",
|
|
101
|
-
"display_name": "GPT-5",
|
|
102
|
-
"input_cost_per_1m": 2.5,
|
|
103
|
-
"output_cost_per_1m": 15.0,
|
|
104
|
-
"cached_input_cost_per_1m": 0.25,
|
|
105
|
-
"context_window": 1000000,
|
|
106
|
-
"supports_caching": true,
|
|
107
|
-
"supports_batch": true,
|
|
108
|
-
"complexity_tiers": [
|
|
109
|
-
"simple",
|
|
110
|
-
"medium",
|
|
111
|
-
"complex",
|
|
112
|
-
"expert"
|
|
113
|
-
],
|
|
114
|
-
"max_output_tokens": 32768
|
|
115
|
-
},
|
|
116
|
-
"gemini-flash": {
|
|
117
|
-
"model_id": "gemini-2.5-flash",
|
|
118
|
-
"provider": "google",
|
|
119
|
-
"display_name": "Gemini 2.5 Flash",
|
|
120
|
-
"input_cost_per_1m": 0.3,
|
|
121
|
-
"output_cost_per_1m": 2.5,
|
|
122
|
-
"cached_input_cost_per_1m": 0.03,
|
|
123
|
-
"context_window": 1000000,
|
|
124
|
-
"supports_caching": true,
|
|
125
|
-
"supports_batch": true,
|
|
126
|
-
"complexity_tiers": [
|
|
127
|
-
"simple",
|
|
128
|
-
"medium"
|
|
129
|
-
],
|
|
130
|
-
"max_output_tokens": 8192
|
|
131
|
-
},
|
|
132
|
-
"gemini-pro": {
|
|
133
|
-
"model_id": "gemini-2.5-pro",
|
|
134
|
-
"provider": "google",
|
|
135
|
-
"display_name": "Gemini 2.5 Pro",
|
|
136
|
-
"input_cost_per_1m": 1.25,
|
|
137
|
-
"output_cost_per_1m": 10.0,
|
|
138
|
-
"cached_input_cost_per_1m": 0.125,
|
|
139
|
-
"context_window": 2000000,
|
|
140
|
-
"supports_caching": true,
|
|
141
|
-
"supports_batch": true,
|
|
142
|
-
"complexity_tiers": [
|
|
143
|
-
"simple",
|
|
144
|
-
"medium",
|
|
145
|
-
"complex",
|
|
146
|
-
"expert"
|
|
147
|
-
],
|
|
148
|
-
"max_output_tokens": 8192
|
|
149
|
-
},
|
|
150
|
-
"bedrock-claude-haiku-4-5": {
|
|
151
|
-
"model_id": "anthropic.claude-haiku-4-5-20251001-v1:0",
|
|
152
|
-
"provider": "bedrock",
|
|
153
|
-
"display_name": "Claude Haiku 4.5 (Bedrock)",
|
|
154
|
-
"input_cost_per_1m": 0.8,
|
|
155
|
-
"output_cost_per_1m": 4.0,
|
|
156
|
-
"cached_input_cost_per_1m": 0.08,
|
|
157
|
-
"context_window": 200000,
|
|
158
|
-
"supports_caching": true,
|
|
159
|
-
"supports_batch": true,
|
|
160
|
-
"complexity_tiers": [
|
|
161
|
-
"simple",
|
|
162
|
-
"medium"
|
|
163
|
-
],
|
|
164
|
-
"max_output_tokens": 8192,
|
|
165
|
-
"notes": "Bedrock prompt caching supported via cachePoint format. Min 4,096 tokens. Auto-translated from cache_control by llm-optimizer. TTL: 5m (default) or 1h (Claude 4.5 models). Automatic caching NOT supported on Bedrock \u2014 explicit checkpoints injected.",
|
|
166
|
-
"cache_format": "bedrock_cachepoint"
|
|
167
|
-
},
|
|
168
|
-
"bedrock-claude-sonnet-4-5": {
|
|
169
|
-
"model_id": "anthropic.claude-sonnet-4-5-20250929-v1:0",
|
|
170
|
-
"provider": "bedrock",
|
|
171
|
-
"display_name": "Claude Sonnet 4.5 (Bedrock)",
|
|
172
|
-
"input_cost_per_1m": 3.0,
|
|
173
|
-
"output_cost_per_1m": 15.0,
|
|
174
|
-
"cached_input_cost_per_1m": 0.3,
|
|
175
|
-
"context_window": 200000,
|
|
176
|
-
"supports_caching": true,
|
|
177
|
-
"supports_batch": true,
|
|
178
|
-
"complexity_tiers": [
|
|
179
|
-
"simple",
|
|
180
|
-
"medium",
|
|
181
|
-
"complex"
|
|
182
|
-
],
|
|
183
|
-
"max_output_tokens": 8192,
|
|
184
|
-
"notes": "Bedrock prompt caching supported via cachePoint format. Min 4,096 tokens. Auto-translated from cache_control by llm-optimizer. TTL: 5m (default) or 1h (Claude 4.5 models). Automatic caching NOT supported on Bedrock \u2014 explicit checkpoints injected.",
|
|
185
|
-
"cache_format": "bedrock_cachepoint"
|
|
186
|
-
}
|
|
187
|
-
|
|
1
|
+
{
|
|
2
|
+
"_meta": {
|
|
3
|
+
"version": "2026-07-15",
|
|
4
|
+
"last_updated": "2026-07-15",
|
|
5
|
+
"warning": "Provider pricing changes without notice. Verify at provider pricing pages before relying on cost estimates.",
|
|
6
|
+
"sources": {
|
|
7
|
+
"anthropic": "https://www.anthropic.com/pricing",
|
|
8
|
+
"openai": "https://openai.com/pricing",
|
|
9
|
+
"google": "https://ai.google.dev/pricing",
|
|
10
|
+
"bedrock": "https://aws.amazon.com/bedrock/pricing/"
|
|
11
|
+
},
|
|
12
|
+
"bedrock_note": "Bedrock prices = AWS list price. If your account has a negotiated discount (e.g. 16%), set discount_pct in BedrockClient to apply it to cost estimates."
|
|
13
|
+
},
|
|
14
|
+
"models": {
|
|
15
|
+
"claude-haiku-4-5": {
|
|
16
|
+
"model_id": "claude-haiku-4-5-20251001",
|
|
17
|
+
"provider": "anthropic",
|
|
18
|
+
"display_name": "Claude Haiku 4.5",
|
|
19
|
+
"input_cost_per_1m": 1.0,
|
|
20
|
+
"output_cost_per_1m": 5.0,
|
|
21
|
+
"cached_input_cost_per_1m": 0.1,
|
|
22
|
+
"context_window": 200000,
|
|
23
|
+
"supports_caching": true,
|
|
24
|
+
"supports_batch": true,
|
|
25
|
+
"complexity_tiers": [
|
|
26
|
+
"simple",
|
|
27
|
+
"medium"
|
|
28
|
+
],
|
|
29
|
+
"max_output_tokens": 8192
|
|
30
|
+
},
|
|
31
|
+
"claude-haiku-3-5": {
|
|
32
|
+
"model_id": "claude-haiku-3-5-20241022",
|
|
33
|
+
"provider": "anthropic",
|
|
34
|
+
"display_name": "Claude Haiku 3.5",
|
|
35
|
+
"input_cost_per_1m": 0.8,
|
|
36
|
+
"output_cost_per_1m": 4.0,
|
|
37
|
+
"cached_input_cost_per_1m": 0.08,
|
|
38
|
+
"context_window": 200000,
|
|
39
|
+
"supports_caching": true,
|
|
40
|
+
"supports_batch": true,
|
|
41
|
+
"complexity_tiers": [
|
|
42
|
+
"simple",
|
|
43
|
+
"medium"
|
|
44
|
+
],
|
|
45
|
+
"max_output_tokens": 8192
|
|
46
|
+
},
|
|
47
|
+
"claude-sonnet-4": {
|
|
48
|
+
"model_id": "claude-sonnet-4-5",
|
|
49
|
+
"provider": "anthropic",
|
|
50
|
+
"display_name": "Claude Sonnet 4.5",
|
|
51
|
+
"input_cost_per_1m": 3.0,
|
|
52
|
+
"output_cost_per_1m": 15.0,
|
|
53
|
+
"cached_input_cost_per_1m": 0.3,
|
|
54
|
+
"context_window": 200000,
|
|
55
|
+
"supports_caching": true,
|
|
56
|
+
"supports_batch": true,
|
|
57
|
+
"complexity_tiers": [
|
|
58
|
+
"simple",
|
|
59
|
+
"medium",
|
|
60
|
+
"complex"
|
|
61
|
+
],
|
|
62
|
+
"max_output_tokens": 8192
|
|
63
|
+
},
|
|
64
|
+
"claude-opus-4": {
|
|
65
|
+
"model_id": "claude-opus-4-5",
|
|
66
|
+
"provider": "anthropic",
|
|
67
|
+
"display_name": "Claude Opus 4.5",
|
|
68
|
+
"input_cost_per_1m": 5.0,
|
|
69
|
+
"output_cost_per_1m": 25.0,
|
|
70
|
+
"cached_input_cost_per_1m": 0.5,
|
|
71
|
+
"context_window": 200000,
|
|
72
|
+
"supports_caching": true,
|
|
73
|
+
"supports_batch": true,
|
|
74
|
+
"complexity_tiers": [
|
|
75
|
+
"simple",
|
|
76
|
+
"medium",
|
|
77
|
+
"complex",
|
|
78
|
+
"expert"
|
|
79
|
+
],
|
|
80
|
+
"max_output_tokens": 8192
|
|
81
|
+
},
|
|
82
|
+
"gpt-5-mini": {
|
|
83
|
+
"model_id": "gpt-5-mini",
|
|
84
|
+
"provider": "openai",
|
|
85
|
+
"display_name": "GPT-5 Mini",
|
|
86
|
+
"input_cost_per_1m": 0.25,
|
|
87
|
+
"output_cost_per_1m": 2.0,
|
|
88
|
+
"cached_input_cost_per_1m": 0.025,
|
|
89
|
+
"context_window": 400000,
|
|
90
|
+
"supports_caching": true,
|
|
91
|
+
"supports_batch": true,
|
|
92
|
+
"complexity_tiers": [
|
|
93
|
+
"simple",
|
|
94
|
+
"medium"
|
|
95
|
+
],
|
|
96
|
+
"max_output_tokens": 16384
|
|
97
|
+
},
|
|
98
|
+
"gpt-5": {
|
|
99
|
+
"model_id": "gpt-5",
|
|
100
|
+
"provider": "openai",
|
|
101
|
+
"display_name": "GPT-5",
|
|
102
|
+
"input_cost_per_1m": 2.5,
|
|
103
|
+
"output_cost_per_1m": 15.0,
|
|
104
|
+
"cached_input_cost_per_1m": 0.25,
|
|
105
|
+
"context_window": 1000000,
|
|
106
|
+
"supports_caching": true,
|
|
107
|
+
"supports_batch": true,
|
|
108
|
+
"complexity_tiers": [
|
|
109
|
+
"simple",
|
|
110
|
+
"medium",
|
|
111
|
+
"complex",
|
|
112
|
+
"expert"
|
|
113
|
+
],
|
|
114
|
+
"max_output_tokens": 32768
|
|
115
|
+
},
|
|
116
|
+
"gemini-flash": {
|
|
117
|
+
"model_id": "gemini-2.5-flash",
|
|
118
|
+
"provider": "google",
|
|
119
|
+
"display_name": "Gemini 2.5 Flash",
|
|
120
|
+
"input_cost_per_1m": 0.3,
|
|
121
|
+
"output_cost_per_1m": 2.5,
|
|
122
|
+
"cached_input_cost_per_1m": 0.03,
|
|
123
|
+
"context_window": 1000000,
|
|
124
|
+
"supports_caching": true,
|
|
125
|
+
"supports_batch": true,
|
|
126
|
+
"complexity_tiers": [
|
|
127
|
+
"simple",
|
|
128
|
+
"medium"
|
|
129
|
+
],
|
|
130
|
+
"max_output_tokens": 8192
|
|
131
|
+
},
|
|
132
|
+
"gemini-pro": {
|
|
133
|
+
"model_id": "gemini-2.5-pro",
|
|
134
|
+
"provider": "google",
|
|
135
|
+
"display_name": "Gemini 2.5 Pro",
|
|
136
|
+
"input_cost_per_1m": 1.25,
|
|
137
|
+
"output_cost_per_1m": 10.0,
|
|
138
|
+
"cached_input_cost_per_1m": 0.125,
|
|
139
|
+
"context_window": 2000000,
|
|
140
|
+
"supports_caching": true,
|
|
141
|
+
"supports_batch": true,
|
|
142
|
+
"complexity_tiers": [
|
|
143
|
+
"simple",
|
|
144
|
+
"medium",
|
|
145
|
+
"complex",
|
|
146
|
+
"expert"
|
|
147
|
+
],
|
|
148
|
+
"max_output_tokens": 8192
|
|
149
|
+
},
|
|
150
|
+
"bedrock-claude-haiku-4-5": {
|
|
151
|
+
"model_id": "global.anthropic.claude-haiku-4-5-20251001-v1:0",
|
|
152
|
+
"provider": "bedrock",
|
|
153
|
+
"display_name": "Claude Haiku 4.5 (Bedrock)",
|
|
154
|
+
"input_cost_per_1m": 0.8,
|
|
155
|
+
"output_cost_per_1m": 4.0,
|
|
156
|
+
"cached_input_cost_per_1m": 0.08,
|
|
157
|
+
"context_window": 200000,
|
|
158
|
+
"supports_caching": true,
|
|
159
|
+
"supports_batch": true,
|
|
160
|
+
"complexity_tiers": [
|
|
161
|
+
"simple",
|
|
162
|
+
"medium"
|
|
163
|
+
],
|
|
164
|
+
"max_output_tokens": 8192,
|
|
165
|
+
"notes": "Bedrock prompt caching supported via cachePoint format. Min 4,096 tokens. Auto-translated from cache_control by llm-optimizer. TTL: 5m (default) or 1h (Claude 4.5 models). Automatic caching NOT supported on Bedrock \u2014 explicit checkpoints injected.",
|
|
166
|
+
"cache_format": "bedrock_cachepoint"
|
|
167
|
+
},
|
|
168
|
+
"bedrock-claude-sonnet-4-5": {
|
|
169
|
+
"model_id": "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
|
|
170
|
+
"provider": "bedrock",
|
|
171
|
+
"display_name": "Claude Sonnet 4.5 (Bedrock)",
|
|
172
|
+
"input_cost_per_1m": 3.0,
|
|
173
|
+
"output_cost_per_1m": 15.0,
|
|
174
|
+
"cached_input_cost_per_1m": 0.3,
|
|
175
|
+
"context_window": 200000,
|
|
176
|
+
"supports_caching": true,
|
|
177
|
+
"supports_batch": true,
|
|
178
|
+
"complexity_tiers": [
|
|
179
|
+
"simple",
|
|
180
|
+
"medium",
|
|
181
|
+
"complex"
|
|
182
|
+
],
|
|
183
|
+
"max_output_tokens": 8192,
|
|
184
|
+
"notes": "Bedrock prompt caching supported via cachePoint format. Min 4,096 tokens. Auto-translated from cache_control by llm-optimizer. TTL: 5m (default) or 1h (Claude 4.5 models). Automatic caching NOT supported on Bedrock \u2014 explicit checkpoints injected.",
|
|
185
|
+
"cache_format": "bedrock_cachepoint"
|
|
186
|
+
},
|
|
187
|
+
"bedrock-claude-sonnet-4-6": {
|
|
188
|
+
"model_id": "global.anthropic.claude-sonnet-4-6",
|
|
189
|
+
"provider": "bedrock",
|
|
190
|
+
"display_name": "Claude Sonnet 4.6 (Bedrock)",
|
|
191
|
+
"input_cost_per_1m": 3.0,
|
|
192
|
+
"output_cost_per_1m": 15.0,
|
|
193
|
+
"cached_input_cost_per_1m": 0.3,
|
|
194
|
+
"context_window": 200000,
|
|
195
|
+
"supports_caching": true,
|
|
196
|
+
"supports_batch": true,
|
|
197
|
+
"complexity_tiers": [
|
|
198
|
+
"simple",
|
|
199
|
+
"medium",
|
|
200
|
+
"complex"
|
|
201
|
+
],
|
|
202
|
+
"max_output_tokens": 8192,
|
|
203
|
+
"notes": "Cross-region inference profile for us-east-1"
|
|
204
|
+
},
|
|
205
|
+
"bedrock-claude-opus-4-5": {
|
|
206
|
+
"model_id": "us.anthropic.claude-opus-4-5-20251101-v1:0",
|
|
207
|
+
"provider": "bedrock",
|
|
208
|
+
"display_name": "Claude Opus 4.5 (Bedrock)",
|
|
209
|
+
"input_cost_per_1m": 5.0,
|
|
210
|
+
"output_cost_per_1m": 25.0,
|
|
211
|
+
"cached_input_cost_per_1m": 0.5,
|
|
212
|
+
"context_window": 200000,
|
|
213
|
+
"supports_caching": true,
|
|
214
|
+
"supports_batch": true,
|
|
215
|
+
"complexity_tiers": [
|
|
216
|
+
"simple",
|
|
217
|
+
"medium",
|
|
218
|
+
"complex",
|
|
219
|
+
"expert"
|
|
220
|
+
],
|
|
221
|
+
"max_output_tokens": 8192,
|
|
222
|
+
"notes": "Cross-region inference profile for us-east-1"
|
|
223
|
+
}
|
|
224
|
+
}
|
|
188
225
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: llm-optimizer
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: Reduce LLM API costs by up to 90% — prompt caching, smart routing, batch processing, and more
|
|
5
5
|
Author-email: Somnath Banerjee <banerjso30@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -500,7 +500,7 @@ from llm_optimizer.bedrock import make_bedrock_client
|
|
|
500
500
|
|
|
501
501
|
# Option 1 — AWS profile (local dev)
|
|
502
502
|
bedrock = make_bedrock_client(
|
|
503
|
-
profile_name="
|
|
503
|
+
profile_name="my-profile",
|
|
504
504
|
region="us-east-1",
|
|
505
505
|
discount_pct=16.0, # apply your negotiated AWS discount to cost estimates
|
|
506
506
|
enable_caching=True, # auto-translates cache_control → Bedrock cachePoint
|
|
@@ -866,6 +866,10 @@ tests/
|
|
|
866
866
|
|
|
867
867
|
## Changelog
|
|
868
868
|
|
|
869
|
+
### v0.4.2
|
|
870
|
+
|
|
871
|
+
- Sanitize docs, examples, and tests — replace org-specific AWS profile names with generic placeholders; Bedrock integration tests read `AWS_PROFILE` from the environment
|
|
872
|
+
|
|
869
873
|
### v0.4.1
|
|
870
874
|
|
|
871
875
|
- BUG FIX
|
|
@@ -894,7 +898,7 @@ tests/
|
|
|
894
898
|
- Bedrock cachePoint translation — auto-translates Anthropic `cache_control` → Bedrock `cachePoint` format
|
|
895
899
|
- TTL preservation on Bedrock — fixes open LiteLLM bug (GitHub #20326, Feb 2026)
|
|
896
900
|
- `make_bedrock_client()` accepts `enable_caching` and `cache_ttl` parameters
|
|
897
|
-
- Correct model IDs matching
|
|
901
|
+
- Correct model IDs matching Bedrock account format (`anthropic.claude-haiku-4-5-20251001-v1:0`)
|
|
898
902
|
- Negotiated discount support via `discount_pct`
|
|
899
903
|
|
|
900
904
|
**Test suite: 172 tests — all unit tests, no real API calls required**
|
|
@@ -916,7 +920,7 @@ tests/
|
|
|
916
920
|
### v0.3.0
|
|
917
921
|
|
|
918
922
|
- AWS Bedrock support — `BedrockClient` and `make_bedrock_client()` factory
|
|
919
|
-
- Both auth patterns — AWS profile (`profile_name="
|
|
923
|
+
- Both auth patterns — AWS profile (`profile_name="my-profile"`) and env vars / IAM role
|
|
920
924
|
- Bedrock pricing added to `pricing.json` with negotiated discount support
|
|
921
925
|
- `Provider.BEDROCK` added, Bedrock entries in `TIER_DEFAULTS` for all complexity tiers
|
|
922
926
|
- Note: Bedrock cachePoint translation was added in v0.4.0; this version stripped `cache_control` silently
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "llm-optimizer"
|
|
7
|
-
version = "0.4.
|
|
7
|
+
version = "0.4.2"
|
|
8
8
|
description = "Reduce LLM API costs by up to 90% — prompt caching, smart routing, batch processing, and more"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -582,9 +582,9 @@ class TestBedrockClient:
|
|
|
582
582
|
|
|
583
583
|
def test_instantiates_with_profile(self):
|
|
584
584
|
from llm_optimizer.bedrock import BedrockClient
|
|
585
|
-
c = BedrockClient(region="us-east-1", profile_name="
|
|
585
|
+
c = BedrockClient(region="us-east-1", profile_name="my-profile")
|
|
586
586
|
assert c.region == "us-east-1"
|
|
587
|
-
assert c._profile == "
|
|
587
|
+
assert c._profile == "my-profile"
|
|
588
588
|
|
|
589
589
|
def test_instantiates_without_profile(self):
|
|
590
590
|
"""Env vars / IAM role path — zero config."""
|
|
@@ -673,7 +673,7 @@ class TestBedrockClient:
|
|
|
673
673
|
import json
|
|
674
674
|
from unittest.mock import MagicMock
|
|
675
675
|
|
|
676
|
-
bedrock = BedrockClient(region="us-east-1", profile_name="
|
|
676
|
+
bedrock = BedrockClient(region="us-east-1", profile_name="my-profile")
|
|
677
677
|
bedrock._runtime = self._mock_runtime("Classified as SPAM")
|
|
678
678
|
|
|
679
679
|
client = OptimizedClient(
|
|
@@ -699,8 +699,8 @@ class TestBedrockClient:
|
|
|
699
699
|
|
|
700
700
|
def test_make_bedrock_client_factory(self):
|
|
701
701
|
from llm_optimizer.bedrock import make_bedrock_client
|
|
702
|
-
c = make_bedrock_client(profile_name="
|
|
703
|
-
assert c._profile == "
|
|
702
|
+
c = make_bedrock_client(profile_name="my-profile", discount_pct=16.0)
|
|
703
|
+
assert c._profile == "my-profile"
|
|
704
704
|
assert c.discount_pct == 16.0
|
|
705
705
|
|
|
706
706
|
def test_make_bedrock_client_no_args(self):
|
|
@@ -1223,7 +1223,7 @@ class TestBedrockCacheTranslation:
|
|
|
1223
1223
|
"""make_bedrock_client factory passes cache params through."""
|
|
1224
1224
|
from llm_optimizer.bedrock import make_bedrock_client
|
|
1225
1225
|
client = make_bedrock_client(
|
|
1226
|
-
profile_name="
|
|
1226
|
+
profile_name="my-profile",
|
|
1227
1227
|
enable_caching=True,
|
|
1228
1228
|
cache_ttl="1h",
|
|
1229
1229
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|