@broberg/ai-sdk 0.51.0 → 0.52.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/dist/index.d.ts CHANGED
@@ -2428,6 +2428,9 @@ declare const aiConfigSchema: z.ZodObject<{
2428
2428
  /** F069.1 — customer-key mode. Every provider must be built with byokAdapter(), so no
2429
2429
  * call can fall back to the fleet's env keys; createAI throws at setup otherwise. */
2430
2430
  byok: z.ZodOptional<z.ZodBoolean>;
2431
+ /** F069.2 — attribution labels stamped on EVERY call's usage (and so on every cost-sink
2432
+ * row), e.g. { byok: "true", tenantId }. A call's own `labels` win on the same key. */
2433
+ labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2431
2434
  /** F039.2 — client-wide opt-out from prompt caching (default: on where the
2432
2435
  * provider supports it). A per-call `promptCache` wins over this. */
2433
2436
  promptCache: z.ZodOptional<z.ZodBoolean>;
@@ -2471,6 +2474,7 @@ declare const aiConfigSchema: z.ZodObject<{
2471
2474
  }>>;
2472
2475
  }, "strip", z.ZodTypeAny, {
2473
2476
  promptCache?: boolean | undefined;
2477
+ labels?: Record<string, string> | undefined;
2474
2478
  byok?: boolean | undefined;
2475
2479
  defaults?: Partial<Record<"fast" | "smart" | "powerful" | "cheap" | "vision" | "video" | "embedding", {
2476
2480
  provider: string;
@@ -2489,6 +2493,7 @@ declare const aiConfigSchema: z.ZodObject<{
2489
2493
  } | undefined;
2490
2494
  }, {
2491
2495
  promptCache?: boolean | undefined;
2496
+ labels?: Record<string, string> | undefined;
2492
2497
  byok?: boolean | undefined;
2493
2498
  defaults?: Partial<Record<"fast" | "smart" | "powerful" | "cheap" | "vision" | "video" | "embedding", {
2494
2499
  provider: string;
@@ -2872,8 +2877,8 @@ declare const falStubAdapter: ProviderAdapter;
2872
2877
  * wires the live adapters. */
2873
2878
  declare const stubProviders: Record<string, ProviderAdapter>;
2874
2879
 
2875
- declare const VERSION: "0.51.0";
2876
- declare const SDK_TAG: "@broberg/ai-sdk@0.51.0";
2880
+ declare const VERSION: "0.52.0";
2881
+ declare const SDK_TAG: "@broberg/ai-sdk@0.52.0";
2877
2882
 
2878
2883
  /** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
2879
2884
  * per-call override.
package/dist/index.js CHANGED
@@ -3498,6 +3498,9 @@ var aiConfigSchema = z.object({
3498
3498
  /** F069.1 — customer-key mode. Every provider must be built with byokAdapter(), so no
3499
3499
  * call can fall back to the fleet's env keys; createAI throws at setup otherwise. */
3500
3500
  byok: z.boolean().optional(),
3501
+ /** F069.2 — attribution labels stamped on EVERY call's usage (and so on every cost-sink
3502
+ * row), e.g. { byok: "true", tenantId }. A call's own `labels` win on the same key. */
3503
+ labels: z.record(z.string(), z.string()).optional(),
3501
3504
  /** F039.2 — client-wide opt-out from prompt caching (default: on where the
3502
3505
  * provider supports it). A per-call `promptCache` wins over this. */
3503
3506
  promptCache: z.boolean().optional(),
@@ -3517,8 +3520,8 @@ var aiConfigSchema = z.object({
3517
3520
  import { randomUUID } from "crypto";
3518
3521
 
3519
3522
  // src/version.ts
3520
- var VERSION = "0.51.0";
3521
- var SDK_TAG = "@broberg/ai-sdk@0.51.0";
3523
+ var VERSION = "0.52.0";
3524
+ var SDK_TAG = "@broberg/ai-sdk@0.52.0";
3522
3525
 
3523
3526
  // src/cost/sinks/upmetrics.ts
3524
3527
  function isRetryableStatus(status) {
@@ -3831,7 +3834,8 @@ function createAI(config = {}) {
3831
3834
  usage.capability = capability;
3832
3835
  if (tier) usage.tier = tier;
3833
3836
  if (purpose) usage.purpose = purpose;
3834
- if (labels && Object.keys(labels).length > 0) usage.labels = labels;
3837
+ const merged = { ...cfg.labels, ...labels };
3838
+ if (Object.keys(merged).length > 0) usage.labels = merged;
3835
3839
  usage.latencyMs = Math.round(latencyMs);
3836
3840
  if (!usage.ts) usage.ts = (/* @__PURE__ */ new Date()).toISOString();
3837
3841
  return usage;