@paid-ai/paid-node 1.6.0 → 1.7.1

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.
@@ -55,8 +55,8 @@ class PaidClient {
55
55
  this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
56
56
  "X-Fern-Language": "JavaScript",
57
57
  "X-Fern-SDK-Name": "@paid-ai/paid-node",
58
- "X-Fern-SDK-Version": "1.6.0",
59
- "User-Agent": "@paid-ai/paid-node/1.6.0",
58
+ "X-Fern-SDK-Version": "1.7.0",
59
+ "User-Agent": "@paid-ai/paid-node/1.7.0",
60
60
  "X-Fern-Runtime": core.RUNTIME.type,
61
61
  "X-Fern-Runtime-Version": core.RUNTIME.version,
62
62
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -83,7 +83,7 @@ class Costs {
83
83
  var _a, _b, _c, _d, _e, _f, _g, _h;
84
84
  const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
85
85
  const _response = yield core.fetcher({
86
- url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Default, "cost/bulk"),
86
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Default, "costs/bulk"),
87
87
  method: "POST",
88
88
  headers: _headers,
89
89
  contentType: "application/json",
@@ -121,7 +121,7 @@ class Costs {
121
121
  rawResponse: _response.rawResponse,
122
122
  });
123
123
  case "timeout":
124
- throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /cost/bulk.");
124
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /costs/bulk.");
125
125
  case "unknown":
126
126
  throw new errors.PaidError({
127
127
  message: _response.error.errorMessage,
@@ -35,6 +35,23 @@ const ATTRIBUTE_MAP = {
35
35
  function isAISDKSpan(span) {
36
36
  const attrs = span.attributes;
37
37
  const name = span.name.toLowerCase();
38
+ // The AI SDK emits two spans per call: an outer wrapper (e.g. ai.generateObject)
39
+ // and an inner span that actually hits the provider (e.g. ai.generateObject.doGenerate).
40
+ // Both carry identical token usage attributes, so processing both double-counts costs.
41
+ //
42
+ // We can't use attribute presence to distinguish them — outer and inner spans share
43
+ // the same base attributes (ai.model.id, ai.model.provider), and response-model
44
+ // attributes are only set on LLM inner spans, not embedding inner spans (doEmbed).
45
+ //
46
+ // The AI SDK's naming convention for inner (provider-call) spans is to include a
47
+ // ".do" segment in the operationId (doGenerate, doStream, doEmbed). This is the
48
+ // SDK's structural contract for separating orchestration from provider calls, and
49
+ // is the only reliable discriminator that works across all operation types (LLM,
50
+ // embedding) and telemetry formats (modern GenAI semconv, legacy LegacyOpenTelemetry).
51
+ const operationId = attrs["ai.operationId"];
52
+ if (typeof operationId === "string" && !operationId.includes(".do")) {
53
+ return false;
54
+ }
38
55
  // Check for AI SDK specific attributes (most reliable)
39
56
  // Also check span name - account for PaidSpanProcessor prefix (paid.trace.ai.xxx)
40
57
  return !!(attrs["ai.model.id"] ||
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.6.0";
1
+ export declare const SDK_VERSION = "1.7.0";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "1.6.0";
4
+ exports.SDK_VERSION = "1.7.0";
@@ -19,8 +19,8 @@ export class PaidClient {
19
19
  this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
20
20
  "X-Fern-Language": "JavaScript",
21
21
  "X-Fern-SDK-Name": "@paid-ai/paid-node",
22
- "X-Fern-SDK-Version": "1.6.0",
23
- "User-Agent": "@paid-ai/paid-node/1.6.0",
22
+ "X-Fern-SDK-Version": "1.7.0",
23
+ "User-Agent": "@paid-ai/paid-node/1.7.0",
24
24
  "X-Fern-Runtime": core.RUNTIME.type,
25
25
  "X-Fern-Runtime-Version": core.RUNTIME.version,
26
26
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -47,7 +47,7 @@ export class Costs {
47
47
  var _a, _b, _c, _d, _e, _f, _g, _h;
48
48
  const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
49
49
  const _response = yield core.fetcher({
50
- url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Default, "cost/bulk"),
50
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Default, "costs/bulk"),
51
51
  method: "POST",
52
52
  headers: _headers,
53
53
  contentType: "application/json",
@@ -85,7 +85,7 @@ export class Costs {
85
85
  rawResponse: _response.rawResponse,
86
86
  });
87
87
  case "timeout":
88
- throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /cost/bulk.");
88
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /costs/bulk.");
89
89
  case "unknown":
90
90
  throw new errors.PaidError({
91
91
  message: _response.error.errorMessage,
@@ -32,6 +32,23 @@ const ATTRIBUTE_MAP = {
32
32
  function isAISDKSpan(span) {
33
33
  const attrs = span.attributes;
34
34
  const name = span.name.toLowerCase();
35
+ // The AI SDK emits two spans per call: an outer wrapper (e.g. ai.generateObject)
36
+ // and an inner span that actually hits the provider (e.g. ai.generateObject.doGenerate).
37
+ // Both carry identical token usage attributes, so processing both double-counts costs.
38
+ //
39
+ // We can't use attribute presence to distinguish them — outer and inner spans share
40
+ // the same base attributes (ai.model.id, ai.model.provider), and response-model
41
+ // attributes are only set on LLM inner spans, not embedding inner spans (doEmbed).
42
+ //
43
+ // The AI SDK's naming convention for inner (provider-call) spans is to include a
44
+ // ".do" segment in the operationId (doGenerate, doStream, doEmbed). This is the
45
+ // SDK's structural contract for separating orchestration from provider calls, and
46
+ // is the only reliable discriminator that works across all operation types (LLM,
47
+ // embedding) and telemetry formats (modern GenAI semconv, legacy LegacyOpenTelemetry).
48
+ const operationId = attrs["ai.operationId"];
49
+ if (typeof operationId === "string" && !operationId.includes(".do")) {
50
+ return false;
51
+ }
35
52
  // Check for AI SDK specific attributes (most reliable)
36
53
  // Also check span name - account for PaidSpanProcessor prefix (paid.trace.ai.xxx)
37
54
  return !!(attrs["ai.model.id"] ||
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.6.0";
1
+ export declare const SDK_VERSION = "1.7.0";
@@ -1 +1 @@
1
- export const SDK_VERSION = "1.6.0";
1
+ export const SDK_VERSION = "1.7.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paid-ai/paid-node",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "private": false,
5
5
  "repository": "github:paid-ai/paid-node",
6
6
  "type": "commonjs",