@broberg/ai-sdk 0.74.0 → 0.75.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
@@ -1,5 +1,5 @@
1
- import { U as Usage, C as CostSink, T as Tier, a as ChatResult, b as ChatStreamEvent, c as TranslateResult, I as ImageResult, A as AnimateResult, d as TrainStyleResult, E as EmbeddingResult, e as TranscribeResult, O as OcrResult, M as ModerationResult, J as JudgeResult, V as VectorizeResult, P as PodcastResult, B as BatchRequestItem, f as TierSpec, g as BatchJob, h as BatchResultItem, i as ProviderAdapter, j as ToolCall, k as Tool, l as Transport, m as Capability, R as Region, n as BudgetConfig, o as BudgetStore } from './registry-Dwe4cmUM.js';
2
- export { p as AlignedWordTimings, q as AvailabilitySource, r as AvailabilityStatus, s as AzureWordBoundary, t as CallOptions, u as ChatRequest, v as ContentPart, D as DialogueRequest, w as DialogueTurn, x as EmbeddingRequest, y as ImageRequest, z as JudgeAnswer, F as JudgeChoiceAnswer, G as JudgeNoulAnswer, H as JudgeQuestion, K as JudgeScoreAnswer, L as LoraWeight, N as Message, Q as ModelStatus, S as ModelUnavailableError, W as ModerationItem, X as ModerationRequest, Y as OcrPage, Z as OcrRequest, _ as ResolveOptions, $ as ResolveResult, a0 as Role, a1 as TierDescription, a2 as TrainStyleRequest, a3 as TranscribeRequest, a4 as TtsRequest, a5 as WordTiming, a6 as alignWordTimings, a7 as classifyRegionName, a8 as describeTier, a9 as listModels, aa as regionOfHost, ab as regionOfProvider, ac as resolveModel } from './registry-Dwe4cmUM.js';
1
+ import { U as Usage, C as CostSink, T as Tier, a as ChatResult, b as ChatStreamEvent, c as TranslateResult, I as ImageResult, A as AnimateResult, d as TrainStyleResult, E as EmbeddingResult, e as TranscribeResult, O as OcrResult, M as ModerationResult, J as JudgeResult, V as VectorizeResult, P as PodcastResult, B as BatchRequestItem, f as TierSpec, g as BatchJob, h as BatchResultItem, i as ProviderAdapter, j as ToolCall, k as Tool, l as Transport, m as Capability, R as Region, n as BudgetConfig, o as BudgetStore } from './registry-CsDDEHEr.js';
2
+ export { p as AlignedWordTimings, q as AvailabilitySource, r as AvailabilityStatus, s as AzureWordBoundary, t as CallOptions, u as ChatRequest, v as ContentPart, D as DialogueRequest, w as DialogueTurn, x as EmbeddingRequest, y as ImageRequest, z as JudgeAnswer, F as JudgeChoiceAnswer, G as JudgeNoulAnswer, H as JudgeQuestion, K as JudgeScoreAnswer, L as LoraWeight, N as Message, Q as ModelStatus, S as ModelUnavailableError, W as ModerationItem, X as ModerationRequest, Y as OcrPage, Z as OcrRequest, _ as ResolveOptions, $ as ResolveResult, a0 as Role, a1 as TierDescription, a2 as TrainStyleRequest, a3 as TranscribeRequest, a4 as TtsRequest, a5 as WordTiming, a6 as alignWordTimings, a7 as classifyRegionName, a8 as describeTier, a9 as listModels, aa as regionOfHost, ab as regionOfProvider, ac as resolveModel } from './registry-CsDDEHEr.js';
3
3
  import { z } from 'zod';
4
4
  export { CheapestQuery, CheapestResult, CheapestRow, DEFAULT_CLIP_SEC, MEDIA_PRICING_CHECKED_AT, MediaPrice, MediaUnit, PRICING_STALE_AFTER_DAYS, PriceKind, PricingFreshness, UnitFreshness, UpstreamStatus, cheapestModels, classifyKind, getMediaPrice, listMediaPrices, pricingFreshness, pricingGeneratedAt } from './pricing.js';
5
5
 
