@anyway-sh/node-server-sdk 0.22.9 → 0.22.11

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.
@@ -129,5 +129,15 @@ export interface InitializeOptions {
129
129
  * This is used to configure the Google Cloud Trace Exporter.
130
130
  */
131
131
  gcpProjectId?: string;
132
+ /**
133
+ * Whether to calculate and add cost attributes to spans. Optional.
134
+ * Defaults to true.
135
+ */
136
+ pricingEnabled?: boolean;
137
+ /**
138
+ * Path to a custom pricing JSON file. Optional.
139
+ * If not set, uses the bundled default pricing data.
140
+ */
141
+ pricingJsonPath?: string;
132
142
  }
133
143
  //# sourceMappingURL=initialize-options.interface.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { ReadableSpan } from "@opentelemetry/sdk-trace-base";
2
+ interface NormalizedPricing {
3
+ inputCostPerToken: number;
4
+ outputCostPerToken: number;
5
+ }
6
+ interface ModelPricing {
7
+ promptPrice: number;
8
+ completionPrice: number;
9
+ }
10
+ export interface PricingData {
11
+ chat?: Record<string, ModelPricing>;
12
+ embeddings?: Record<string, number>;
13
+ images?: Record<string, unknown>;
14
+ audio?: Record<string, unknown>;
15
+ }
16
+ export declare class PricingCalculator {
17
+ private chatModels;
18
+ constructor(pricingData: PricingData);
19
+ findPricing(modelName: string): NormalizedPricing | null;
20
+ addCostAttributes(span: ReadableSpan): void;
21
+ private normalize;
22
+ }
23
+ export {};
24
+ //# sourceMappingURL=calculator.d.ts.map
@@ -0,0 +1,4 @@
1
+ export { PricingCalculator } from "./calculator";
2
+ export type { PricingData } from "./calculator";
3
+ export { loadPricing } from "./loader";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { PricingData } from "./calculator";
2
+ export declare function loadPricing(pricingJsonPath?: string): PricingData;
3
+ //# sourceMappingURL=loader.d.ts.map
@@ -1,7 +1,9 @@
1
1
  import { SpanProcessor } from "@opentelemetry/sdk-trace-node";
2
2
  import { SpanExporter } from "@opentelemetry/sdk-trace-base";
3
+ import { PricingCalculator } from "../pricing";
3
4
  export declare const ALL_INSTRUMENTATION_LIBRARIES: "all";
4
5
  type AllInstrumentationLibraries = typeof ALL_INSTRUMENTATION_LIBRARIES;
6
+ export declare const setPricingCalculator: (calculator: PricingCalculator | null) => void;
5
7
  export interface SpanProcessorOptions {
6
8
  /**
7
9
  * The API Key for sending traces data. Optional.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anyway-sh/node-server-sdk",
3
- "version": "0.22.9",
3
+ "version": "0.22.11",
4
4
  "description": "Anyway Software Development Kit (SDK) for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",