bedrock-wrapper 2.4.5 → 2.6.0

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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,23 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [2.6.0] - 2025-09-30 (Claude Sonnet 4.5)
5
+ ### Added
6
+ - Support for Claude Sonnet 4.5 models
7
+ - Claude-4-5-Sonnet
8
+ - Claude-4-5-Sonnet-Thinking
9
+
10
+ ## [2.5.0] - 2025-08-12 (Converse API)
11
+ ### Added
12
+ - Support for Converse API (streaming and non-streaming)
13
+
14
+ ### Technical Details
15
+ - **Model Configuration**: All models use standard messages API format
16
+ - **API Compatibility**: Supports OpenAI-style requests
17
+ - **Response Processing**: Automatic reasoning tag handling based on model variant
18
+ - **Streaming Fallback**: Automatic detection and fallback to non-streaming for unsupported models
19
+ - **Testing Coverage**: Full integration with existing test suites and interactive example
20
+
4
21
  ## [2.4.5] - 2025-08-06 (GPT-OSS Models)
5
22
  ### Added
6
23
  - Support for OpenAI GPT-OSS models on AWS Bedrock
package/README.md CHANGED
@@ -39,7 +39,7 @@ Bedrock Wrapper is an npm package that simplifies the integration of existing Op
39
39
  ```javascript
40
40
  const openaiChatCompletionsCreateObject = {
41
41
  "messages": messages,
42
- "model": "Llama-3-1-8b",
42
+ "model": "Claude-4.5-Sonnet",
43
43
  "max_tokens": LLM_MAX_GEN_TOKENS,
44
44
  "stream": true,
45
45
  "temperature": LLM_TEMPERATURE,
@@ -48,7 +48,7 @@ Bedrock Wrapper is an npm package that simplifies the integration of existing Op
48
48
  };
49
49
  ```
50
50
 
51
- the `messages` variable should be in openai's role/content format
51
+ the `messages` variable should be in openai's role/content format (not all models support system prompts)
52
52
  ```javascript
53
53
  messages = [
54
54
  {
@@ -98,6 +98,24 @@ Bedrock Wrapper is an npm package that simplifies the integration of existing Op
98
98
  console.log(`\n\completeResponse:\n${completeResponse}\n`); // ⇠ do stuff with the complete response
99
99
  }
100
100
 
101
+ 5. **NEW: Using the Converse API (optional)**
102
+
103
+ You can now optionally use AWS Bedrock's Converse API instead of the Invoke API by passing `useConverseAPI: true` in the options parameter:
104
+ ```javascript
105
+ // Use the Converse API for unified request/response format across all models
106
+ for await (const chunk of bedrockWrapper(awsCreds, openaiChatCompletionsCreateObject, { useConverseAPI: true })) {
107
+ completeResponse += chunk;
108
+ process.stdout.write(chunk);
109
+ }
110
+ ```
111
+
112
+ The Converse API provides:
113
+ - **Consistent API**: Single request/response format across all models
114
+ - **Simplified conversation management**: Better handling of multi-turn conversations
115
+ - **System prompts**: Cleaner separation of system instructions
116
+ - **Tool use support**: Native support for function calling (where supported)
117
+ - **Unified multimodal**: Consistent handling of text and image inputs
118
+
101
119
  ---
102
120
 
103
121
  ### Supported Models
@@ -108,6 +126,8 @@ Bedrock Wrapper is an npm package that simplifies the integration of existing Op
108
126
  | Claude-4-1-Opus-Thinking | us.anthropic.claude-opus-4-1-20250805-v1:0 | ✅ |
109
127
  | Claude-4-Opus | us.anthropic.claude-opus-4-20250514-v1:0 | ✅ |
110
128
  | Claude-4-Opus-Thinking | us.anthropic.claude-opus-4-20250514-v1:0 | ✅ |
129
+ | Claude-4.5-Sonnet | us.anthropic.claude-sonnet-4-5-20250929-v1:0 | ✅ |
130
+ | Claude-4.5-Sonnet-Thinking | us.anthropic.claude-sonnet-4-5-20250929-v1:0 | ✅ |
111
131
  | Claude-4-Sonnet | us.anthropic.claude-sonnet-4-20250514-v1:0 | ✅ |
112
132
  | Claude-4-Sonnet-Thinking | us.anthropic.claude-sonnet-4-20250514-v1:0 | ✅ |
113
133
  | Claude-3-7-Sonnet-Thinking | us.anthropic.claude-3-7-sonnet-20250219-v1:0 | ✅ |
@@ -150,7 +170,7 @@ Please modify the `bedrock_models.js` file and submit a PR 🏆 or create an Iss
150
170
 
151
171
  ### Image Support
152
172
 
153
- For models with image support (Claude 4 series, Claude 3.7 Sonnet, Claude 3.5 Sonnet, Claude 3 Haiku, Nova Pro, and Nova Lite), you can include images in your messages using the following format:
173
+ For models with image support (Claude 4+ series including Claude 4.5 Sonnet, Claude 3.7 Sonnet, Claude 3.5 Sonnet, Claude 3 Haiku, Nova Pro, and Nova Lite), you can include images in your messages using the following format (not all models support system prompts):
154
174
 
155
175
  ```javascript