@@ -1169,7 +1169,7 @@ interface AiClient {
1169
1169
  translate(input: TranslateInput): Promise<TranslateResult>;
1170
1170
  image(input: ImageInput): Promise<ImageResult>;
1171
1171
  /** Image-to-video (F024) — animate a still into a short clip → { url, usage }.
1172
- * gemini (Veo 3.1) by default; override to fal for Kling/Seedance.
1172
+ * bfl (FLUX 3 Video, EU) by default since F092; override for other routes.
1173
1173
  *
1174
1174
  * THIS one is the tooltip a consumer sees, because it sits on the method they call.
1175
1175
  * F045 fixed the same stale "fal." on ProviderAdapter and missed this copy — super
@@ -1280,6 +1280,7 @@ declare function geminiAdapter(config?: {
1280
1280
  declare function deepinfraAdapter(config?: {
1281
1281
  apiKey?: string;
1282
1282
  baseUrl?: string;
1283
+ fetch?: typeof fetch;
1283
1284
  }): ProviderAdapter;
1284
1285
 
1285
1286
  interface OpenRouterAdapterConfig {
@@ -1501,6 +1502,10 @@ interface OpenAICompatibleConfig {
1501
1502
  * response's `usage.cost` (USD) as costUsd, falling back to the pricing table.
1502
1503
  * Only OpenRouter returns this field — openai/deepinfra leave it false. */
1503
1504
  costFromResponseField?: boolean;
1505
+ /** F091 — the provider reports its own price under this `usage` field (USD) WITHOUT
1506
+ * being asked: DeepInfra's `estimated_cost`. Read in chat and stream; wins over the
1507
+ * pricing table. Unlike costFromResponseField nothing is added to the request. */
1508
+ reportedCostField?: "estimated_cost";
1504
1509
  /** F039.2 — this provider accepts `prompt_cache_key` and caches a shared prefix
1505
1510
  * on it. Mistral only, deliberately: an unknown field is ignored by some
1506
1511
  * OpenAI-compatible servers and rejected with a 400 by others, so sending it
@@ -1582,8 +1587,8 @@ declare const falStubAdapter: ProviderAdapter;
1582
1587
  * wires the live adapters. */
1583
1588
  declare const stubProviders: Record<string, ProviderAdapter>;
1584
1589
 
1585
- declare const VERSION: "0.74.0";
1586
- declare const SDK_TAG: "@broberg/ai-sdk@0.74.0";
1590
+ declare const VERSION: "0.75.0";
1591
+ declare const SDK_TAG: "@broberg/ai-sdk@0.75.0";
1587
1592
 
1588
1593
  /** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
1589
1594
  * per-call override.
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  listMediaPrices,
24
24
  pricingFreshness,
25
25
  pricingGeneratedAt
26
- } from "./chunk-XKN2PYBQ.js";
26
+ } from "./chunk-XWWFXMDP.js";
27
27
  import {
28
28
  PRICING,
29
29
  getPrice
@@ -1209,6 +1209,12 @@ function makeOpenAICompatibleAdapter(config) {
1209
1209
  });
1210
1210
  if (config.costFromResponseField && typeof data.usage?.cost === "number") {
1211
1211
  usage.costUsd = data.usage.cost;
1212
+ usage.costBasis = "reported";
1213
+ }
1214
+ const reported = config.reportedCostField ? data.usage?.[config.reportedCostField] : void 0;
1215
+ if (typeof reported === "number") {
1216
+ usage.costUsd = reported;
1217
+ usage.costBasis = "reported";
1212
1218
  }
1213
1219
  if (typeof data.model === "string" && data.model) usage.servedModel = data.model;
1214
1220
  const result = { text, usage };
@@ -1278,6 +1284,12 @@ function makeOpenAICompatibleAdapter(config) {
1278
1284
  });
1279
1285
  if (config.costFromResponseField && typeof chunk.usage.cost === "number") {
1280
1286
  usage.costUsd = chunk.usage.cost;
1287
+ usage.costBasis = "reported";
1288
+ }
1289
+ const reportedChunk = config.reportedCostField ? chunk.usage[config.reportedCostField] : void 0;
1290
+ if (typeof reportedChunk === "number") {
1291
+ usage.costUsd = reportedChunk;
1292
+ usage.costBasis = "reported";
1281
1293
  }
1282
1294
  if (typeof chunk.model === "string" && chunk.model) usage.servedModel = chunk.model;
1283
1295
  yield { type: "usage", costUsd: usage.costUsd, model: usage.model, usage };
@@ -1688,7 +1700,10 @@ function deepinfraAdapter(config = {}) {
1688
1700
  return makeOpenAICompatibleAdapter({
1689
1701
  name: "deepinfra",
1690
1702
  baseUrl: config.baseUrl ?? DEFAULT_BASE_URLS.deepinfra,
1691
- apiKey: config.apiKey
1703
+ apiKey: config.apiKey,
1704
+ fetch: config.fetch,
1705
+ // F091 — DeepInfra puts its own price in usage.estimated_cost (measured 2026-11-17).
1706
+ reportedCostField: "estimated_cost"
1692
1707
  });
1693
1708
  }
1694
1709
 
@@ -4336,7 +4351,7 @@ var imageInputSchema = z.object({
4336
4351
  });
4337
4352
  var animateInputSchema = z.object({
4338
4353
  /** Input image: a URL or raw bytes. Where bytes are uploaded is the ADAPTER's
4339
- * business — fal uses fal storage, the Gemini/Veo default inlines them.
4354
+ * business — the BFL default sends them as keyframes; other routes upload or inline them.
4340
4355
  * Omit for text→video (F079.2): only bfl/flux-3-video supports it. */
4341
4356
  image: z.union([z.string(), z.instanceof(Uint8Array)]).optional(),
4342
4357
  /** Motion/scene prompt. */
@@ -4506,8 +4521,8 @@ var aiConfigSchema = z.object({
4506
4521
  import { randomUUID } from "crypto";
4507
4522
 
4508
4523
  // src/version.ts
4509
- var VERSION = "0.74.0";
4510
- var SDK_TAG = "@broberg/ai-sdk@0.74.0";
4524
+ var VERSION = "0.75.0";
4525
+ var SDK_TAG = "@broberg/ai-sdk@0.75.0";
4511
4526
 
4512
4527
  // src/cost/sinks/upmetrics.ts
4513
4528
  function isRetryableStatus(status) {
@@ -4806,8 +4821,8 @@ var DEFAULT_TRAINSTYLE_SPEC = {
4806
4821
  transport: "http"
4807
4822
  };
4808
4823
  var DEFAULT_ANIMATE_SPEC = {
4809
- provider: "gemini",
4810
- model: "veo-3.1-generate-preview",
4824
+ provider: "bfl",
4825
+ model: "flux-3-video",
4811
4826
  transport: "http"
4812
4827
  };
4813
4828
  var ANIMATE_AUDIO_DIRECTIVE = "No spoken dialogue, no talking, no voiceover. Include natural ambient background sounds that match the environment.";