@aws-sdk/client-bedrock-runtime 3.863.0 → 3.872.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/README.md CHANGED
@@ -226,6 +226,14 @@ ConverseStream
226
226
 
227
227
  [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-runtime/command/ConverseStreamCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/ConverseStreamCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/ConverseStreamCommandOutput/)
228
228
 
229
+ </details>
230
+ <details>
231
+ <summary>
232
+ CountTokens
233
+ </summary>
234
+
235
+ [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-runtime/command/CountTokensCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/CountTokensCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/CountTokensCommandOutput/)
236
+
229
237
  </details>
230
238
  <details>
231
239
  <summary>
package/dist-cjs/index.js CHANGED
@@ -57,7 +57,12 @@ __export(index_exports, {
57
57
  ConverseStreamRequestFilterSensitiveLog: () => ConverseStreamRequestFilterSensitiveLog,
58
58
  ConverseStreamResponseFilterSensitiveLog: () => ConverseStreamResponseFilterSensitiveLog,
59
59
  ConverseStreamTraceFilterSensitiveLog: () => ConverseStreamTraceFilterSensitiveLog,
60
+ ConverseTokensRequestFilterSensitiveLog: () => ConverseTokensRequestFilterSensitiveLog,
60
61
  ConverseTraceFilterSensitiveLog: () => ConverseTraceFilterSensitiveLog,
62
+ CountTokensCommand: () => CountTokensCommand,
63
+ CountTokensInput: () => CountTokensInput,
64
+ CountTokensInputFilterSensitiveLog: () => CountTokensInputFilterSensitiveLog,
65
+ CountTokensRequestFilterSensitiveLog: () => CountTokensRequestFilterSensitiveLog,
61
66
  DocumentContentBlock: () => DocumentContentBlock,
62
67
  DocumentFormat: () => DocumentFormat,
63
68
  DocumentSource: () => DocumentSource,
@@ -117,6 +122,7 @@ __export(index_exports, {
117
122
  InvokeModelCommand: () => InvokeModelCommand,
118
123
  InvokeModelRequestFilterSensitiveLog: () => InvokeModelRequestFilterSensitiveLog,
119
124
  InvokeModelResponseFilterSensitiveLog: () => InvokeModelResponseFilterSensitiveLog,
125
+ InvokeModelTokensRequestFilterSensitiveLog: () => InvokeModelTokensRequestFilterSensitiveLog,
120
126
  InvokeModelWithBidirectionalStreamCommand: () => InvokeModelWithBidirectionalStreamCommand,
121
127
  InvokeModelWithBidirectionalStreamInput: () => InvokeModelWithBidirectionalStreamInput,
122
128
  InvokeModelWithBidirectionalStreamInputFilterSensitiveLog: () => InvokeModelWithBidirectionalStreamInputFilterSensitiveLog,
@@ -1061,6 +1067,14 @@ var ResponseStream;
1061
1067
  return visitor._(value.$unknown[0], value.$unknown[1]);
1062
1068
  }, "visit");
1063
1069
  })(ResponseStream || (ResponseStream = {}));
1070
+ var CountTokensInput;
1071
+ ((CountTokensInput2) => {
1072
+ CountTokensInput2.visit = /* @__PURE__ */ __name((value, visitor) => {
1073
+ if (value.invokeModel !== void 0) return visitor.invokeModel(value.invokeModel);
1074
+ if (value.converse !== void 0) return visitor.converse(value.converse);
1075
+ return visitor._(value.$unknown[0], value.$unknown[1]);
1076
+ }, "visit");
1077
+ })(CountTokensInput || (CountTokensInput = {}));
1064
1078
  var GetAsyncInvokeResponseFilterSensitiveLog = /* @__PURE__ */ __name((obj) => ({
1065
1079
  ...obj,
1066
1080
  ...obj.failureMessage && { failureMessage: import_smithy_client.SENSITIVE_STRING },
@@ -1414,6 +1428,25 @@ var InvokeModelWithResponseStreamResponseFilterSensitiveLog = /* @__PURE__ */ __
1414
1428
  ...obj,
1415
1429
  ...obj.body && { body: "STREAMING_CONTENT" }
1416
1430
  }), "InvokeModelWithResponseStreamResponseFilterSensitiveLog");
1431
+ var ConverseTokensRequestFilterSensitiveLog = /* @__PURE__ */ __name((obj) => ({
1432
+ ...obj,
1433
+ ...obj.messages && { messages: obj.messages.map((item) => MessageFilterSensitiveLog(item)) },
1434
+ ...obj.system && { system: obj.system.map((item) => SystemContentBlockFilterSensitiveLog(item)) }
1435
+ }), "ConverseTokensRequestFilterSensitiveLog");
1436
+ var InvokeModelTokensRequestFilterSensitiveLog = /* @__PURE__ */ __name((obj) => ({
1437
+ ...obj,
1438
+ ...obj.body && { body: import_smithy_client.SENSITIVE_STRING }
1439
+ }), "InvokeModelTokensRequestFilterSensitiveLog");
1440
+ var CountTokensInputFilterSensitiveLog = /* @__PURE__ */ __name((obj) => {
1441
+ if (obj.invokeModel !== void 0)
1442
+ return { invokeModel: InvokeModelTokensRequestFilterSensitiveLog(obj.invokeModel) };
1443
+ if (obj.converse !== void 0) return { converse: ConverseTokensRequestFilterSensitiveLog(obj.converse) };
1444
+ if (obj.$unknown !== void 0) return { [obj.$unknown[0]]: "UNKNOWN" };
1445
+ }, "CountTokensInputFilterSensitiveLog");
1446
+ var CountTokensRequestFilterSensitiveLog = /* @__PURE__ */ __name((obj) => ({
1447
+ ...obj,
1448
+ ...obj.input && { input: CountTokensInputFilterSensitiveLog(obj.input) }
1449
+ }), "CountTokensRequestFilterSensitiveLog");
1417
1450
 
1418
1451
  // src/protocols/Aws_restJson1.ts
1419
1452
  var import_core2 = require("@aws-sdk/core");
@@ -1489,6 +1522,22 @@ var se_ConverseStreamCommand = /* @__PURE__ */ __name(async (input, context) =>
1489
1522
  b.m("POST").h(headers).b(body);
1490
1523
  return b.build();
1491
1524
  }, "se_ConverseStreamCommand");
1525
+ var se_CountTokensCommand = /* @__PURE__ */ __name(async (input, context) => {
1526
+ const b = (0, import_core.requestBuilder)(input, context);
1527
+ const headers = {
1528
+ "content-type": "application/json"
1529
+ };
1530
+ b.bp("/model/{modelId}/count-tokens");
1531
+ b.p("modelId", () => input.modelId, "{modelId}", false);
1532
+ let body;
1533
+ body = JSON.stringify(
1534
+ (0, import_smithy_client.take)(input, {
1535
+ input: /* @__PURE__ */ __name((_) => se_CountTokensInput(_, context), "input")
1536
+ })
1537
+ );
1538
+ b.m("POST").h(headers).b(body);
1539
+ return b.build();
1540
+ }, "se_CountTokensCommand");
1492
1541
  var se_GetAsyncInvokeCommand = /* @__PURE__ */ __name(async (input, context) => {
1493
1542
  const b = (0, import_core.requestBuilder)(input, context);
1494
1543
  const headers = {};
@@ -1636,6 +1685,20 @@ var de_ConverseStreamCommand = /* @__PURE__ */ __name(async (output, context) =>
1636
1685
  contents.stream = de_ConverseStreamOutput(data, context);
1637
1686
  return contents;
1638
1687
  }, "de_ConverseStreamCommand");
1688
+ var de_CountTokensCommand = /* @__PURE__ */ __name(async (output, context) => {
1689
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
1690
+ return de_CommandError(output, context);
1691
+ }
1692
+ const contents = (0, import_smithy_client.map)({
1693
+ $metadata: deserializeMetadata(output)
1694
+ });
1695
+ const data = (0, import_smithy_client.expectNonNull)((0, import_smithy_client.expectObject)(await (0, import_core2.parseJsonBody)(output.body, context)), "body");
1696
+ const doc = (0, import_smithy_client.take)(data, {
1697
+ inputTokens: import_smithy_client.expectInt32
1698
+ });
1699
+ Object.assign(contents, doc);
1700
+ return contents;
1701
+ }, "de_CountTokensCommand");
1639
1702
  var de_GetAsyncInvokeCommand = /* @__PURE__ */ __name(async (output, context) => {
1640
1703
  if (output.statusCode !== 200 && output.statusCode >= 300) {
1641
1704
  return de_CommandError(output, context);
@@ -2228,6 +2291,19 @@ var se_ContentBlocks = /* @__PURE__ */ __name((input, context) => {
2228
2291
  return se_ContentBlock(entry, context);
2229
2292
  });
2230
2293
  }, "se_ContentBlocks");
2294
+ var se_ConverseTokensRequest = /* @__PURE__ */ __name((input, context) => {
2295
+ return (0, import_smithy_client.take)(input, {
2296
+ messages: /* @__PURE__ */ __name((_) => se_Messages(_, context), "messages"),
2297
+ system: /* @__PURE__ */ __name((_) => se_SystemContentBlocks(_, context), "system")
2298
+ });
2299
+ }, "se_ConverseTokensRequest");
2300
+ var se_CountTokensInput = /* @__PURE__ */ __name((input, context) => {
2301
+ return CountTokensInput.visit(input, {
2302
+ converse: /* @__PURE__ */ __name((value) => ({ converse: se_ConverseTokensRequest(value, context) }), "converse"),
2303
+ invokeModel: /* @__PURE__ */ __name((value) => ({ invokeModel: se_InvokeModelTokensRequest(value, context) }), "invokeModel"),
2304
+ _: /* @__PURE__ */ __name((name, value) => ({ [name]: value }), "_")
2305
+ });
2306
+ }, "se_CountTokensInput");
2231
2307
  var se_DocumentBlock = /* @__PURE__ */ __name((input, context) => {
2232
2308
  return (0, import_smithy_client.take)(input, {
2233
2309
  citations: import_smithy_client._json,
@@ -2310,6 +2386,11 @@ var se_InferenceConfiguration = /* @__PURE__ */ __name((input, context) => {
2310
2386
  topP: import_smithy_client.serializeFloat
2311
2387
  });
2312
2388
  }, "se_InferenceConfiguration");
2389
+ var se_InvokeModelTokensRequest = /* @__PURE__ */ __name((input, context) => {
2390
+ return (0, import_smithy_client.take)(input, {
2391
+ body: context.base64Encoder
2392
+ });
2393
+ }, "se_InvokeModelTokensRequest");
2313
2394
  var se_Message = /* @__PURE__ */ __name((input, context) => {
2314
2395
  return (0, import_smithy_client.take)(input, {
2315
2396
  content: /* @__PURE__ */ __name((_) => se_ContentBlocks(_, context), "content"),
@@ -2997,6 +3078,21 @@ var ConverseStreamCommand = class extends import_smithy_client.Command.classBuil
2997
3078
  }
2998
3079
  };
2999
3080
 
3081
+ // src/commands/CountTokensCommand.ts
3082
+
3083
+
3084
+
3085
+ var CountTokensCommand = class extends import_smithy_client.Command.classBuilder().ep(commonParams).m(function(Command, cs, config, o) {
3086
+ return [
3087
+ (0, import_middleware_serde.getSerdePlugin)(config, this.serialize, this.deserialize),
3088
+ (0, import_middleware_endpoint.getEndpointPlugin)(config, Command.getEndpointParameterInstructions())
3089
+ ];
3090
+ }).s("AmazonBedrockFrontendService", "CountTokens", {}).n("BedrockRuntimeClient", "CountTokensCommand").f(CountTokensRequestFilterSensitiveLog, void 0).ser(se_CountTokensCommand).de(de_CountTokensCommand).build() {
3091
+ static {
3092
+ __name(this, "CountTokensCommand");
3093
+ }
3094
+ };
3095
+
3000
3096
  // src/commands/GetAsyncInvokeCommand.ts
3001
3097
 
3002
3098
 
@@ -3116,6 +3212,7 @@ var commands = {
3116
3212
  ApplyGuardrailCommand,
3117
3213
  ConverseCommand,
3118
3214
  ConverseStreamCommand,
3215
+ CountTokensCommand,
3119
3216
  GetAsyncInvokeCommand,
3120
3217
  InvokeModelCommand,
3121
3218
  InvokeModelWithBidirectionalStreamCommand,
@@ -3144,6 +3241,7 @@ var paginateListAsyncInvokes = (0, import_core.createPaginator)(BedrockRuntimeCl
3144
3241
  ApplyGuardrailCommand,
3145
3242
  ConverseCommand,
3146
3243
  ConverseStreamCommand,
3244
+ CountTokensCommand,
3147
3245
  GetAsyncInvokeCommand,
3148
3246
  InvokeModelCommand,
3149
3247
  InvokeModelWithBidirectionalStreamCommand,
@@ -3226,6 +3324,7 @@ var paginateListAsyncInvokes = (0, import_core.createPaginator)(BedrockRuntimeCl
3226
3324
  InvokeModelWithBidirectionalStreamInput,
3227
3325
  InvokeModelWithBidirectionalStreamOutput,
3228
3326
  ResponseStream,
3327
+ CountTokensInput,
3229
3328
  GetAsyncInvokeResponseFilterSensitiveLog,
3230
3329
  AsyncInvokeSummaryFilterSensitiveLog,
3231
3330
  ListAsyncInvokesResponseFilterSensitiveLog,
@@ -3281,6 +3380,10 @@ var paginateListAsyncInvokes = (0, import_core.createPaginator)(BedrockRuntimeCl
3281
3380
  InvokeModelWithResponseStreamRequestFilterSensitiveLog,
3282
3381
  PayloadPartFilterSensitiveLog,
3283
3382
  ResponseStreamFilterSensitiveLog,
3284
- InvokeModelWithResponseStreamResponseFilterSensitiveLog
3383
+ InvokeModelWithResponseStreamResponseFilterSensitiveLog,
3384
+ ConverseTokensRequestFilterSensitiveLog,
3385
+ InvokeModelTokensRequestFilterSensitiveLog,
3386
+ CountTokensInputFilterSensitiveLog,
3387
+ CountTokensRequestFilterSensitiveLog
3285
3388
  });
3286
3389
 
@@ -3,6 +3,7 @@ import { BedrockRuntimeClient } from "./BedrockRuntimeClient";
3
3
  import { ApplyGuardrailCommand, } from "./commands/ApplyGuardrailCommand";
4
4
  import { ConverseCommand } from "./commands/ConverseCommand";
5
5
  import { ConverseStreamCommand, } from "./commands/ConverseStreamCommand";
6
+ import { CountTokensCommand } from "./commands/CountTokensCommand";
6
7
  import { GetAsyncInvokeCommand, } from "./commands/GetAsyncInvokeCommand";
7
8
  import { InvokeModelCommand } from "./commands/InvokeModelCommand";
8
9
  import { InvokeModelWithBidirectionalStreamCommand, } from "./commands/InvokeModelWithBidirectionalStreamCommand";
@@ -13,6 +14,7 @@ const commands = {
13
14
  ApplyGuardrailCommand,
14
15
  ConverseCommand,
15
16
  ConverseStreamCommand,
17
+ CountTokensCommand,
16
18
  GetAsyncInvokeCommand,
17
19
  InvokeModelCommand,
18
20
  InvokeModelWithBidirectionalStreamCommand,
@@ -0,0 +1,23 @@
1
+ import { getEndpointPlugin } from "@smithy/middleware-endpoint";
2
+ import { getSerdePlugin } from "@smithy/middleware-serde";
3
+ import { Command as $Command } from "@smithy/smithy-client";
4
+ import { commonParams } from "../endpoint/EndpointParameters";
5
+ import { CountTokensRequestFilterSensitiveLog } from "../models/models_0";
6
+ import { de_CountTokensCommand, se_CountTokensCommand } from "../protocols/Aws_restJson1";
7
+ export { $Command };
8
+ export class CountTokensCommand extends $Command
9
+ .classBuilder()
10
+ .ep(commonParams)
11
+ .m(function (Command, cs, config, o) {
12
+ return [
13
+ getSerdePlugin(config, this.serialize, this.deserialize),
14
+ getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
15
+ ];
16
+ })
17
+ .s("AmazonBedrockFrontendService", "CountTokens", {})
18
+ .n("BedrockRuntimeClient", "CountTokensCommand")
19
+ .f(CountTokensRequestFilterSensitiveLog, void 0)
20
+ .ser(se_CountTokensCommand)
21
+ .de(de_CountTokensCommand)
22
+ .build() {
23
+ }
@@ -1,6 +1,7 @@
1
1
  export * from "./ApplyGuardrailCommand";
2
2
  export * from "./ConverseCommand";
3
3
  export * from "./ConverseStreamCommand";
4
+ export * from "./CountTokensCommand";
4
5
  export * from "./GetAsyncInvokeCommand";
5
6
  export * from "./InvokeModelCommand";
6
7
  export * from "./InvokeModelWithBidirectionalStreamCommand";
@@ -702,6 +702,16 @@ export var ResponseStream;
702
702
  return visitor._(value.$unknown[0], value.$unknown[1]);
703
703
  };
704
704
  })(ResponseStream || (ResponseStream = {}));
705
+ export var CountTokensInput;
706
+ (function (CountTokensInput) {
707
+ CountTokensInput.visit = (value, visitor) => {
708
+ if (value.invokeModel !== undefined)
709
+ return visitor.invokeModel(value.invokeModel);
710
+ if (value.converse !== undefined)
711
+ return visitor.converse(value.converse);
712
+ return visitor._(value.$unknown[0], value.$unknown[1]);
713
+ };
714
+ })(CountTokensInput || (CountTokensInput = {}));
705
715
  export const GetAsyncInvokeResponseFilterSensitiveLog = (obj) => ({
706
716
  ...obj,
707
717
  ...(obj.failureMessage && { failureMessage: SENSITIVE_STRING }),
@@ -1108,3 +1118,24 @@ export const InvokeModelWithResponseStreamResponseFilterSensitiveLog = (obj) =>
1108
1118
  ...obj,
1109
1119
  ...(obj.body && { body: "STREAMING_CONTENT" }),
1110
1120
  });
1121
+ export const ConverseTokensRequestFilterSensitiveLog = (obj) => ({
1122
+ ...obj,
1123
+ ...(obj.messages && { messages: obj.messages.map((item) => MessageFilterSensitiveLog(item)) }),
1124
+ ...(obj.system && { system: obj.system.map((item) => SystemContentBlockFilterSensitiveLog(item)) }),
1125
+ });
1126
+ export const InvokeModelTokensRequestFilterSensitiveLog = (obj) => ({
1127
+ ...obj,
1128
+ ...(obj.body && { body: SENSITIVE_STRING }),
1129
+ });
1130
+ export const CountTokensInputFilterSensitiveLog = (obj) => {
1131
+ if (obj.invokeModel !== undefined)
1132
+ return { invokeModel: InvokeModelTokensRequestFilterSensitiveLog(obj.invokeModel) };
1133
+ if (obj.converse !== undefined)
1134
+ return { converse: ConverseTokensRequestFilterSensitiveLog(obj.converse) };
1135
+ if (obj.$unknown !== undefined)
1136
+ return { [obj.$unknown[0]]: "UNKNOWN" };
1137
+ };
1138
+ export const CountTokensRequestFilterSensitiveLog = (obj) => ({
1139
+ ...obj,
1140
+ ...(obj.input && { input: CountTokensInputFilterSensitiveLog(obj.input) }),
1141
+ });
@@ -3,7 +3,7 @@ import { requestBuilder as rb } from "@smithy/core";
3
3
  import { _json, collectBody, decorateServiceException as __decorateServiceException, expectBoolean as __expectBoolean, expectInt32 as __expectInt32, expectNonNull as __expectNonNull, expectObject as __expectObject, expectString as __expectString, isSerializableHeaderValue, limitedParseDouble as __limitedParseDouble, map, parseRfc3339DateTimeWithOffset as __parseRfc3339DateTimeWithOffset, serializeDateTime as __serializeDateTime, serializeFloat as __serializeFloat, take, withBaseException, } from "@smithy/smithy-client";
4
4
  import { v4 as generateIdempotencyToken } from "uuid";
5
5
  import { BedrockRuntimeServiceException as __BaseException } from "../models/BedrockRuntimeServiceException";
6
- import { AccessDeniedException, ConflictException, ContentBlock, DocumentSource, GuardrailContentBlock, GuardrailConverseContentBlock, GuardrailConverseImageSource, GuardrailImageSource, ImageSource, InternalServerException, InvokeModelWithBidirectionalStreamInput, ModelErrorException, ModelNotReadyException, ModelStreamErrorException, ModelTimeoutException, ReasoningContentBlock, ResourceNotFoundException, ServiceQuotaExceededException, ServiceUnavailableException, SystemContentBlock, ThrottlingException, Tool, ToolInputSchema, ToolResultContentBlock, ValidationException, VideoSource, } from "../models/models_0";
6
+ import { AccessDeniedException, ConflictException, ContentBlock, CountTokensInput, DocumentSource, GuardrailContentBlock, GuardrailConverseContentBlock, GuardrailConverseImageSource, GuardrailImageSource, ImageSource, InternalServerException, InvokeModelWithBidirectionalStreamInput, ModelErrorException, ModelNotReadyException, ModelStreamErrorException, ModelTimeoutException, ReasoningContentBlock, ResourceNotFoundException, ServiceQuotaExceededException, ServiceUnavailableException, SystemContentBlock, ThrottlingException, Tool, ToolInputSchema, ToolResultContentBlock, ValidationException, VideoSource, } from "../models/models_0";
7
7
  export const se_ApplyGuardrailCommand = async (input, context) => {
8
8
  const b = rb(input, context);
9
9
  const headers = {
@@ -67,6 +67,20 @@ export const se_ConverseStreamCommand = async (input, context) => {
67
67
  b.m("POST").h(headers).b(body);
68
68
  return b.build();
69
69
  };
70
+ export const se_CountTokensCommand = async (input, context) => {
71
+ const b = rb(input, context);
72
+ const headers = {
73
+ "content-type": "application/json",
74
+ };
75
+ b.bp("/model/{modelId}/count-tokens");
76
+ b.p("modelId", () => input.modelId, "{modelId}", false);
77
+ let body;
78
+ body = JSON.stringify(take(input, {
79
+ input: (_) => se_CountTokensInput(_, context),
80
+ }));
81
+ b.m("POST").h(headers).b(body);
82
+ return b.build();
83
+ };
70
84
  export const se_GetAsyncInvokeCommand = async (input, context) => {
71
85
  const b = rb(input, context);
72
86
  const headers = {};
@@ -212,6 +226,20 @@ export const de_ConverseStreamCommand = async (output, context) => {
212
226
  contents.stream = de_ConverseStreamOutput(data, context);
213
227
  return contents;
214
228
  };
229
+ export const de_CountTokensCommand = async (output, context) => {
230
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
231
+ return de_CommandError(output, context);
232
+ }
233
+ const contents = map({
234
+ $metadata: deserializeMetadata(output),
235
+ });
236
+ const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
237
+ const doc = take(data, {
238
+ inputTokens: __expectInt32,
239
+ });
240
+ Object.assign(contents, doc);
241
+ return contents;
242
+ };
215
243
  export const de_GetAsyncInvokeCommand = async (output, context) => {
216
244
  if (output.statusCode !== 200 && output.statusCode >= 300) {
217
245
  return de_CommandError(output, context);
@@ -788,6 +816,19 @@ const se_ContentBlocks = (input, context) => {
788
816
  return se_ContentBlock(entry, context);
789
817
  });
790
818
  };
819
+ const se_ConverseTokensRequest = (input, context) => {
820
+ return take(input, {
821
+ messages: (_) => se_Messages(_, context),
822
+ system: (_) => se_SystemContentBlocks(_, context),
823
+ });
824
+ };
825
+ const se_CountTokensInput = (input, context) => {
826
+ return CountTokensInput.visit(input, {
827
+ converse: (value) => ({ converse: se_ConverseTokensRequest(value, context) }),
828
+ invokeModel: (value) => ({ invokeModel: se_InvokeModelTokensRequest(value, context) }),
829
+ _: (name, value) => ({ [name]: value }),
830
+ });
831
+ };
791
832
  const se_DocumentBlock = (input, context) => {
792
833
  return take(input, {
793
834
  citations: _json,
@@ -872,6 +913,11 @@ const se_InferenceConfiguration = (input, context) => {
872
913
  topP: __serializeFloat,
873
914
  });
874
915
  };
916
+ const se_InvokeModelTokensRequest = (input, context) => {
917
+ return take(input, {
918
+ body: context.base64Encoder,
919
+ });
920
+ };
875
921
  const se_Message = (input, context) => {
876
922
  return take(input, {
877
923
  content: (_) => se_ContentBlocks(_, context),
@@ -3,6 +3,7 @@ import { BedrockRuntimeClient } from "./BedrockRuntimeClient";
3
3
  import { ApplyGuardrailCommandInput, ApplyGuardrailCommandOutput } from "./commands/ApplyGuardrailCommand";
4
4
  import { ConverseCommandInput, ConverseCommandOutput } from "./commands/ConverseCommand";
5
5
  import { ConverseStreamCommandInput, ConverseStreamCommandOutput } from "./commands/ConverseStreamCommand";
6
+ import { CountTokensCommandInput, CountTokensCommandOutput } from "./commands/CountTokensCommand";
6
7
  import { GetAsyncInvokeCommandInput, GetAsyncInvokeCommandOutput } from "./commands/GetAsyncInvokeCommand";
7
8
  import { InvokeModelCommandInput, InvokeModelCommandOutput } from "./commands/InvokeModelCommand";
8
9
  import { InvokeModelWithBidirectionalStreamCommandInput, InvokeModelWithBidirectionalStreamCommandOutput } from "./commands/InvokeModelWithBidirectionalStreamCommand";
@@ -28,6 +29,12 @@ export interface BedrockRuntime {
28
29
  converseStream(args: ConverseStreamCommandInput, options?: __HttpHandlerOptions): Promise<ConverseStreamCommandOutput>;
29
30
  converseStream(args: ConverseStreamCommandInput, cb: (err: any, data?: ConverseStreamCommandOutput) => void): void;
30
31
  converseStream(args: ConverseStreamCommandInput, options: __HttpHandlerOptions, cb: (err: any, data?: ConverseStreamCommandOutput) => void): void;
32
+ /**
33
+ * @see {@link CountTokensCommand}
34
+ */
35
+ countTokens(args: CountTokensCommandInput, options?: __HttpHandlerOptions): Promise<CountTokensCommandOutput>;
36
+ countTokens(args: CountTokensCommandInput, cb: (err: any, data?: CountTokensCommandOutput) => void): void;
37
+ countTokens(args: CountTokensCommandInput, options: __HttpHandlerOptions, cb: (err: any, data?: CountTokensCommandOutput) => void): void;
31
38
  /**
32
39
  * @see {@link GetAsyncInvokeCommand}
33
40
  */
@@ -14,6 +14,7 @@ import { HttpAuthSchemeInputConfig, HttpAuthSchemeResolvedConfig } from "./auth/
14
14
  import { ApplyGuardrailCommandInput, ApplyGuardrailCommandOutput } from "./commands/ApplyGuardrailCommand";
15
15
  import { ConverseCommandInput, ConverseCommandOutput } from "./commands/ConverseCommand";
16
16
  import { ConverseStreamCommandInput, ConverseStreamCommandOutput } from "./commands/ConverseStreamCommand";
17
+ import { CountTokensCommandInput, CountTokensCommandOutput } from "./commands/CountTokensCommand";
17
18
  import { GetAsyncInvokeCommandInput, GetAsyncInvokeCommandOutput } from "./commands/GetAsyncInvokeCommand";
18
19
  import { InvokeModelCommandInput, InvokeModelCommandOutput } from "./commands/InvokeModelCommand";
19
20
  import { InvokeModelWithBidirectionalStreamCommandInput, InvokeModelWithBidirectionalStreamCommandOutput } from "./commands/InvokeModelWithBidirectionalStreamCommand";
@@ -26,11 +27,11 @@ export { __Client };
26
27
  /**
27
28
  * @public
28
29
  */
29
- export type ServiceInputTypes = ApplyGuardrailCommandInput | ConverseCommandInput | ConverseStreamCommandInput | GetAsyncInvokeCommandInput | InvokeModelCommandInput | InvokeModelWithBidirectionalStreamCommandInput | InvokeModelWithResponseStreamCommandInput | ListAsyncInvokesCommandInput | StartAsyncInvokeCommandInput;
30
+ export type ServiceInputTypes = ApplyGuardrailCommandInput | ConverseCommandInput | ConverseStreamCommandInput | CountTokensCommandInput | GetAsyncInvokeCommandInput | InvokeModelCommandInput | InvokeModelWithBidirectionalStreamCommandInput | InvokeModelWithResponseStreamCommandInput | ListAsyncInvokesCommandInput | StartAsyncInvokeCommandInput;
30
31
  /**
31
32
  * @public
32
33
  */
33
- export type ServiceOutputTypes = ApplyGuardrailCommandOutput | ConverseCommandOutput | ConverseStreamCommandOutput | GetAsyncInvokeCommandOutput | InvokeModelCommandOutput | InvokeModelWithBidirectionalStreamCommandOutput | InvokeModelWithResponseStreamCommandOutput | ListAsyncInvokesCommandOutput | StartAsyncInvokeCommandOutput;
34
+ export type ServiceOutputTypes = ApplyGuardrailCommandOutput | ConverseCommandOutput | ConverseStreamCommandOutput | CountTokensCommandOutput | GetAsyncInvokeCommandOutput | InvokeModelCommandOutput | InvokeModelWithBidirectionalStreamCommandOutput | InvokeModelWithResponseStreamCommandOutput | ListAsyncInvokesCommandOutput | StartAsyncInvokeCommandOutput;
34
35
  /**
35
36
  * @public
36
37
  */
@@ -0,0 +1,281 @@
1
+ import { Command as $Command } from "@smithy/smithy-client";
2
+ import { MetadataBearer as __MetadataBearer } from "@smithy/types";
3
+ import { BedrockRuntimeClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../BedrockRuntimeClient";
4
+ import { CountTokensRequest, CountTokensResponse } from "../models/models_0";
5
+ /**
6
+ * @public
7
+ */
8
+ export type { __MetadataBearer };
9
+ export { $Command };
10
+ /**
11
+ * @public
12
+ *
13
+ * The input for {@link CountTokensCommand}.
14
+ */
15
+ export interface CountTokensCommandInput extends CountTokensRequest {
16
+ }
17
+ /**
18
+ * @public
19
+ *
20
+ * The output of {@link CountTokensCommand}.
21
+ */
22
+ export interface CountTokensCommandOutput extends CountTokensResponse, __MetadataBearer {
23
+ }
24
+ declare const CountTokensCommand_base: {
25
+ new (input: CountTokensCommandInput): import("@smithy/smithy-client").CommandImpl<CountTokensCommandInput, CountTokensCommandOutput, BedrockRuntimeClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes>;
26
+ new (input: CountTokensCommandInput): import("@smithy/smithy-client").CommandImpl<CountTokensCommandInput, CountTokensCommandOutput, BedrockRuntimeClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes>;
27
+ getEndpointParameterInstructions(): import("@smithy/middleware-endpoint").EndpointParameterInstructions;
28
+ };
29
+ /**
30
+ * <p>Returns the token count for a given inference request. This operation helps you estimate token usage before sending requests to foundation models by returning the token count that would be used if the same input were sent to the model in an inference request.</p> <p>Token counting is model-specific because different models use different tokenization strategies. The token count returned by this operation will match the token count that would be charged if the same input were sent to the model in an <code>InvokeModel</code> or <code>Converse</code> request.</p> <p>You can use this operation to:</p> <ul> <li> <p>Estimate costs before sending inference requests.</p> </li> <li> <p>Optimize prompts to fit within token limits.</p> </li> <li> <p>Plan for token usage in your applications.</p> </li> </ul> <p>This operation accepts the same input formats as <code>InvokeModel</code> and <code>Converse</code>, allowing you to count tokens for both raw text inputs and structured conversation formats.</p> <p>The following operations are related to <code>CountTokens</code>:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/bedrock/latest/API/API_runtime_InvokeModel.html">InvokeModel</a> - Sends inference requests to foundation models</p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock/latest/API/API_runtime_Converse.html">Converse</a> - Sends conversation-based inference requests to foundation models</p> </li> </ul>
31
+ * @example
32
+ * Use a bare-bones client and the command you need to make an API call.
33
+ * ```javascript
34
+ * import { BedrockRuntimeClient, CountTokensCommand } from "@aws-sdk/client-bedrock-runtime"; // ES Modules import
35
+ * // const { BedrockRuntimeClient, CountTokensCommand } = require("@aws-sdk/client-bedrock-runtime"); // CommonJS import
36
+ * const client = new BedrockRuntimeClient(config);
37
+ * const input = { // CountTokensRequest
38
+ * modelId: "STRING_VALUE", // required
39
+ * input: { // CountTokensInput Union: only one key present
40
+ * invokeModel: { // InvokeModelTokensRequest
41
+ * body: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") // required
42
+ * },
43
+ * converse: { // ConverseTokensRequest
44
+ * messages: [ // Messages
45
+ * { // Message
46
+ * role: "user" || "assistant", // required
47
+ * content: [ // ContentBlocks // required
48
+ * { // ContentBlock Union: only one key present
49
+ * text: "STRING_VALUE",
50
+ * image: { // ImageBlock
51
+ * format: "png" || "jpeg" || "gif" || "webp", // required
52
+ * source: { // ImageSource Union: only one key present
53
+ * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
54
+ * s3Location: { // S3Location
55
+ * uri: "STRING_VALUE", // required
56
+ * bucketOwner: "STRING_VALUE",
57
+ * },
58
+ * },
59
+ * },
60
+ * document: { // DocumentBlock
61
+ * format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md",
62
+ * name: "STRING_VALUE", // required
63
+ * source: { // DocumentSource Union: only one key present
64
+ * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
65
+ * s3Location: {
66
+ * uri: "STRING_VALUE", // required
67
+ * bucketOwner: "STRING_VALUE",
68
+ * },
69
+ * text: "STRING_VALUE",
70
+ * content: [ // DocumentContentBlocks
71
+ * { // DocumentContentBlock Union: only one key present
72
+ * text: "STRING_VALUE",
73
+ * },
74
+ * ],
75
+ * },
76
+ * context: "STRING_VALUE",
77
+ * citations: { // CitationsConfig
78
+ * enabled: true || false, // required
79
+ * },
80
+ * },
81
+ * video: { // VideoBlock
82
+ * format: "mkv" || "mov" || "mp4" || "webm" || "flv" || "mpeg" || "mpg" || "wmv" || "three_gp", // required
83
+ * source: { // VideoSource Union: only one key present
84
+ * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
85
+ * s3Location: {
86
+ * uri: "STRING_VALUE", // required
87
+ * bucketOwner: "STRING_VALUE",
88
+ * },
89
+ * },
90
+ * },
91
+ * toolUse: { // ToolUseBlock
92
+ * toolUseId: "STRING_VALUE", // required
93
+ * name: "STRING_VALUE", // required
94
+ * input: "DOCUMENT_VALUE", // required
95
+ * },
96
+ * toolResult: { // ToolResultBlock
97
+ * toolUseId: "STRING_VALUE", // required
98
+ * content: [ // ToolResultContentBlocks // required
99
+ * { // ToolResultContentBlock Union: only one key present
100
+ * json: "DOCUMENT_VALUE",
101
+ * text: "STRING_VALUE",
102
+ * image: {
103
+ * format: "png" || "jpeg" || "gif" || "webp", // required
104
+ * source: {// Union: only one key present
105
+ * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
106
+ * s3Location: {
107
+ * uri: "STRING_VALUE", // required
108
+ * bucketOwner: "STRING_VALUE",
109
+ * },
110
+ * },
111
+ * },
112
+ * document: {
113
+ * format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md",
114
+ * name: "STRING_VALUE", // required
115
+ * source: {// Union: only one key present
116
+ * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
117
+ * s3Location: {
118
+ * uri: "STRING_VALUE", // required
119
+ * bucketOwner: "STRING_VALUE",
120
+ * },
121
+ * text: "STRING_VALUE",
122
+ * content: [
123
+ * {// Union: only one key present
124
+ * text: "STRING_VALUE",
125
+ * },
126
+ * ],
127
+ * },
128
+ * context: "STRING_VALUE",
129
+ * citations: {
130
+ * enabled: true || false, // required
131
+ * },
132
+ * },
133
+ * video: {
134
+ * format: "mkv" || "mov" || "mp4" || "webm" || "flv" || "mpeg" || "mpg" || "wmv" || "three_gp", // required
135
+ * source: {// Union: only one key present
136
+ * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
137
+ * s3Location: "<S3Location>",
138
+ * },
139
+ * },
140
+ * },
141
+ * ],
142
+ * status: "success" || "error",
143
+ * },
144
+ * guardContent: { // GuardrailConverseContentBlock Union: only one key present
145
+ * text: { // GuardrailConverseTextBlock
146
+ * text: "STRING_VALUE", // required
147
+ * qualifiers: [ // GuardrailConverseContentQualifierList
148
+ * "grounding_source" || "query" || "guard_content",
149
+ * ],
150
+ * },
151
+ * image: { // GuardrailConverseImageBlock
152
+ * format: "png" || "jpeg", // required
153
+ * source: { // GuardrailConverseImageSource Union: only one key present
154
+ * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
155
+ * },
156
+ * },
157
+ * },
158
+ * cachePoint: { // CachePointBlock
159
+ * type: "default", // required
160
+ * },
161
+ * reasoningContent: { // ReasoningContentBlock Union: only one key present
162
+ * reasoningText: { // ReasoningTextBlock
163
+ * text: "STRING_VALUE", // required
164
+ * signature: "STRING_VALUE",
165
+ * },
166
+ * redactedContent: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
167
+ * },
168
+ * citationsContent: { // CitationsContentBlock
169
+ * content: [ // CitationGeneratedContentList
170
+ * { // CitationGeneratedContent Union: only one key present
171
+ * text: "STRING_VALUE",
172
+ * },
173
+ * ],
174
+ * citations: [ // Citations
175
+ * { // Citation
176
+ * title: "STRING_VALUE",
177
+ * sourceContent: [ // CitationSourceContentList
178
+ * { // CitationSourceContent Union: only one key present
179
+ * text: "STRING_VALUE",
180
+ * },
181
+ * ],
182
+ * location: { // CitationLocation Union: only one key present
183
+ * documentChar: { // DocumentCharLocation
184
+ * documentIndex: Number("int"),
185
+ * start: Number("int"),
186
+ * end: Number("int"),
187
+ * },
188
+ * documentPage: { // DocumentPageLocation
189
+ * documentIndex: Number("int"),
190
+ * start: Number("int"),
191
+ * end: Number("int"),
192
+ * },
193
+ * documentChunk: { // DocumentChunkLocation
194
+ * documentIndex: Number("int"),
195
+ * start: Number("int"),
196
+ * end: Number("int"),
197
+ * },
198
+ * },
199
+ * },
200
+ * ],
201
+ * },
202
+ * },
203
+ * ],
204
+ * },
205
+ * ],
206
+ * system: [ // SystemContentBlocks
207
+ * { // SystemContentBlock Union: only one key present
208
+ * text: "STRING_VALUE",
209
+ * guardContent: {// Union: only one key present
210
+ * text: {
211
+ * text: "STRING_VALUE", // required
212
+ * qualifiers: [
213
+ * "grounding_source" || "query" || "guard_content",
214
+ * ],
215
+ * },
216
+ * image: {
217
+ * format: "png" || "jpeg", // required
218
+ * source: {// Union: only one key present
219
+ * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
220
+ * },
221
+ * },
222
+ * },
223
+ * cachePoint: {
224
+ * type: "default", // required
225
+ * },
226
+ * },
227
+ * ],
228
+ * },
229
+ * },
230
+ * };
231
+ * const command = new CountTokensCommand(input);
232
+ * const response = await client.send(command);
233
+ * // { // CountTokensResponse
234
+ * // inputTokens: Number("int"), // required
235
+ * // };
236
+ *
237
+ * ```
238
+ *
239
+ * @param CountTokensCommandInput - {@link CountTokensCommandInput}
240
+ * @returns {@link CountTokensCommandOutput}
241
+ * @see {@link CountTokensCommandInput} for command's `input` shape.
242
+ * @see {@link CountTokensCommandOutput} for command's `response` shape.
243
+ * @see {@link BedrockRuntimeClientResolvedConfig | config} for BedrockRuntimeClient's `config` shape.
244
+ *
245
+ * @throws {@link AccessDeniedException} (client fault)
246
+ * <p>The request is denied because you do not have sufficient permissions to perform the requested action. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-access-denied">AccessDeniedException</a> in the Amazon Bedrock User Guide</p>
247
+ *
248
+ * @throws {@link InternalServerException} (server fault)
249
+ * <p>An internal server error occurred. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-internal-failure">InternalFailure</a> in the Amazon Bedrock User Guide</p>
250
+ *
251
+ * @throws {@link ResourceNotFoundException} (client fault)
252
+ * <p>The specified resource ARN was not found. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-resource-not-found">ResourceNotFound</a> in the Amazon Bedrock User Guide</p>
253
+ *
254
+ * @throws {@link ServiceUnavailableException} (server fault)
255
+ * <p>The service isn't currently available. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-service-unavailable">ServiceUnavailable</a> in the Amazon Bedrock User Guide</p>
256
+ *
257
+ * @throws {@link ThrottlingException} (client fault)
258
+ * <p>Your request was denied due to exceeding the account quotas for <i>Amazon Bedrock</i>. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-throttling-exception">ThrottlingException</a> in the Amazon Bedrock User Guide</p>
259
+ *
260
+ * @throws {@link ValidationException} (client fault)
261
+ * <p>The input fails to satisfy the constraints specified by <i>Amazon Bedrock</i>. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-validation-error">ValidationError</a> in the Amazon Bedrock User Guide</p>
262
+ *
263
+ * @throws {@link BedrockRuntimeServiceException}
264
+ * <p>Base exception class for all service exceptions from BedrockRuntime service.</p>
265
+ *
266
+ *
267
+ * @public
268
+ */
269
+ export declare class CountTokensCommand extends CountTokensCommand_base {
270
+ /** @internal type navigation helper, not in runtime. */
271
+ protected static __types: {
272
+ api: {
273
+ input: CountTokensRequest;
274
+ output: CountTokensResponse;
275
+ };
276
+ sdk: {
277
+ input: CountTokensCommandInput;
278
+ output: CountTokensCommandOutput;
279
+ };
280
+ };
281
+ }
@@ -1,6 +1,7 @@
1
1
  export * from "./ApplyGuardrailCommand";
2
2
  export * from "./ConverseCommand";
3
3
  export * from "./ConverseStreamCommand";
4
+ export * from "./CountTokensCommand";
4
5
  export * from "./GetAsyncInvokeCommand";
5
6
  export * from "./InvokeModelCommand";
6
7
  export * from "./InvokeModelWithBidirectionalStreamCommand";
@@ -862,7 +862,7 @@ export type GuardrailAutomatedReasoningFinding = GuardrailAutomatedReasoningFind
862
862
  */
863
863
  export declare namespace GuardrailAutomatedReasoningFinding {
864
864
  /**
865
- * <p>Indicates that the claims are definitively true and logically implied by the premises, with no possible alternative interpretations.</p>
865
+ * <p>Contains the result when the automated reasoning evaluation determines that the claims in the input are logically valid and definitively true based on the provided premises and policy rules.</p>
866
866
  * @public
867
867
  */
868
868
  interface ValidMember {
@@ -876,7 +876,7 @@ export declare namespace GuardrailAutomatedReasoningFinding {
876
876
  $unknown?: never;
877
877
  }
878
878
  /**
879
- * <p>Indicates that the claims are logically false and contradictory to the established rules or premises.</p>
879
+ * <p>Contains the result when the automated reasoning evaluation determines that the claims in the input are logically invalid and contradict the established premises or policy rules.</p>
880
880
  * @public
881
881
  */
882
882
  interface InvalidMember {
@@ -890,7 +890,7 @@ export declare namespace GuardrailAutomatedReasoningFinding {
890
890
  $unknown?: never;
891
891
  }
892
892
  /**
893
- * <p>Indicates that the claims could be either true or false depending on additional assumptions not provided in the input.</p>
893
+ * <p>Contains the result when the automated reasoning evaluation determines that the claims in the input could be either true or false depending on additional assumptions not provided in the input context.</p>
894
894
  * @public
895
895
  */
896
896
  interface SatisfiableMember {
@@ -904,7 +904,7 @@ export declare namespace GuardrailAutomatedReasoningFinding {
904
904
  $unknown?: never;
905
905
  }
906
906
  /**
907
- * <p>Indicates that no valid claims can be made due to logical contradictions in the premises or rules.</p>
907
+ * <p>Contains the result when the automated reasoning evaluation determines that no valid logical conclusions can be drawn due to contradictions in the premises or policy rules themselves.</p>
908
908
  * @public
909
909
  */
910
910
  interface ImpossibleMember {
@@ -918,7 +918,7 @@ export declare namespace GuardrailAutomatedReasoningFinding {
918
918
  $unknown?: never;
919
919
  }
920
920
  /**
921
- * <p>Indicates that the input has multiple valid logical interpretations, requiring additional context or clarification.</p>
921
+ * <p>Contains the result when the automated reasoning evaluation detects that the input has multiple valid logical interpretations, requiring additional context or clarification to proceed with validation.</p>
922
922
  * @public
923
923
  */
924
924
  interface TranslationAmbiguousMember {
@@ -932,7 +932,7 @@ export declare namespace GuardrailAutomatedReasoningFinding {
932
932
  $unknown?: never;
933
933
  }
934
934
  /**
935
- * <p>Indicates that the input exceeds the processing capacity due to the volume or complexity of the logical information.</p>
935
+ * <p>Contains the result when the automated reasoning evaluation cannot process the input due to its complexity or volume exceeding the system's processing capacity for logical analysis.</p>
936
936
  * @public
937
937
  */
938
938
  interface TooComplexMember {
@@ -946,7 +946,7 @@ export declare namespace GuardrailAutomatedReasoningFinding {
946
946
  $unknown?: never;
947
947
  }
948
948
  /**
949
- * <p>Indicates that no relevant logical information could be extracted from the input for validation.</p>
949
+ * <p>Contains the result when the automated reasoning evaluation cannot extract any relevant logical information from the input that can be validated against the policy rules.</p>
950
950
  * @public
951
951
  */
952
952
  interface NoTranslationsMember {
@@ -4624,6 +4624,100 @@ export interface InvokeModelWithResponseStreamResponse {
4624
4624
  */
4625
4625
  performanceConfigLatency?: PerformanceConfigLatency | undefined;
4626
4626
  }
4627
+ /**
4628
+ * <p>The inputs from a <code>Converse</code> API request for token counting.</p> <p>This structure mirrors the input format for the <code>Converse</code> operation, allowing you to count tokens for conversation-based inference requests.</p>
4629
+ * @public
4630
+ */
4631
+ export interface ConverseTokensRequest {
4632
+ /**
4633
+ * <p>An array of messages to count tokens for.</p>
4634
+ * @public
4635
+ */
4636
+ messages?: Message[] | undefined;
4637
+ /**
4638
+ * <p>The system content blocks to count tokens for. System content provides instructions or context to the model about how it should behave or respond. The token count will include any system content provided.</p>
4639
+ * @public
4640
+ */
4641
+ system?: SystemContentBlock[] | undefined;
4642
+ }
4643
+ /**
4644
+ * <p>The body of an <code>InvokeModel</code> API request for token counting. This structure mirrors the input format for the <code>InvokeModel</code> operation, allowing you to count tokens for raw text inference requests.</p>
4645
+ * @public
4646
+ */
4647
+ export interface InvokeModelTokensRequest {
4648
+ /**
4649
+ * <p>The request body to count tokens for, formatted according to the model's expected input format. To learn about the input format for different models, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html">Model inference parameters and responses</a>.</p>
4650
+ * @public
4651
+ */
4652
+ body: Uint8Array | undefined;
4653
+ }
4654
+ /**
4655
+ * <p>The input value for token counting. The value should be either an <code>InvokeModel</code> or <code>Converse</code> request body. </p>
4656
+ * @public
4657
+ */
4658
+ export type CountTokensInput = CountTokensInput.ConverseMember | CountTokensInput.InvokeModelMember | CountTokensInput.$UnknownMember;
4659
+ /**
4660
+ * @public
4661
+ */
4662
+ export declare namespace CountTokensInput {
4663
+ /**
4664
+ * <p>An <code>InvokeModel</code> request for which to count tokens. Use this field when you want to count tokens for a raw text input that would be sent to the <code>InvokeModel</code> operation.</p>
4665
+ * @public
4666
+ */
4667
+ interface InvokeModelMember {
4668
+ invokeModel: InvokeModelTokensRequest;
4669
+ converse?: never;
4670
+ $unknown?: never;
4671
+ }
4672
+ /**
4673
+ * <p>A <code>Converse</code> request for which to count tokens. Use this field when you want to count tokens for a conversation-based input that would be sent to the <code>Converse</code> operation.</p>
4674
+ * @public
4675
+ */
4676
+ interface ConverseMember {
4677
+ invokeModel?: never;
4678
+ converse: ConverseTokensRequest;
4679
+ $unknown?: never;
4680
+ }
4681
+ /**
4682
+ * @public
4683
+ */
4684
+ interface $UnknownMember {
4685
+ invokeModel?: never;
4686
+ converse?: never;
4687
+ $unknown: [string, any];
4688
+ }
4689
+ interface Visitor<T> {
4690
+ invokeModel: (value: InvokeModelTokensRequest) => T;
4691
+ converse: (value: ConverseTokensRequest) => T;
4692
+ _: (name: string, value: any) => T;
4693
+ }
4694
+ const visit: <T>(value: CountTokensInput, visitor: Visitor<T>) => T;
4695
+ }
4696
+ /**
4697
+ * @public
4698
+ */
4699
+ export interface CountTokensRequest {
4700
+ /**
4701
+ * <p>The unique identifier or ARN of the foundation model to use for token counting. Each model processes tokens differently, so the token count is specific to the model you specify.</p>
4702
+ * @public
4703
+ */
4704
+ modelId: string | undefined;
4705
+ /**
4706
+ * <p>The input for which to count tokens. The structure of this parameter depends on whether you're counting tokens for an <code>InvokeModel</code> or <code>Converse</code> request:</p> <ul> <li> <p>For <code>InvokeModel</code> requests, provide the request body in the <code>invokeModel</code> field</p> </li> <li> <p>For <code>Converse</code> requests, provide the messages and system content in the <code>converse</code> field</p> </li> </ul> <p>The input format must be compatible with the model specified in the <code>modelId</code> parameter.</p>
4707
+ * @public
4708
+ */
4709
+ input: CountTokensInput | undefined;
4710
+ }
4711
+ /**
4712
+ * @public
4713
+ */
4714
+ export interface CountTokensResponse {
4715
+ /**
4716
+ * <p>The number of tokens in the provided input according to the specified model's tokenization rules. This count represents the number of input tokens that would be processed if the same input were sent to the model in an inference request. Use this value to estimate costs and ensure your inputs stay within model token limits.</p>
4717
+ * @public
4718
+ */
4719
+ inputTokens: number | undefined;
4720
+ }
4627
4721
  /**
4628
4722
  * @internal
4629
4723
  */
@@ -4848,3 +4942,19 @@ export declare const ResponseStreamFilterSensitiveLog: (obj: ResponseStream) =>
4848
4942
  * @internal
4849
4943
  */
4850
4944
  export declare const InvokeModelWithResponseStreamResponseFilterSensitiveLog: (obj: InvokeModelWithResponseStreamResponse) => any;
4945
+ /**
4946
+ * @internal
4947
+ */
4948
+ export declare const ConverseTokensRequestFilterSensitiveLog: (obj: ConverseTokensRequest) => any;
4949
+ /**
4950
+ * @internal
4951
+ */
4952
+ export declare const InvokeModelTokensRequestFilterSensitiveLog: (obj: InvokeModelTokensRequest) => any;
4953
+ /**
4954
+ * @internal
4955
+ */
4956
+ export declare const CountTokensInputFilterSensitiveLog: (obj: CountTokensInput) => any;
4957
+ /**
4958
+ * @internal
4959
+ */
4960
+ export declare const CountTokensRequestFilterSensitiveLog: (obj: CountTokensRequest) => any;
@@ -3,6 +3,7 @@ import { EventStreamSerdeContext as __EventStreamSerdeContext, SerdeContext as _
3
3
  import { ApplyGuardrailCommandInput, ApplyGuardrailCommandOutput } from "../commands/ApplyGuardrailCommand";
4
4
  import { ConverseCommandInput, ConverseCommandOutput } from "../commands/ConverseCommand";
5
5
  import { ConverseStreamCommandInput, ConverseStreamCommandOutput } from "../commands/ConverseStreamCommand";
6
+ import { CountTokensCommandInput, CountTokensCommandOutput } from "../commands/CountTokensCommand";
6
7
  import { GetAsyncInvokeCommandInput, GetAsyncInvokeCommandOutput } from "../commands/GetAsyncInvokeCommand";
7
8
  import { InvokeModelCommandInput, InvokeModelCommandOutput } from "../commands/InvokeModelCommand";
8
9
  import { InvokeModelWithBidirectionalStreamCommandInput, InvokeModelWithBidirectionalStreamCommandOutput } from "../commands/InvokeModelWithBidirectionalStreamCommand";
@@ -21,6 +22,10 @@ export declare const se_ConverseCommand: (input: ConverseCommandInput, context:
21
22
  * serializeAws_restJson1ConverseStreamCommand
22
23
  */
23
24
  export declare const se_ConverseStreamCommand: (input: ConverseStreamCommandInput, context: __SerdeContext) => Promise<__HttpRequest>;
25
+ /**
26
+ * serializeAws_restJson1CountTokensCommand
27
+ */
28
+ export declare const se_CountTokensCommand: (input: CountTokensCommandInput, context: __SerdeContext) => Promise<__HttpRequest>;
24
29
  /**
25
30
  * serializeAws_restJson1GetAsyncInvokeCommand
26
31
  */
@@ -57,6 +62,10 @@ export declare const de_ConverseCommand: (output: __HttpResponse, context: __Ser
57
62
  * deserializeAws_restJson1ConverseStreamCommand
58
63
  */
59
64
  export declare const de_ConverseStreamCommand: (output: __HttpResponse, context: __SerdeContext & __EventStreamSerdeContext) => Promise<ConverseStreamCommandOutput>;
65
+ /**
66
+ * deserializeAws_restJson1CountTokensCommand
67
+ */
68
+ export declare const de_CountTokensCommand: (output: __HttpResponse, context: __SerdeContext) => Promise<CountTokensCommandOutput>;
60
69
  /**
61
70
  * deserializeAws_restJson1GetAsyncInvokeCommand
62
71
  */
@@ -12,6 +12,10 @@ import {
12
12
  ConverseStreamCommandInput,
13
13
  ConverseStreamCommandOutput,
14
14
  } from "./commands/ConverseStreamCommand";
15
+ import {
16
+ CountTokensCommandInput,
17
+ CountTokensCommandOutput,
18
+ } from "./commands/CountTokensCommand";
15
19
  import {
16
20
  GetAsyncInvokeCommandInput,
17
21
  GetAsyncInvokeCommandOutput,
@@ -76,6 +80,19 @@ export interface BedrockRuntime {
76
80
  options: __HttpHandlerOptions,
77
81
  cb: (err: any, data?: ConverseStreamCommandOutput) => void
78
82
  ): void;
83
+ countTokens(
84
+ args: CountTokensCommandInput,
85
+ options?: __HttpHandlerOptions
86
+ ): Promise<CountTokensCommandOutput>;
87
+ countTokens(
88
+ args: CountTokensCommandInput,
89
+ cb: (err: any, data?: CountTokensCommandOutput) => void
90
+ ): void;
91
+ countTokens(
92
+ args: CountTokensCommandInput,
93
+ options: __HttpHandlerOptions,
94
+ cb: (err: any, data?: CountTokensCommandOutput) => void
95
+ ): void;
79
96
  getAsyncInvoke(
80
97
  args: GetAsyncInvokeCommandInput,
81
98
  options?: __HttpHandlerOptions
@@ -71,6 +71,10 @@ import {
71
71
  ConverseStreamCommandInput,
72
72
  ConverseStreamCommandOutput,
73
73
  } from "./commands/ConverseStreamCommand";
74
+ import {
75
+ CountTokensCommandInput,
76
+ CountTokensCommandOutput,
77
+ } from "./commands/CountTokensCommand";
74
78
  import {
75
79
  GetAsyncInvokeCommandInput,
76
80
  GetAsyncInvokeCommandOutput,
@@ -106,6 +110,7 @@ export type ServiceInputTypes =
106
110
  | ApplyGuardrailCommandInput
107
111
  | ConverseCommandInput
108
112
  | ConverseStreamCommandInput
113
+ | CountTokensCommandInput
109
114
  | GetAsyncInvokeCommandInput
110
115
  | InvokeModelCommandInput
111
116
  | InvokeModelWithBidirectionalStreamCommandInput
@@ -116,6 +121,7 @@ export type ServiceOutputTypes =
116
121
  | ApplyGuardrailCommandOutput
117
122
  | ConverseCommandOutput
118
123
  | ConverseStreamCommandOutput
124
+ | CountTokensCommandOutput
119
125
  | GetAsyncInvokeCommandOutput
120
126
  | InvokeModelCommandOutput
121
127
  | InvokeModelWithBidirectionalStreamCommandOutput
@@ -0,0 +1,47 @@
1
+ import { Command as $Command } from "@smithy/smithy-client";
2
+ import { MetadataBearer as __MetadataBearer } from "@smithy/types";
3
+ import {
4
+ BedrockRuntimeClientResolvedConfig,
5
+ ServiceInputTypes,
6
+ ServiceOutputTypes,
7
+ } from "../BedrockRuntimeClient";
8
+ import { CountTokensRequest, CountTokensResponse } from "../models/models_0";
9
+ export { __MetadataBearer };
10
+ export { $Command };
11
+ export interface CountTokensCommandInput extends CountTokensRequest {}
12
+ export interface CountTokensCommandOutput
13
+ extends CountTokensResponse,
14
+ __MetadataBearer {}
15
+ declare const CountTokensCommand_base: {
16
+ new (
17
+ input: CountTokensCommandInput
18
+ ): import("@smithy/smithy-client").CommandImpl<
19
+ CountTokensCommandInput,
20
+ CountTokensCommandOutput,
21
+ BedrockRuntimeClientResolvedConfig,
22
+ ServiceInputTypes,
23
+ ServiceOutputTypes
24
+ >;
25
+ new (
26
+ input: CountTokensCommandInput
27
+ ): import("@smithy/smithy-client").CommandImpl<
28
+ CountTokensCommandInput,
29
+ CountTokensCommandOutput,
30
+ BedrockRuntimeClientResolvedConfig,
31
+ ServiceInputTypes,
32
+ ServiceOutputTypes
33
+ >;
34
+ getEndpointParameterInstructions(): import("@smithy/middleware-endpoint").EndpointParameterInstructions;
35
+ };
36
+ export declare class CountTokensCommand extends CountTokensCommand_base {
37
+ protected static __types: {
38
+ api: {
39
+ input: CountTokensRequest;
40
+ output: CountTokensResponse;
41
+ };
42
+ sdk: {
43
+ input: CountTokensCommandInput;
44
+ output: CountTokensCommandOutput;
45
+ };
46
+ };
47
+ }
@@ -1,6 +1,7 @@
1
1
  export * from "./ApplyGuardrailCommand";
2
2
  export * from "./ConverseCommand";
3
3
  export * from "./ConverseStreamCommand";
4
+ export * from "./CountTokensCommand";
4
5
  export * from "./GetAsyncInvokeCommand";
5
6
  export * from "./InvokeModelCommand";
6
7
  export * from "./InvokeModelWithBidirectionalStreamCommand";
@@ -2236,6 +2236,47 @@ export interface InvokeModelWithResponseStreamResponse {
2236
2236
  contentType: string | undefined;
2237
2237
  performanceConfigLatency?: PerformanceConfigLatency | undefined;
2238
2238
  }
2239
+ export interface ConverseTokensRequest {
2240
+ messages?: Message[] | undefined;
2241
+ system?: SystemContentBlock[] | undefined;
2242
+ }
2243
+ export interface InvokeModelTokensRequest {
2244
+ body: Uint8Array | undefined;
2245
+ }
2246
+ export type CountTokensInput =
2247
+ | CountTokensInput.ConverseMember
2248
+ | CountTokensInput.InvokeModelMember
2249
+ | CountTokensInput.$UnknownMember;
2250
+ export declare namespace CountTokensInput {
2251
+ interface InvokeModelMember {
2252
+ invokeModel: InvokeModelTokensRequest;
2253
+ converse?: never;
2254
+ $unknown?: never;
2255
+ }
2256
+ interface ConverseMember {
2257
+ invokeModel?: never;
2258
+ converse: ConverseTokensRequest;
2259
+ $unknown?: never;
2260
+ }
2261
+ interface $UnknownMember {
2262
+ invokeModel?: never;
2263
+ converse?: never;
2264
+ $unknown: [string, any];
2265
+ }
2266
+ interface Visitor<T> {
2267
+ invokeModel: (value: InvokeModelTokensRequest) => T;
2268
+ converse: (value: ConverseTokensRequest) => T;
2269
+ _: (name: string, value: any) => T;
2270
+ }
2271
+ const visit: <T>(value: CountTokensInput, visitor: Visitor<T>) => T;
2272
+ }
2273
+ export interface CountTokensRequest {
2274
+ modelId: string | undefined;
2275
+ input: CountTokensInput | undefined;
2276
+ }
2277
+ export interface CountTokensResponse {
2278
+ inputTokens: number | undefined;
2279
+ }
2239
2280
  export declare const GetAsyncInvokeResponseFilterSensitiveLog: (
2240
2281
  obj: GetAsyncInvokeResponse
2241
2282
  ) => any;
@@ -2398,3 +2439,15 @@ export declare const ResponseStreamFilterSensitiveLog: (
2398
2439
  export declare const InvokeModelWithResponseStreamResponseFilterSensitiveLog: (
2399
2440
  obj: InvokeModelWithResponseStreamResponse
2400
2441
  ) => any;
2442
+ export declare const ConverseTokensRequestFilterSensitiveLog: (
2443
+ obj: ConverseTokensRequest
2444
+ ) => any;
2445
+ export declare const InvokeModelTokensRequestFilterSensitiveLog: (
2446
+ obj: InvokeModelTokensRequest
2447
+ ) => any;
2448
+ export declare const CountTokensInputFilterSensitiveLog: (
2449
+ obj: CountTokensInput
2450
+ ) => any;
2451
+ export declare const CountTokensRequestFilterSensitiveLog: (
2452
+ obj: CountTokensRequest
2453
+ ) => any;
@@ -18,6 +18,10 @@ import {
18
18
  ConverseStreamCommandInput,
19
19
  ConverseStreamCommandOutput,
20
20
  } from "../commands/ConverseStreamCommand";
21
+ import {
22
+ CountTokensCommandInput,
23
+ CountTokensCommandOutput,
24
+ } from "../commands/CountTokensCommand";
21
25
  import {
22
26
  GetAsyncInvokeCommandInput,
23
27
  GetAsyncInvokeCommandOutput,
@@ -54,6 +58,10 @@ export declare const se_ConverseStreamCommand: (
54
58
  input: ConverseStreamCommandInput,
55
59
  context: __SerdeContext
56
60
  ) => Promise<__HttpRequest>;
61
+ export declare const se_CountTokensCommand: (
62
+ input: CountTokensCommandInput,
63
+ context: __SerdeContext
64
+ ) => Promise<__HttpRequest>;
57
65
  export declare const se_GetAsyncInvokeCommand: (
58
66
  input: GetAsyncInvokeCommandInput,
59
67
  context: __SerdeContext
@@ -90,6 +98,10 @@ export declare const de_ConverseStreamCommand: (
90
98
  output: __HttpResponse,
91
99
  context: __SerdeContext & __EventStreamSerdeContext
92
100
  ) => Promise<ConverseStreamCommandOutput>;
101
+ export declare const de_CountTokensCommand: (
102
+ output: __HttpResponse,
103
+ context: __SerdeContext
104
+ ) => Promise<CountTokensCommandOutput>;
93
105
  export declare const de_GetAsyncInvokeCommand: (
94
106
  output: __HttpResponse,
95
107
  context: __SerdeContext
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aws-sdk/client-bedrock-runtime",
3
3
  "description": "AWS SDK for JavaScript Bedrock Runtime Client for Node.js, Browser and React Native",
4
- "version": "3.863.0",
4
+ "version": "3.872.0",
5
5
  "scripts": {
6
6
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
7
7
  "build:cjs": "node ../../scripts/compilation/inline client-bedrock-runtime",
@@ -20,21 +20,21 @@
20
20
  "dependencies": {
21
21
  "@aws-crypto/sha256-browser": "5.2.0",
22
22
  "@aws-crypto/sha256-js": "5.2.0",
23
- "@aws-sdk/core": "3.863.0",
24
- "@aws-sdk/credential-provider-node": "3.863.0",
23
+ "@aws-sdk/core": "3.864.0",
24
+ "@aws-sdk/credential-provider-node": "3.872.0",
25
25
  "@aws-sdk/eventstream-handler-node": "3.862.0",
26
26
  "@aws-sdk/middleware-eventstream": "3.862.0",
27
27
  "@aws-sdk/middleware-host-header": "3.862.0",
28
28
  "@aws-sdk/middleware-logger": "3.862.0",
29
29
  "@aws-sdk/middleware-recursion-detection": "3.862.0",
30
- "@aws-sdk/middleware-user-agent": "3.863.0",
30
+ "@aws-sdk/middleware-user-agent": "3.864.0",
31
31
  "@aws-sdk/middleware-websocket": "3.862.0",
32
32
  "@aws-sdk/region-config-resolver": "3.862.0",
33
- "@aws-sdk/token-providers": "3.863.0",
33
+ "@aws-sdk/token-providers": "3.864.0",
34
34
  "@aws-sdk/types": "3.862.0",
35
35
  "@aws-sdk/util-endpoints": "3.862.0",
36
36
  "@aws-sdk/util-user-agent-browser": "3.862.0",
37
- "@aws-sdk/util-user-agent-node": "3.863.0",
37
+ "@aws-sdk/util-user-agent-node": "3.864.0",
38
38
  "@smithy/config-resolver": "^4.1.5",
39
39
  "@smithy/core": "^3.8.0",
40
40
  "@smithy/eventstream-serde-browser": "^4.0.5",