autotel-genai 0.10.2 → 0.11.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
@@ -86,8 +86,19 @@ recordLLMCost(ctx, 'claude-sonnet-4', {
86
86
  inputTokens: 4000,
87
87
  cacheReadInputTokens: 3500, // priced at the cached rate
88
88
  });
89
+
90
+ // Hosted ids price as the model they name
91
+ estimateLLMCost('eu.anthropic.claude-3-5-haiku-20241022-v1:0', usage);
92
+
93
+ // Your own rates, merged over the built-in table
94
+ estimateLLMCost('my-finetune', usage, {
95
+ pricing: { 'my-finetune': { inputPer1M: 0.5, outputPer1M: 1.5 } },
96
+ });
89
97
  ```
90
98
 
99
+ `createGenAiObserver({ pricing })` and `autotelTelemetry({ pricing })` take the
100
+ same map once, so every span an observer prices uses it.
101
+
91
102
  **Server-side tools are money too.** Web search, code interpreter and file
92
103
  search are billed per call, outside the token counts. An agent that searches on
93
104
  every step can spend more there than on tokens, and a cost built from tokens
package/dist/cost.cjs CHANGED
@@ -110,7 +110,30 @@ const MODEL_PRICING = {
110
110
  outputPer1M: .4
111
111
  }
112
112
  };
113
- function resolvePricing(table, model) {
113
+ /**
114
+ * Strip one leading vendor segment from a hosted model id, or return
115
+ * `undefined` when there is nothing left to strip.
116
+ *
117
+ * Bedrock, Vertex and the cross-region inference profiles all namespace the
118
+ * model rather than rename it: `anthropic.claude-3-5-haiku-20241022-v1:0`,
119
+ * `eu.anthropic.claude-...`, `publishers/anthropic/models/claude-...`. The
120
+ * price table is keyed on the model itself, so the prefix has to come off
121
+ * before a lookup can hit.
122
+ *
123
+ * A segment containing a digit is left alone. Model families carry their
124
+ * version in the name — `gpt-4.1-mini`, `gemini-1.5-pro`, `claude-3-opus` —
125
+ * and stripping `gpt-4` off `gpt-4.1-mini` would turn a real key into `1-mini`.
126
+ */
127
+ function stripVendorPrefix(model) {
128
+ const slash = model.lastIndexOf("/");
129
+ if (slash !== -1) return model.slice(slash + 1);
130
+ const dot = model.indexOf(".");
131
+ if (dot === -1) return undefined;
132
+ const head = model.slice(0, dot);
133
+ if (head.length === 0 || /\d/.test(head)) return undefined;
134
+ return model.slice(dot + 1);
135
+ }
136
+ function matchPricing(table, model) {
114
137
  const exact = table[model];
115
138
  if (exact) return exact;
116
139
  let best;
@@ -123,6 +146,15 @@ function resolvePricing(table, model) {
123
146
  }
124
147
  return best;
125
148
  }
149
+ function resolvePricing(table, model) {
150
+ let candidate = model;
151
+ while (candidate !== undefined) {
152
+ const price = matchPricing(table, candidate);
153
+ if (price) return price;
154
+ candidate = stripVendorPrefix(candidate);
155
+ }
156
+ return undefined;
157
+ }
126
158
  /** The table this model's tool prices resolve through, model entry first. */
127
159
  function serverToolRate(price, tool) {
128
160
  return price.serverToolPer1K?.[tool] ?? SERVER_TOOL_PRICING_PER_1K[tool];
package/dist/cost.js CHANGED
@@ -109,7 +109,30 @@ const MODEL_PRICING = {
109
109
  outputPer1M: .4
110
110
  }
111
111
  };
112
- function resolvePricing(table, model) {
112
+ /**
113
+ * Strip one leading vendor segment from a hosted model id, or return
114
+ * `undefined` when there is nothing left to strip.
115
+ *
116
+ * Bedrock, Vertex and the cross-region inference profiles all namespace the
117
+ * model rather than rename it: `anthropic.claude-3-5-haiku-20241022-v1:0`,
118
+ * `eu.anthropic.claude-...`, `publishers/anthropic/models/claude-...`. The
119
+ * price table is keyed on the model itself, so the prefix has to come off
120
+ * before a lookup can hit.
121
+ *
122
+ * A segment containing a digit is left alone. Model families carry their
123
+ * version in the name — `gpt-4.1-mini`, `gemini-1.5-pro`, `claude-3-opus` —
124
+ * and stripping `gpt-4` off `gpt-4.1-mini` would turn a real key into `1-mini`.
125
+ */
126
+ function stripVendorPrefix(model) {
127
+ const slash = model.lastIndexOf("/");
128
+ if (slash !== -1) return model.slice(slash + 1);
129
+ const dot = model.indexOf(".");
130
+ if (dot === -1) return undefined;
131
+ const head = model.slice(0, dot);
132
+ if (head.length === 0 || /\d/.test(head)) return undefined;
133
+ return model.slice(dot + 1);
134
+ }
135
+ function matchPricing(table, model) {
113
136
  const exact = table[model];
114
137
  if (exact) return exact;
115
138
  let best;
@@ -122,6 +145,15 @@ function resolvePricing(table, model) {
122
145
  }
123
146
  return best;
124
147
  }
148
+ function resolvePricing(table, model) {
149
+ let candidate = model;
150
+ while (candidate !== undefined) {
151
+ const price = matchPricing(table, candidate);
152
+ if (price) return price;
153
+ candidate = stripVendorPrefix(candidate);
154
+ }
155
+ return undefined;
156
+ }
125
157
  /** The table this model's tool prices resolve through, model entry first. */
126
158
  function serverToolRate(price, tool) {
127
159
  return price.serverToolPer1K?.[tool] ?? SERVER_TOOL_PRICING_PER_1K[tool];
@@ -1,4 +1,4 @@
1
- import { o as TokenUsage } from "./cost-BcW9kEgp.cjs";
1
+ import { i as ModelPricing, o as TokenUsage } from "./cost-BcW9kEgp.cjs";
2
2
  import { h as GenAiProviderName } from "./semconv-m_Y-ve_N.cjs";
3
3
  import { J as GenAiMetadata, c as AgentOutputFormat, o as AgentInputProvenance, s as AgentMemoryOperation } from "./agent-security-BjM1QOTr.cjs";
4
4
  import { a as GenAiResponseInput, i as GenAiRequestInput, l as GenAiWorkflowInput, s as GenAiToolInput, t as GenAiAgentInput } from "./attributes-B8K6NxiM.cjs";
@@ -171,6 +171,15 @@ interface GenAiObserverOptions {
171
171
  * ambient context.
172
172
  */
173
173
  onSpanStart?: (id: string, span: Span) => void;
174
+ /**
175
+ * Extra `gen_ai.usage.cost.usd` pricing, merged over the built-in table and
176
+ * keyed the same way (longest matching model prefix wins).
177
+ *
178
+ * Needed for any model the built-in table cannot know: a new release, a
179
+ * self-hosted or fine-tuned model, or a negotiated rate that differs from
180
+ * list price. Without a matching entry the cost attribute is simply absent.
181
+ */
182
+ pricing?: Record<string, ModelPricing>;
174
183
  }
175
184
  //#endregion
176
185
  //#region src/observer/observer.d.ts
@@ -489,6 +498,11 @@ interface AutotelTelemetryOptions {
489
498
  * request span. Return `undefined` to keep it a root.
490
499
  */
491
500
  resolveParentContext?: (event: GenAiObserverEvent) => Context | undefined;
501
+ /**
502
+ * Extra `gen_ai.usage.cost.usd` pricing, merged over the built-in table.
503
+ * See {@link GenAiObserverOptions.pricing}.
504
+ */
505
+ pricing?: Record<string, ModelPricing>;
492
506
  }
493
507
  /**
494
508
  * Create an AI SDK telemetry integration that streams canonical `gen_ai.*`
@@ -1,4 +1,4 @@
1
- import { o as TokenUsage } from "./cost-BcW9kEgp.js";
1
+ import { i as ModelPricing, o as TokenUsage } from "./cost-BcW9kEgp.js";
2
2
  import { h as GenAiProviderName } from "./semconv-m_Y-ve_N.js";
3
3
  import { J as GenAiMetadata, c as AgentOutputFormat, o as AgentInputProvenance, s as AgentMemoryOperation } from "./agent-security-D9NfzH7I.js";
4
4
  import { a as GenAiResponseInput, i as GenAiRequestInput, l as GenAiWorkflowInput, s as GenAiToolInput, t as GenAiAgentInput } from "./attributes-BNl903D-.js";
@@ -171,6 +171,15 @@ interface GenAiObserverOptions {
171
171
  * ambient context.
172
172
  */
173
173
  onSpanStart?: (id: string, span: Span) => void;
174
+ /**
175
+ * Extra `gen_ai.usage.cost.usd` pricing, merged over the built-in table and
176
+ * keyed the same way (longest matching model prefix wins).
177
+ *
178
+ * Needed for any model the built-in table cannot know: a new release, a
179
+ * self-hosted or fine-tuned model, or a negotiated rate that differs from
180
+ * list price. Without a matching entry the cost attribute is simply absent.
181
+ */
182
+ pricing?: Record<string, ModelPricing>;
174
183
  }
175
184
  //#endregion
176
185
  //#region src/observer/observer.d.ts
@@ -489,6 +498,11 @@ interface AutotelTelemetryOptions {
489
498
  * request span. Return `undefined` to keep it a root.
490
499
  */
491
500
  resolveParentContext?: (event: GenAiObserverEvent) => Context | undefined;
501
+ /**
502
+ * Extra `gen_ai.usage.cost.usd` pricing, merged over the built-in table.
503
+ * See {@link GenAiObserverOptions.pricing}.
504
+ */
505
+ pricing?: Record<string, ModelPricing>;
492
506
  }
493
507
  /**
494
508
  * Create an AI SDK telemetry integration that streams canonical `gen_ai.*`
package/dist/index.cjs CHANGED
@@ -8,7 +8,7 @@ const require_streaming = require('./streaming.cjs');
8
8
  const require_trace = require('./trace.cjs');
9
9
  const require_guard = require('./guard.cjs');
10
10
  const require_ai_sdk_bridge = require('./ai-sdk-bridge.cjs');
11
- const require_observer = require('./observer-CfzH7gQt.cjs');
11
+ const require_observer = require('./observer-DBA5K_6A.cjs');
12
12
  const require_agent = require('./agent-DavvAWIG.cjs');
13
13
 
14
14
  exports.AGENT_AUDIT_SCHEMA_VERSION = require_agent.AGENT_AUDIT_SCHEMA_VERSION;
package/dist/index.d.cts CHANGED
@@ -9,7 +9,7 @@ import { CONTEXT_LIMITS, GenAiBudgetOptions, GenAiGuard, GenAiGuardOptions, GenA
9
9
  import { GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_TOKEN_USAGE_BUCKETS, GenAiHistogramKind, GenAiMetricInput, genAiMetricViews, llmHistogramAdvice, recordGenAiMetrics, resetGenAiInstruments } from "./metrics.cjs";
10
10
  import { ChunkIntervalStats, ComputeStreamTimingInput, StreamTimer, StreamTiming, chunkIntervalStats, computeStreamTiming, createStreamTimer, recordStreamTiming } from "./streaming.cjs";
11
11
  import { TraceGenAIConfig, recordGenAiResponse, recordGenAiUsage, traceGenAI, traceLLM } from "./trace.cjs";
12
- import { A as ChatStreamTiming, B as WorkflowStartEvent, C as observeAiSdkResult, D as AgentStartEvent, E as AgentEndEvent, F as SpanEnd, I as SpanStart, L as ToolEndEvent, M as GenAiObserverEvent, N as GenAiObserverOptions, O as ChatEndEvent, P as GenAiToolIdentity, R as ToolStartEvent, S as ObserveAiSdkOptions, T as createGenAiObserver, _ as AiSdkResult, b as AiSdkToolResult, c as createLangChainObserver, d as AutotelTelemetryIntegration, f as AutotelTelemetryOptions, g as promptToGenAiMessages, h as contentToGenAiMessage, j as GenAiObserver, k as ChatStartEvent, l as SubscribeAiTelemetryOptions, m as ConvertedPrompt, o as LangChainObserverHandler, p as autotelTelemetry, s as LangChainObserverOptions, u as subscribeAiTelemetry, v as AiSdkStep, w as SpanRegistry, x as AiSdkUsage, y as AiSdkToolCall, z as WorkflowEndEvent } from "./index-D0AAZXlJ.cjs";
12
+ import { A as ChatStreamTiming, B as WorkflowStartEvent, C as observeAiSdkResult, D as AgentStartEvent, E as AgentEndEvent, F as SpanEnd, I as SpanStart, L as ToolEndEvent, M as GenAiObserverEvent, N as GenAiObserverOptions, O as ChatEndEvent, P as GenAiToolIdentity, R as ToolStartEvent, S as ObserveAiSdkOptions, T as createGenAiObserver, _ as AiSdkResult, b as AiSdkToolResult, c as createLangChainObserver, d as AutotelTelemetryIntegration, f as AutotelTelemetryOptions, g as promptToGenAiMessages, h as contentToGenAiMessage, j as GenAiObserver, k as ChatStartEvent, l as SubscribeAiTelemetryOptions, m as ConvertedPrompt, o as LangChainObserverHandler, p as autotelTelemetry, s as LangChainObserverOptions, u as subscribeAiTelemetry, v as AiSdkStep, w as SpanRegistry, x as AiSdkUsage, y as AiSdkToolCall, z as WorkflowEndEvent } from "./index-BUzGrp9R.cjs";
13
13
  //#region src/redaction.d.ts
14
14
  /**
15
15
  * Keeping binary out of spans, and keeping what is left inside the limits.
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ import { CONTEXT_LIMITS, GenAiBudgetOptions, GenAiGuard, GenAiGuardOptions, GenA
9
9
  import { GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_TOKEN_USAGE_BUCKETS, GenAiHistogramKind, GenAiMetricInput, genAiMetricViews, llmHistogramAdvice, recordGenAiMetrics, resetGenAiInstruments } from "./metrics.js";
10
10
  import { ChunkIntervalStats, ComputeStreamTimingInput, StreamTimer, StreamTiming, chunkIntervalStats, computeStreamTiming, createStreamTimer, recordStreamTiming } from "./streaming.js";
11
11
  import { TraceGenAIConfig, recordGenAiResponse, recordGenAiUsage, traceGenAI, traceLLM } from "./trace.js";
12
- import { A as ChatStreamTiming, B as WorkflowStartEvent, C as observeAiSdkResult, D as AgentStartEvent, E as AgentEndEvent, F as SpanEnd, I as SpanStart, L as ToolEndEvent, M as GenAiObserverEvent, N as GenAiObserverOptions, O as ChatEndEvent, P as GenAiToolIdentity, R as ToolStartEvent, S as ObserveAiSdkOptions, T as createGenAiObserver, _ as AiSdkResult, b as AiSdkToolResult, c as createLangChainObserver, d as AutotelTelemetryIntegration, f as AutotelTelemetryOptions, g as promptToGenAiMessages, h as contentToGenAiMessage, j as GenAiObserver, k as ChatStartEvent, l as SubscribeAiTelemetryOptions, m as ConvertedPrompt, o as LangChainObserverHandler, p as autotelTelemetry, s as LangChainObserverOptions, u as subscribeAiTelemetry, v as AiSdkStep, w as SpanRegistry, x as AiSdkUsage, y as AiSdkToolCall, z as WorkflowEndEvent } from "./index-DCpmeJbI.js";
12
+ import { A as ChatStreamTiming, B as WorkflowStartEvent, C as observeAiSdkResult, D as AgentStartEvent, E as AgentEndEvent, F as SpanEnd, I as SpanStart, L as ToolEndEvent, M as GenAiObserverEvent, N as GenAiObserverOptions, O as ChatEndEvent, P as GenAiToolIdentity, R as ToolStartEvent, S as ObserveAiSdkOptions, T as createGenAiObserver, _ as AiSdkResult, b as AiSdkToolResult, c as createLangChainObserver, d as AutotelTelemetryIntegration, f as AutotelTelemetryOptions, g as promptToGenAiMessages, h as contentToGenAiMessage, j as GenAiObserver, k as ChatStartEvent, l as SubscribeAiTelemetryOptions, m as ConvertedPrompt, o as LangChainObserverHandler, p as autotelTelemetry, s as LangChainObserverOptions, u as subscribeAiTelemetry, v as AiSdkStep, w as SpanRegistry, x as AiSdkUsage, y as AiSdkToolCall, z as WorkflowEndEvent } from "./index-Qja0TsgZ.js";
13
13
  //#region src/redaction.d.ts
14
14
  /**
15
15
  * Keeping binary out of spans, and keeping what is left inside the limits.
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { chunkIntervalStats, computeStreamTiming, createStreamTimer, recordStrea
7
7
  import { recordGenAiResponse, recordGenAiUsage, traceGenAI, traceLLM } from "./trace.js";
8
8
  import { CONTEXT_LIMITS, contextBudget, costCeiling, createGenAiBudget, createGenAiGuard, errorLoop, maxDuration, maxSteps, maxToolCalls, parseGuardRules, spinLoop, tokenCeiling } from "./guard.js";
9
9
  import { AI_SDK_ATTR, AUTOTEL_ENRICHED_ATTR, autotelEnrich, estimateAiSdkCost, extractAiSdkModel, extractAiSdkUsage, mapAiSdkAttributes, normalizeAiSdkProvider, recordAiSdkCost } from "./ai-sdk-bridge.js";
10
- import { a as contentToGenAiMessage, c as createGenAiObserver, i as autotelTelemetry, l as SpanRegistry, n as createLangChainObserver, o as promptToGenAiMessages, r as subscribeAiTelemetry, s as observeAiSdkResult } from "./observer-BJVqXsky.js";
10
+ import { a as contentToGenAiMessage, c as createGenAiObserver, i as autotelTelemetry, l as SpanRegistry, n as createLangChainObserver, o as promptToGenAiMessages, r as subscribeAiTelemetry, s as observeAiSdkResult } from "./observer-DxczDG5k.js";
11
11
  import { A as createSignedEventEnvelope, B as defineAgentToolCall, F as createAgentIdentityRegistry, G as flattenAgentAttributes, H as recordPolicyDecision, I as withAgentSession, J as canonicalizeForHash, K as setAgentAttributes, L as delegateToAgent, M as resolvePrivacyProfile, N as sanitizeAuditPayload, R as recordAgentHandoff, U as withAgentAction, V as recordDecisionBasis, W as withAgentToolCall, X as AGENT_AUDIT_SCHEMA_VERSION, Y as hashPayload, j as verifyEventEnvelopeHash, k as withScopedTool, q as createAgentAuditMetadata, z as defineAgentAction } from "./agent-BaaC6IUD.js";
12
12
 
13
13
  export { AGENT_AUDIT_SCHEMA_VERSION, AI_SDK_ATTR, AUTOTEL_ENRICHED_ATTR, CONTENT_ORIGINAL_SIZE_SUFFIX, CONTEXT_LIMITS, DEFAULT_MAX_CONTENT_BYTES, GEN_AI, GEN_AI_COST_ATTRIBUTE, GEN_AI_COST_USD_BUCKETS, GEN_AI_DURATION_BUCKETS_SECONDS, GEN_AI_EVENT, GEN_AI_EXT_EVENT, GEN_AI_GUARD_EVENT, GEN_AI_METRIC, GEN_AI_OPERATION, GEN_AI_OUTPUT_TYPE, GEN_AI_PROVIDER, GEN_AI_TOKEN_TYPE, GEN_AI_TOKEN_USAGE_BUCKETS, GEN_AI_TOOL_TYPE, MODEL_PRICING, SERVER_TOOL_PRICING_PER_1K, SpanRegistry, autotelEnrich, autotelTelemetry, canonicalizeForHash, chunkIntervalStats, computeStreamTiming, contentToGenAiMessage, contextBudget, costCeiling, createAgentAuditMetadata, createAgentIdentityRegistry, createGenAiBudget, createGenAiGuard, createGenAiObserver, createLangChainObserver, createSignedEventEnvelope, createStreamTimer, defineAgentAction, defineAgentToolCall, delegateToAgent, errorLoop, estimateAiSdkCost, estimateLLMCost, extractAiSdkModel, extractAiSdkUsage, flattenAgentAttributes, genAiAgentAttributes, genAiMemoryAttributes, genAiMetricViews, genAiRequestAttributes, genAiResponseAttributes, genAiRetrievalAttributes, genAiSpanName, genAiToolAttributes, genAiUsageAttributes, genAiWorkflowAttributes, hashPayload, llmHistogramAdvice, mapAiSdkAttributes, maxDuration, maxSteps, maxToolCalls, normalizeAiSdkProvider, observeAiSdkResult, parseGuardRules, promptToGenAiMessages, recordAgentHandoff, recordAiSdkCost, recordDecisionBasis, recordEvaluationResult, recordGenAiMetrics, recordGenAiResponse, recordGenAiUsage, recordInferenceDetails, recordLLMCost, recordModelWarnings, recordOperationException, recordPolicyDecision, recordStreamTiming, redactBinaryContent, resetGenAiInstruments, resolvePrivacyProfile, sanitizeAuditPayload, serializeWithinBudget, setAgentAttributes, setGenAiContent, spinLoop, subscribeAiTelemetry, tokenCeiling, traceGenAI, traceLLM, truncateUtf8, unpricedServerTools, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_observer = require('../observer-CfzH7gQt.cjs');
2
+ const require_observer = require('../observer-DBA5K_6A.cjs');
3
3
 
4
4
  exports.SpanRegistry = require_observer.SpanRegistry;
5
5
  exports.autotelTelemetry = require_observer.autotelTelemetry;
@@ -1,2 +1,2 @@
1
- import { A as ChatStreamTiming, B as WorkflowStartEvent, C as observeAiSdkResult, D as AgentStartEvent, E as AgentEndEvent, F as SpanEnd, I as SpanStart, L as ToolEndEvent, M as GenAiObserverEvent, N as GenAiObserverOptions, O as ChatEndEvent, P as GenAiToolIdentity, R as ToolStartEvent, S as ObserveAiSdkOptions, T as createGenAiObserver, _ as AiSdkResult, a as createMastraObserver, b as AiSdkToolResult, c as createLangChainObserver, d as AutotelTelemetryIntegration, f as AutotelTelemetryOptions, g as promptToGenAiMessages, h as contentToGenAiMessage, i as MastraTracingEvent, j as GenAiObserver, k as ChatStartEvent, l as SubscribeAiTelemetryOptions, m as ConvertedPrompt, n as MastraObserverExporter, o as LangChainObserverHandler, p as autotelTelemetry, r as MastraObserverOptions, s as LangChainObserverOptions, t as MastraExportedSpan, u as subscribeAiTelemetry, v as AiSdkStep, w as SpanRegistry, x as AiSdkUsage, y as AiSdkToolCall, z as WorkflowEndEvent } from "../index-D0AAZXlJ.cjs";
1
+ import { A as ChatStreamTiming, B as WorkflowStartEvent, C as observeAiSdkResult, D as AgentStartEvent, E as AgentEndEvent, F as SpanEnd, I as SpanStart, L as ToolEndEvent, M as GenAiObserverEvent, N as GenAiObserverOptions, O as ChatEndEvent, P as GenAiToolIdentity, R as ToolStartEvent, S as ObserveAiSdkOptions, T as createGenAiObserver, _ as AiSdkResult, a as createMastraObserver, b as AiSdkToolResult, c as createLangChainObserver, d as AutotelTelemetryIntegration, f as AutotelTelemetryOptions, g as promptToGenAiMessages, h as contentToGenAiMessage, i as MastraTracingEvent, j as GenAiObserver, k as ChatStartEvent, l as SubscribeAiTelemetryOptions, m as ConvertedPrompt, n as MastraObserverExporter, o as LangChainObserverHandler, p as autotelTelemetry, r as MastraObserverOptions, s as LangChainObserverOptions, t as MastraExportedSpan, u as subscribeAiTelemetry, v as AiSdkStep, w as SpanRegistry, x as AiSdkUsage, y as AiSdkToolCall, z as WorkflowEndEvent } from "../index-BUzGrp9R.cjs";
2
2
  export { type AgentEndEvent, type AgentStartEvent, type AiSdkResult, type AiSdkStep, type AiSdkToolCall, type AiSdkToolResult, type AiSdkUsage, type AutotelTelemetryIntegration, type AutotelTelemetryOptions, type ChatEndEvent, type ChatStartEvent, type ChatStreamTiming, type ConvertedPrompt, type GenAiObserver, type GenAiObserverEvent, type GenAiObserverOptions, type GenAiToolIdentity, type LangChainObserverHandler, type LangChainObserverOptions, type MastraExportedSpan, type MastraObserverExporter, type MastraObserverOptions, type MastraTracingEvent, type ObserveAiSdkOptions, type SpanEnd, SpanRegistry, type SpanStart, type SubscribeAiTelemetryOptions, type ToolEndEvent, type ToolStartEvent, type WorkflowEndEvent, type WorkflowStartEvent, autotelTelemetry, contentToGenAiMessage, createGenAiObserver, createLangChainObserver, createMastraObserver, observeAiSdkResult, promptToGenAiMessages, subscribeAiTelemetry };
@@ -1,2 +1,2 @@
1
- import { A as ChatStreamTiming, B as WorkflowStartEvent, C as observeAiSdkResult, D as AgentStartEvent, E as AgentEndEvent, F as SpanEnd, I as SpanStart, L as ToolEndEvent, M as GenAiObserverEvent, N as GenAiObserverOptions, O as ChatEndEvent, P as GenAiToolIdentity, R as ToolStartEvent, S as ObserveAiSdkOptions, T as createGenAiObserver, _ as AiSdkResult, a as createMastraObserver, b as AiSdkToolResult, c as createLangChainObserver, d as AutotelTelemetryIntegration, f as AutotelTelemetryOptions, g as promptToGenAiMessages, h as contentToGenAiMessage, i as MastraTracingEvent, j as GenAiObserver, k as ChatStartEvent, l as SubscribeAiTelemetryOptions, m as ConvertedPrompt, n as MastraObserverExporter, o as LangChainObserverHandler, p as autotelTelemetry, r as MastraObserverOptions, s as LangChainObserverOptions, t as MastraExportedSpan, u as subscribeAiTelemetry, v as AiSdkStep, w as SpanRegistry, x as AiSdkUsage, y as AiSdkToolCall, z as WorkflowEndEvent } from "../index-DCpmeJbI.js";
1
+ import { A as ChatStreamTiming, B as WorkflowStartEvent, C as observeAiSdkResult, D as AgentStartEvent, E as AgentEndEvent, F as SpanEnd, I as SpanStart, L as ToolEndEvent, M as GenAiObserverEvent, N as GenAiObserverOptions, O as ChatEndEvent, P as GenAiToolIdentity, R as ToolStartEvent, S as ObserveAiSdkOptions, T as createGenAiObserver, _ as AiSdkResult, a as createMastraObserver, b as AiSdkToolResult, c as createLangChainObserver, d as AutotelTelemetryIntegration, f as AutotelTelemetryOptions, g as promptToGenAiMessages, h as contentToGenAiMessage, i as MastraTracingEvent, j as GenAiObserver, k as ChatStartEvent, l as SubscribeAiTelemetryOptions, m as ConvertedPrompt, n as MastraObserverExporter, o as LangChainObserverHandler, p as autotelTelemetry, r as MastraObserverOptions, s as LangChainObserverOptions, t as MastraExportedSpan, u as subscribeAiTelemetry, v as AiSdkStep, w as SpanRegistry, x as AiSdkUsage, y as AiSdkToolCall, z as WorkflowEndEvent } from "../index-Qja0TsgZ.js";
2
2
  export { type AgentEndEvent, type AgentStartEvent, type AiSdkResult, type AiSdkStep, type AiSdkToolCall, type AiSdkToolResult, type AiSdkUsage, type AutotelTelemetryIntegration, type AutotelTelemetryOptions, type ChatEndEvent, type ChatStartEvent, type ChatStreamTiming, type ConvertedPrompt, type GenAiObserver, type GenAiObserverEvent, type GenAiObserverOptions, type GenAiToolIdentity, type LangChainObserverHandler, type LangChainObserverOptions, type MastraExportedSpan, type MastraObserverExporter, type MastraObserverOptions, type MastraTracingEvent, type ObserveAiSdkOptions, type SpanEnd, SpanRegistry, type SpanStart, type SubscribeAiTelemetryOptions, type ToolEndEvent, type ToolStartEvent, type WorkflowEndEvent, type WorkflowStartEvent, autotelTelemetry, contentToGenAiMessage, createGenAiObserver, createLangChainObserver, createMastraObserver, observeAiSdkResult, promptToGenAiMessages, subscribeAiTelemetry };
@@ -1,3 +1,3 @@
1
- import { a as contentToGenAiMessage, c as createGenAiObserver, i as autotelTelemetry, l as SpanRegistry, n as createLangChainObserver, o as promptToGenAiMessages, r as subscribeAiTelemetry, s as observeAiSdkResult, t as createMastraObserver } from "../observer-BJVqXsky.js";
1
+ import { a as contentToGenAiMessage, c as createGenAiObserver, i as autotelTelemetry, l as SpanRegistry, n as createLangChainObserver, o as promptToGenAiMessages, r as subscribeAiTelemetry, s as observeAiSdkResult, t as createMastraObserver } from "../observer-DxczDG5k.js";
2
2
 
3
3
  export { SpanRegistry, autotelTelemetry, contentToGenAiMessage, createGenAiObserver, createLangChainObserver, createMastraObserver, observeAiSdkResult, promptToGenAiMessages, subscribeAiTelemetry };
@@ -172,7 +172,7 @@ function createGenAiObserver(options = {}) {
172
172
  }
173
173
  if (event.usage) {
174
174
  const costModel = event.costModel ?? event.response?.model;
175
- const costUsd = costModel ? require_cost.estimateLLMCost(costModel, event.usage) : undefined;
175
+ const costUsd = costModel ? require_cost.estimateLLMCost(costModel, event.usage, { pricing: options.pricing }) : undefined;
176
176
  span.setAttributes(require_attributes.genAiUsageAttributes({
177
177
  ...event.usage,
178
178
  costUsd
@@ -629,6 +629,7 @@ function autotelTelemetry(options = {}) {
629
629
  const observe = createGenAiObserver({
630
630
  tracer: options.tracer,
631
631
  exportContent,
632
+ pricing: options.pricing,
632
633
  resolveParentContext: options.resolveParentContext,
633
634
  onSpanStart: (id, span) => spans.set(id, span)
634
635
  });
@@ -172,7 +172,7 @@ function createGenAiObserver(options = {}) {
172
172
  }
173
173
  if (event.usage) {
174
174
  const costModel = event.costModel ?? event.response?.model;
175
- const costUsd = costModel ? estimateLLMCost(costModel, event.usage) : undefined;
175
+ const costUsd = costModel ? estimateLLMCost(costModel, event.usage, { pricing: options.pricing }) : undefined;
176
176
  span.setAttributes(genAiUsageAttributes({
177
177
  ...event.usage,
178
178
  costUsd
@@ -629,6 +629,7 @@ function autotelTelemetry(options = {}) {
629
629
  const observe = createGenAiObserver({
630
630
  tracer: options.tracer,
631
631
  exportContent,
632
+ pricing: options.pricing,
632
633
  resolveParentContext: options.resolveParentContext,
633
634
  onSpanStart: (id, span) => spans.set(id, span)
634
635
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autotel-genai",
3
- "version": "0.10.2",
3
+ "version": "0.11.0",
4
4
  "description": "Gold-standard OpenTelemetry GenAI semantic-convention instrumentation for LLM calls, tools, and agents — cost, tokens, metrics, events, and agent governance.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",