@ai-sdk/amazon-bedrock 4.0.113 → 4.0.115

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/dist/index.mjs CHANGED
@@ -1743,7 +1743,7 @@ var BedrockEmbeddingModel = class {
1743
1743
  normalize: bedrockOptions.normalize
1744
1744
  };
1745
1745
  const url = this.getUrl(this.modelId);
1746
- const { value: response } = await postJsonToApi2({
1746
+ const { value: response, responseHeaders } = await postJsonToApi2({
1747
1747
  url,
1748
1748
  headers: await resolve2(
1749
1749
  combineHeaders2(await resolve2(this.config.headers), headers)
@@ -1772,7 +1772,10 @@ var BedrockEmbeddingModel = class {
1772
1772
  } else {
1773
1773
  embedding = response.embeddings.float[0];
1774
1774
  }
1775
- const tokens = "inputTextTokenCount" in response ? response.inputTextTokenCount : "inputTokenCount" in response ? (_f = response.inputTokenCount) != null ? _f : 0 : NaN;
1775
+ const headerTokenCount = Number(
1776
+ responseHeaders == null ? void 0 : responseHeaders["x-amzn-bedrock-input-token-count"]
1777
+ );
1778
+ const tokens = "inputTextTokenCount" in response ? response.inputTextTokenCount : "inputTokenCount" in response ? (_f = response.inputTokenCount) != null ? _f : 0 : headerTokenCount;
1776
1779
  return {
1777
1780
  embeddings: [embedding],
1778
1781
  usage: { tokens },
@@ -2032,7 +2035,7 @@ import {
2032
2035
  import { AwsV4Signer } from "aws4fetch";
2033
2036
 
2034
2037
  // src/version.ts
2035
- var VERSION = true ? "4.0.113" : "0.0.0-test";
2038
+ var VERSION = true ? "4.0.115" : "0.0.0-test";
2036
2039
 
2037
2040
  // src/bedrock-sigv4-fetch.ts
2038
2041
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {