@siglume/api-sdk 0.7.5 → 0.7.6

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.cjs CHANGED
@@ -2844,11 +2844,15 @@ var init_client = __esm({
2844
2844
  max_retries;
2845
2845
  fetchImpl;
2846
2846
  pendingConfirmations = /* @__PURE__ */ new Map();
2847
- constructor(options) {
2848
- if (!options.api_key) {
2849
- throw new SiglumeClientError("SIGLUME_API_KEY is required.");
2847
+ constructor(options = {}) {
2848
+ const envApiKey = typeof process !== "undefined" ? process.env?.SIGLUME_API_KEY : void 0;
2849
+ const resolvedApiKey = (options.api_key ?? envApiKey ?? "").trim();
2850
+ if (!resolvedApiKey) {
2851
+ throw new SiglumeClientError(
2852
+ "SIGLUME_API_KEY is required. Pass it as the api_key option or set the SIGLUME_API_KEY env var."
2853
+ );
2850
2854
  }
2851
- this.api_key = options.api_key;
2855
+ this.api_key = resolvedApiKey;
2852
2856
  this.agent_key = options.agent_key?.trim() || void 0;
2853
2857
  this.base_url = (options.base_url ?? DEFAULT_SIGLUME_API_BASE).replace(/\/+$/, "");
2854
2858
  this.timeout_ms = Math.max(1, options.timeout_ms ?? 15e3);
@@ -4911,7 +4915,7 @@ ${details}` : summary;
4911
4915
  const headers = new Headers({
4912
4916
  Authorization: `Bearer ${this.api_key}`,
4913
4917
  Accept: "application/json",
4914
- "User-Agent": "siglume-api-sdk-ts/0.6.0"
4918
+ "User-Agent": "siglume-api-sdk-ts/0.7.6"
4915
4919
  });
4916
4920
  if (options.headers) {
4917
4921
  for (const [key, value] of Object.entries(options.headers)) {
@@ -5113,7 +5117,7 @@ var init_metering = __esm({
5113
5117
  fetchImpl;
5114
5118
  constructor(options) {
5115
5119
  this.client = new SiglumeClient(options);
5116
- this.api_key = options.api_key;
5120
+ this.api_key = this.client.api_key;
5117
5121
  this.base_url = (options.base_url ?? DEFAULT_SIGLUME_API_BASE).replace(/\/+$/, "");
5118
5122
  this.timeout_ms = Math.max(1, options.timeout_ms ?? 15e3);
5119
5123
  this.max_retries = Math.max(1, Math.trunc(options.max_retries ?? 3));
@@ -5159,7 +5163,7 @@ var init_metering = __esm({
5159
5163
  const headers = new Headers({
5160
5164
  Authorization: `Bearer ${this.api_key}`,
5161
5165
  Accept: "application/json",
5162
- "User-Agent": "siglume-api-sdk-ts/0.6.0"
5166
+ "User-Agent": "siglume-api-sdk-ts/0.7.6"
5163
5167
  });
5164
5168
  let body;
5165
5169
  if (options.json_body) {
@@ -5351,7 +5355,7 @@ var SiglumeBuyerClient = class {
5351
5355
  warnedFeatures = /* @__PURE__ */ new Set();
5352
5356
  constructor(options) {
5353
5357
  this.client = new SiglumeClient(options);
5354
- this.api_key = options.api_key;
5358
+ this.api_key = this.client.api_key;
5355
5359
  this.base_url = (options.base_url ?? DEFAULT_SIGLUME_API_BASE).replace(/\/+$/, "");
5356
5360
  this.timeout_ms = Math.max(1, options.timeout_ms ?? 15e3);
5357
5361
  this.max_retries = Math.max(1, Math.trunc(options.max_retries ?? 3));
@@ -5528,7 +5532,7 @@ var SiglumeBuyerClient = class {
5528
5532
  const headers = new Headers({
5529
5533
  Authorization: `Bearer ${this.api_key}`,
5530
5534
  Accept: "application/json",
5531
- "User-Agent": "siglume-api-sdk-ts/0.6.0"
5535
+ "User-Agent": "siglume-api-sdk-ts/0.7.6"
5532
5536
  });
5533
5537
  let body;
5534
5538
  if (options.json_body) {