156
176
  messages = [
@@ -239,6 +259,79 @@ const result = await bedrockWrapper(awsCreds, {
239
259
 
240
260
  ---
241
261
 
262
+ ### Parameter Restrictions
263
+
264
+ Some AWS Bedrock models have specific parameter restrictions that are automatically handled by the wrapper:
265
+
266
+ #### Claude 4+ Models (Temperature/Top-P Mutual Exclusion)
267
+
268
+ **Affected Models:**
269
+ - Claude-4.5-Sonnet & Claude-4.5-Sonnet-Thinking
270
+ - Claude-4-Sonnet & Claude-4-Sonnet-Thinking
271
+ - Claude-4-Opus & Claude-4-Opus-Thinking
272
+ - Claude-4-1-Opus & Claude-4-1-Opus-Thinking
273
+
274
+ **Restriction:** These models cannot accept both `temperature` and `top_p` parameters simultaneously.
275
+
276
+ **Automatic Handling:** When both parameters are provided, the wrapper automatically:
277
+ 1. **Keeps `temperature`** (prioritized as more commonly used)
278
+ 2. **Removes `top_p`** to prevent validation errors
279
+ 3. **Works with both APIs** (Invoke API and Converse API)
280
+
281
+ ```javascript
282
+ const request = {
283
+ messages: [{ role: "user", content: "Hello" }],
284
+ model: "Claude-4.5-Sonnet",
285
+ temperature: 0.7, // ✅ Kept
286
+ top_p: 0.9 // ❌ Automatically removed
287
+ };
288
+
289
+ // No error thrown - wrapper handles the restriction automatically
290
+ const response = await bedrockWrapper(awsCreds, request);
291
+ ```
292
+
293
+ **Why This Happens:** AWS Bedrock enforces this restriction on newer Claude models to ensure optimal performance and prevent conflicting sampling parameters.
294
+
295
+ ---
296
+
297
+ ### 🧪 Testing
298
+
299
+ The package includes comprehensive test suites to verify functionality:
300
+
301
+ ```bash
302
+ # Test all models with the Both APIs (Comparison)
303
+ npm run test
304
+
305
+ # Test all models with the Invoke API
306
+ npm run test:invoke
307
+
308
+ # Test all models with the Converse API
309
+ npm run test:converse
310
+
311
+ # Test vision/multimodal capabilities with Both APIs (Comparison)
312
+ npm run test-vision
313
+
314
+ # Test vision/multimodal capabilities with Invoke API
315
+ npm run test-vision:invoke
316
+
317
+ # Test vision/multimodal capabilities with Converse API
318
+ npm run test-vision:converse
319
+
320
+ # Test stop sequences functionality with Both APIs (Comparison)
321
+ npm run test-stop
322
+
323
+ # Test stop sequences functionality with Invoke API
324
+ npm run test-stop:invoke
325
+
326
+ # Test stop sequences functionality with Converse API
327
+ npm run test-stop:converse
328
+
329
+ # Interactive testing
330
+ npm run interactive
331
+ ```
332
+
333
+ ---
334
+
242
335
  ### 📢 P.S.
243
336
 
244
337
  In case you missed it at the beginning of this doc, for an even easier setup, use the 🔀 [Bedrock Proxy Endpoint](https://github.com/jparkerweb/bedrock-proxy-endpoint) project to spin up your own custom OpenAI server endpoint (using the standard `baseUrl`, and `apiKey` params).
package/bedrock-models.js CHANGED
@@ -126,6 +126,72 @@ export const bedrock_models = [
126
126
  "max_images_per_request": 10
127
127
  }
128
128
  },
129
+ {
130
+ // =======================
131
+ // == Claude 4.5 Sonnet ==
132
+ // =======================
133
+ "modelName": "Claude-4.5-Sonnet",
134
+ // "modelId": "anthropic.claude-sonnet-4-5-20250929-v1:0",
135
+ "modelId": "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
136
+ "vision": true,
137
+ "messages_api": true,
138
+ "system_as_separate_field": true,
139
+ "display_role_names": true,
140
+ "max_tokens_param_name": "max_tokens",
141
+ "max_supported_response_tokens": 131072,
142
+ "stop_sequences_param_name": "stop_sequences",
143
+ "response_chunk_element": "delta.text",
144
+ "response_nonchunk_element": "content[0].text",
145
+ "thinking_response_chunk_element": "delta.thinking",
146
+ "thinking_response_nonchunk_element": "content[0].thinking",
147
+ "parameter_restrictions": {
148
+ "mutually_exclusive": [["temperature", "top_p"]]
149
+ },
150
+ "special_request_schema": {
151
+ "anthropic_version": "bedrock-2023-05-31",
152
+ "anthropic_beta": ["output-128k-2025-02-19"],
153
+ },
154
+ "image_support": {
155
+ "max_image_size": 20971520, // 20MB
156
+ "supported_formats": ["jpeg", "png", "gif", "webp"],
157
+ "max_images_per_request": 10
158
+ }
159
+ },
160
+ {
161
+ // ================================
162
+ // == Claude 4.5 Sonnet Thinking ==
163
+ // ================================
164
+ "modelName": "Claude-4.5-Sonnet-Thinking",
165
+ // "modelId": "anthropic.claude-sonnet-4-5-20250929-v1:0",
166
+ "modelId": "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
167
+ "vision": true,
168
+ "messages_api": true,
169
+ "system_as_separate_field": true,
170
+ "display_role_names": true,
171
+ "max_tokens_param_name": "max_tokens",
172
+ "max_supported_response_tokens": 131072,
173
+ "stop_sequences_param_name": "stop_sequences",
174
+ "response_chunk_element": "delta.text",
175
+ "response_nonchunk_element": "content[0].text",
176
+ "thinking_response_chunk_element": "delta.thinking",
177
+ "thinking_response_nonchunk_element": "content[0].thinking",
178
+ "parameter_restrictions": {
179
+ "mutually_exclusive": [["temperature", "top_p"]]
180
+ },
181
+ "special_request_schema": {
182
+ "anthropic_version": "bedrock-2023-05-31",
183
+ "anthropic_beta": ["output-128k-2025-02-19"],
184
+ "thinking": {
185
+ "type": "enabled",
186
+ "budget_tokens": 16000
187
+ },
188
+ },
189
+ "image_support": {
190
+ "max_image_size": 20971520, // 20MB
191
+ "supported_formats": ["jpeg", "png", "gif", "webp"],
192
+ "max_images_per_request": 10
193
+ }
194
+ },
129
195
  {
130
196
  // =====================
131
197
  // == Claude 4 Sonnet ==
@@ -144,6 +210,9 @@ export const bedrock_models = [
144
210
  "response_nonchunk_element": "content[0].text",
145
211
  "thinking_response_chunk_element": "delta.thinking",
146
212
  "thinking_response_nonchunk_element": "content[0].thinking",
213
+ "parameter_restrictions": {
214
+ "mutually_exclusive": [["temperature", "top_p"]]
215
+ },
147
216
  "special_request_schema": {
148
217
  "anthropic_version": "bedrock-2023-05-31",
149
218
  "anthropic_beta": ["output-128k-2025-02-19"],
@@ -172,6 +241,9 @@ export const bedrock_models = [
172
241
  "response_nonchunk_element": "content[0].text",
173
242
  "thinking_response_chunk_element": "delta.thinking",
174
243
  "thinking_response_nonchunk_element": "content[0].thinking",
244
+ "parameter_restrictions": {
245
+ "mutually_exclusive": [["temperature", "top_p"]]
246
+ },
175
247
  "special_request_schema": {
176
248
  "anthropic_version": "bedrock-2023-05-31",
177
249
  "anthropic_beta": ["output-128k-2025-02-19"],