@broberg/ai-sdk 0.19.0 → 0.21.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.
@@ -53,6 +53,14 @@ var PRICING = {
53
53
  // cheap route for fleet background work once `claude -p` is API-billed (15 Jun).
54
54
  "openrouter:deepseek/deepseek-v4-pro": { inputPer1M: 0.435, outputPer1M: 0.87, version: "2026-05-22-deepseek-official" },
55
55
  "openrouter:deepseek/deepseek-v4-flash": { inputPer1M: 0.0983, outputPer1M: 0.1966, version: "2026-05-22-deepseek-official" },
56
+ // DeepSeek DIRECT API (provider "deepseek", F030 non-PII secondary). Rates from
57
+ // api-docs.deepseek.com 2026-06-30 ($0.14/$0.28 per 1M; both map to deepseek-v4-flash).
58
+ // `deepseek-chat` (non-thinking) + `deepseek-reasoner` (thinking) DEPRECATE 2026-07-24.
59
+ // (The bare `deepseek-v4-flash` basename is already priced via the openrouter entry
60
+ // above — kept distinct here to avoid a basename collision in the F027 pricing-API.)
61
+ // Verify against a real key when it lands.
62
+ "deepseek:deepseek-chat": { inputPer1M: 0.14, outputPer1M: 0.28, version: "2026-06-30-deepseek-direct" },
63
+ "deepseek:deepseek-reasoner": { inputPer1M: 0.14, outputPer1M: 0.28, version: "2026-06-30-deepseek-direct" },
56
64
  // Google Gemini (direct). Provider key is "gemini" — matches the adapter's
57
65
  // usage.provider + the override.provider callers pass. (Image-gen models are
58
66
  // priced per-image in the adapter, not here.)
@@ -97,4 +105,4 @@ export {
97
105
  PRICING,
98
106
  getPrice
99
107
  };
100
- //# sourceMappingURL=chunk-V5AQYES2.js.map
108
+ //# sourceMappingURL=chunk-IZG5UZH5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cost/pricing.ts"],"sourcesContent":["// Versioned per-(provider, model) pricing. F3.6 populates the table + adds tests\n// + MiniMax coverage. F3.1 ships the type + lookup with an empty table, so\n// computeCost returns 0 for every model until F3.6 lands (calls still complete).\nexport interface PricingEntry {\n /** USD per 1M input tokens. */\n inputPer1M: number;\n /** USD per 1M output tokens. */\n outputPer1M: number;\n /** USD per 1M cache-read tokens (falls back to input rate if unset). */\n cacheReadPer1M?: number;\n /** USD per 1M cache-write/creation tokens (falls back to input rate if unset). */\n cacheWritePer1M?: number;\n /** Pricing snapshot version (date or tag) so stale entries are detectable. */\n version: string;\n}\n\n// USD per 1M tokens. Anthropic cache multipliers follow the standard model:\n// cache-read ≈ 0.1× input, cache-write ≈ 1.25× input. Verified against the\n// pricing tables in cms (packages/cms-ai/src/providers) + trail (model-lab).\n// MiniMax M2.7 is an estimate pending confirmation against OpenRouter's live\n// price page — flagged in its version string.\nconst V = \"2026-06-02\";\n// Mistral prices come straight from mistral.ai/pricing (per Christian's CD report).\nconst MS = \"2026-06-04-mistral.ai\";\n\n/** Keyed `${provider}:${model}`. Exported so the catalogue-research job (F014)\n * can enumerate every priced entry and diff it against the live provider lists. */\nexport const PRICING: Record<string, PricingEntry> = {\n // Anthropic (direct API). DEFAULT_TIER_MAP: fast/cheap=haiku, smart/vision=sonnet, powerful=opus.\n \"anthropic:claude-haiku-4-5\": {\n inputPer1M: 0.8,\n outputPer1M: 4.0,\n cacheReadPer1M: 0.08,\n cacheWritePer1M: 1.0,\n version: V,\n },\n \"anthropic:claude-sonnet-4-6\": {\n inputPer1M: 3.0,\n outputPer1M: 15.0,\n cacheReadPer1M: 0.3,\n cacheWritePer1M: 3.75,\n version: V,\n },\n \"anthropic:claude-opus-4-8\": {\n inputPer1M: 15.0,\n outputPer1M: 75.0,\n cacheReadPer1M: 1.5,\n cacheWritePer1M: 18.75,\n version: V,\n },\n\n // OpenAI. embedding default tier = text-embedding-3-small (no output tokens).\n \"openai:text-embedding-3-small\": { inputPer1M: 0.02, outputPer1M: 0, version: V },\n \"openai:text-embedding-3-large\": { inputPer1M: 0.13, outputPer1M: 0, version: V },\n \"openai:gpt-4o\": { inputPer1M: 2.5, outputPer1M: 10.0, version: V },\n \"openai:gpt-4o-mini\": { inputPer1M: 0.15, outputPer1M: 0.6, version: V },\n // Whisper is priced per minute, not per token — not representable here; transcribe\n // (F5.6) computes its own cost. Listed as 0 so token-based compute never charges it.\n \"openai:whisper-1\": { inputPer1M: 0, outputPer1M: 0, version: V },\n\n // OpenRouter (meta-router — model slugs include the upstream vendor). Slugs use\n // dots (claude-sonnet-4.6) to match OpenRouter's live ids; the dashed forms\n // never matched a real call. Caught by the F014 catalogue research.\n \"openrouter:anthropic/claude-sonnet-4.6\": { inputPer1M: 3.0, outputPer1M: 15.0, version: V },\n // OpenRouter ground-truth $1/$5 — a markup over Anthropic-direct's $0.8/$4\n // (the `anthropic:` entry above). Was masked while the slug used dashes.\n \"openrouter:anthropic/claude-haiku-4.5\": { inputPer1M: 1.0, outputPer1M: 5.0, version: \"2026-06-04\" },\n \"openrouter:google/gemini-2.5-flash\": { inputPer1M: 0.3, outputPer1M: 2.5, version: V },\n // Ground-truth from OpenRouter /api/v1/models (was a 0.3 estimate; now 0.279).\n \"openrouter:minimax/minimax-m2.7\": {\n inputPer1M: 0.279,\n outputPer1M: 1.2,\n version: \"2026-06-04\",\n },\n // DeepSeek V4 (CN-hosted — NOT GDPR-safe; non-personal-data workloads only).\n // On 2026-05-22 DeepSeek made the \"75% off\" promo the permanent official price.\n // V4-Pro $0.435/$0.87 is ~34x cheaper than GPT-5.5 on output; flash is cheaper\n // still. Numbers match OpenRouter /api/v1/models 1:1 (no router markup). A strong\n // cheap route for fleet background work once `claude -p` is API-billed (15 Jun).\n \"openrouter:deepseek/deepseek-v4-pro\": { inputPer1M: 0.435, outputPer1M: 0.87, version: \"2026-05-22-deepseek-official\" },\n \"openrouter:deepseek/deepseek-v4-flash\": { inputPer1M: 0.0983, outputPer1M: 0.1966, version: \"2026-05-22-deepseek-official\" },\n // DeepSeek DIRECT API (provider \"deepseek\", F030 non-PII secondary). Rates from\n // api-docs.deepseek.com 2026-06-30 ($0.14/$0.28 per 1M; both map to deepseek-v4-flash).\n // `deepseek-chat` (non-thinking) + `deepseek-reasoner` (thinking) DEPRECATE 2026-07-24.\n // (The bare `deepseek-v4-flash` basename is already priced via the openrouter entry\n // above — kept distinct here to avoid a basename collision in the F027 pricing-API.)\n // Verify against a real key when it lands.\n \"deepseek:deepseek-chat\": { inputPer1M: 0.14, outputPer1M: 0.28, version: \"2026-06-30-deepseek-direct\" },\n \"deepseek:deepseek-reasoner\": { inputPer1M: 0.14, outputPer1M: 0.28, version: \"2026-06-30-deepseek-direct\" },\n\n // Google Gemini (direct). Provider key is \"gemini\" — matches the adapter's\n // usage.provider + the override.provider callers pass. (Image-gen models are\n // priced per-image in the adapter, not here.)\n \"gemini:gemini-2.5-flash\": { inputPer1M: 0.3, outputPer1M: 2.5, version: V },\n // flash-lite is the default `video` tier (F019) — cheap native video understanding.\n \"gemini:gemini-2.5-flash-lite\": { inputPer1M: 0.1, outputPer1M: 0.4, version: \"2026-06-04-or-xref\" },\n\n // Mistral (direct, La Plateforme). Official prices from mistral.ai/pricing\n // (2026-06-04, per Christian's CD report). EU/Paris-hosted — the designated\n // GDPR-safe provider for client/personal-data workloads (see F015). NB:\n // medium-3.5 is the premium \"Vibe\" coding tier ($1.5/$7.5); Large 3 ($0.5/$1.5)\n // is the cheaper frontier general-purpose model despite the higher number.\n \"mistral:mistral-large-latest\": { inputPer1M: 0.5, outputPer1M: 1.5, version: MS },\n \"mistral:mistral-large-2512\": { inputPer1M: 0.5, outputPer1M: 1.5, version: MS },\n \"mistral:mistral-medium-latest\": { inputPer1M: 1.5, outputPer1M: 7.5, version: MS },\n \"mistral:mistral-medium-3.5\": { inputPer1M: 1.5, outputPer1M: 7.5, version: MS },\n \"mistral:mistral-medium-3\": { inputPer1M: 0.4, outputPer1M: 2.0, version: \"2026-06-04-or-xref\" },\n \"mistral:mistral-small-latest\": { inputPer1M: 0.1, outputPer1M: 0.3, version: MS },\n \"mistral:mistral-small-2603\": { inputPer1M: 0.1, outputPer1M: 0.3, version: MS },\n \"mistral:ministral-3b-latest\": { inputPer1M: 0.1, outputPer1M: 0.1, version: MS },\n \"mistral:ministral-8b-latest\": { inputPer1M: 0.15, outputPer1M: 0.15, version: MS },\n \"mistral:ministral-14b-latest\": { inputPer1M: 0.2, outputPer1M: 0.2, version: MS },\n \"mistral:magistral-medium-latest\": { inputPer1M: 2.0, outputPer1M: 5.0, version: MS },\n \"mistral:magistral-small-latest\": { inputPer1M: 0.5, outputPer1M: 1.5, version: MS },\n \"mistral:devstral-latest\": { inputPer1M: 0.4, outputPer1M: 2.0, version: MS },\n \"mistral:codestral-latest\": { inputPer1M: 0.3, outputPer1M: 0.9, version: MS },\n \"mistral:open-mistral-nemo\": { inputPer1M: 0.15, outputPer1M: 0.15, version: MS },\n // Moderation (F016.4) — per input token; output 0. (OCR is per-page in the adapter.)\n \"mistral:mistral-moderation-latest\": { inputPer1M: 0.1, outputPer1M: 0, version: MS },\n // Embeddings (F016.5) — per input token.\n \"mistral:mistral-embed\": { inputPer1M: 0.1, outputPer1M: 0, version: MS },\n \"mistral:codestral-embed\": { inputPer1M: 0.15, outputPer1M: 0, version: MS },\n};\n\nexport function getPrice(provider: string, model: string): PricingEntry | undefined {\n const exact = PRICING[`${provider}:${model}`];\n if (exact) return exact;\n // Providers ship dated model snapshots, e.g. \"claude-haiku-4-5-20251001\".\n // Strip a trailing -YYYYMMDD and retry the base lookup so a dated variant\n // prices the same as its base model instead of falling through to 0 — a real\n // paid call must never be logged as $0 (F012). Covers openrouter slugs too.\n const base = model.replace(/-\\d{8}$/, \"\");\n if (base !== model) return PRICING[`${provider}:${base}`];\n return undefined;\n}\n"],"mappings":";AAqBA,IAAM,IAAI;AAEV,IAAM,KAAK;AAIJ,IAAM,UAAwC;AAAA;AAAA,EAEnD,8BAA8B;AAAA,IAC5B,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,SAAS;AAAA,EACX;AAAA,EACA,+BAA+B;AAAA,IAC7B,YAAY;AAAA,IACZ,aAAa;AAAA,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Y,MAAM,aAAa,GAAG,SAAS,GAAG;AAC7E;AAEO,SAAS,SAAS,UAAkB,OAAyC;AAClF,QAAM,QAAQ,QAAQ,GAAG,QAAQ,IAAI,KAAK,EAAE;AAC5C,MAAI,MAAO,QAAO;AAKlB,QAAM,OAAO,MAAM,QAAQ,WAAW,EAAE;AACxC,MAAI,SAAS,MAAO,QAAO,QAAQ,GAAG,QAAQ,IAAI,IAAI,EAAE;AACxD,SAAO;AACT;","names":[]}
package/dist/index.d.ts CHANGED
@@ -245,6 +245,9 @@ interface TranscribeRequest {
245
245
  language?: string;
246
246
  /** Audio length in seconds — enables per-minute cost (Whisper). Omit → cost 0. */
247
247
  durationSec?: number;
248
+ /** Bias recognition toward these brand/jargon terms (Azure phraseList, F029.3).
249
+ * Providers without biasing support (Voxtral/Whisper) ignore it. */
250
+ phrases?: string[];
248
251
  spec: TierSpec;
249
252
  }
250
253
  interface TranscribeResult {
@@ -1312,6 +1315,8 @@ declare const transcribeInputSchema: z.ZodObject<{
1312
1315
  language: z.ZodOptional<z.ZodString>;
1313
1316
  /** Audio length in seconds — enables Whisper per-minute cost. */
1314
1317
  durationSec: z.ZodOptional<z.ZodNumber>;
1318
+ /** Bias toward brand/jargon terms (Azure phraseList, F029.3); others ignore it. */
1319
+ phrases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1315
1320
  }, "strip", z.ZodTypeAny, {
1316
1321
  audio: string | Uint8Array<ArrayBuffer>;
1317
1322
  language?: string | undefined;
@@ -1329,6 +1334,7 @@ declare const transcribeInputSchema: z.ZodObject<{
1329
1334
  })[] | undefined;
1330
1335
  labels?: Record<string, string> | undefined;
1331
1336
  durationSec?: number | undefined;
1337
+ phrases?: string[] | undefined;
1332
1338
  }, {
1333
1339
  audio: string | Uint8Array<ArrayBuffer>;
1334
1340
  language?: string | undefined;
@@ -1346,6 +1352,7 @@ declare const transcribeInputSchema: z.ZodObject<{
1346
1352
  })[] | undefined;
1347
1353
  labels?: Record<string, string> | undefined;
1348
1354
  durationSec?: number | undefined;
1355
+ phrases?: string[] | undefined;
1349
1356
  }>;
1350
1357
  declare const ocrInputSchema: z.ZodObject<{
1351
1358
  tier: z.ZodOptional<z.ZodEnum<["fast", "smart", "powerful", "cheap", "vision", "video", "embedding"]>>;
@@ -1804,6 +1811,19 @@ declare function openrouterAdapter(config?: {
1804
1811
  title?: string;
1805
1812
  }): ProviderAdapter;
1806
1813
 
1814
+ declare function requestyAdapter(config?: {
1815
+ apiKey?: string;
1816
+ baseUrl?: string;
1817
+ eu?: boolean;
1818
+ referer?: string;
1819
+ title?: string;
1820
+ }): ProviderAdapter;
1821
+
1822
+ declare function deepseekAdapter(config?: {
1823
+ apiKey?: string;
1824
+ baseUrl?: string;
1825
+ }): ProviderAdapter;
1826
+
1807
1827
  declare function mistralAdapter(config?: {
1808
1828
  apiKey?: string;
1809
1829
  baseUrl?: string;
@@ -1863,6 +1883,17 @@ declare function azureAdapter(config?: {
1863
1883
  region?: string;
1864
1884
  fetch?: typeof fetch;
1865
1885
  pricePer1kChars?: number;
1886
+ /** USD per audio-minute for transcribe (overrides AZURE_STT_PRICE_PER_MIN). */
1887
+ sttPricePerMin?: number;
1888
+ /** STT base URL override (e.g. a resource custom domain). */
1889
+ sttBaseUrl?: string;
1890
+ /** Resource name → custom-domain STT host `{resource}.cognitiveservices.azure.com`
1891
+ * (or env AZURE_SPEECH_RESOURCE). Without it, STT uses the regional host. */
1892
+ resource?: string;
1893
+ /** Fast-transcription api-version (overrides the GA default). */
1894
+ sttApiVersion?: string;
1895
+ /** phraseList biasing weight (0–2) applied when a call passes `phrases`. Default 1.5. */
1896
+ sttBiasingWeight?: number;
1866
1897
  }): ProviderAdapter;
1867
1898
 
1868
1899
  interface FalAdapterConfig {
@@ -1936,6 +1967,9 @@ declare const defaultProviders: Record<string, ProviderAdapter>;
1936
1967
  declare const anthropicApiAdapter: ProviderAdapter;
1937
1968
  /** Anthropic adapter stub (subprocess / `claude -p` path). */
1938
1969
  declare const anthropicSubprocessAdapter: ProviderAdapter;
1970
+ /** Mistral adapter stub — covers the default text/vision tiers (F030: fast/smart/
1971
+ * powerful/vision/cheap all default to Mistral EU after the Anthropic phase-out). */
1972
+ declare const mistralStubAdapter: ProviderAdapter;
1939
1973
  /** OpenAI adapter stub — covers the embedding default tier + a chat fallback. */
1940
1974
  declare const openaiStubAdapter: ProviderAdapter;
1941
1975
  /** fal.ai adapter stub — image generation (real one in fal.ts, F5.3). */
@@ -1945,16 +1979,20 @@ declare const falStubAdapter: ProviderAdapter;
1945
1979
  * wires the live adapters. */
1946
1980
  declare const stubProviders: Record<string, ProviderAdapter>;
1947
1981
 
1948
- declare const VERSION: "0.19.0";
1949
- declare const SDK_TAG: "@broberg/ai-sdk@0.19.0";
1982
+ declare const VERSION: "0.21.0";
1983
+ declare const SDK_TAG: "@broberg/ai-sdk@0.21.0";
1950
1984
 
1951
1985
  /** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
1952
- * per-call override. Model IDs are current at scaffold time; callers pin their
1953
- * own via config. `cheap` defaults to the cheapest-that's-good-enough cloud
1954
- * modelMistral Small (EU/Paris-hosted, GDPR-safe, ~$0.10/$0.30) so even a
1955
- * cost-tier call is safe for personal data by default; everything else is HTTP.
1956
- * (The `claude -p` subprocess transport still exists for explicit override, but
1957
- * is no longer a default route the fleet's agent-CLI transport moved off it.) */
1986
+ * per-call override.
1987
+ *
1988
+ * F030Anthropic API phase-out: `ANTHROPIC_API_KEY` was globally removed, so the
1989
+ * default cloud route may NOT hit Anthropic Console. `fast`/`smart`/`powerful`/
1990
+ * `vision` now default to **Mistral EU** (Paris-hosted, Schrems II-safe — so every
1991
+ * default text/vision call is GDPR-safe by default). Claude stays reachable as a
1992
+ * NON-default quality fallback for non-PII via `override:{provider:"openrouter",
1993
+ * model:"anthropic/claude-…"}`. DeepSeek (CN) is the opt-in non-PII secondary
1994
+ * (`provider:"deepseek"`), never a default. Magistral (reasoning) / mistral-large
1995
+ * for vision are per-call overrides, not defaults (don't pay the premium on all). */
1958
1996
  declare const DEFAULT_TIER_MAP: Record<Tier, TierSpec>;
1959
1997
  /**
1960
1998
  * Resolve a Tier to a concrete TierSpec.
@@ -2269,4 +2307,4 @@ interface StreamTransportRequest extends TransportRequest {
2269
2307
  */
2270
2308
  declare function streamTransport(req: StreamTransportRequest): AsyncIterable<string>;
2271
2309
 
2272
- export { AZURE_DANISH_VOICES, AZURE_DANISH_VOICE_LIST, type AiClient, type AiConfig, type AzureVoiceInfo, type BatchJob, type BatchRequestItem, type BatchResultItem, type BflAdapterConfig, type BflCredits, type BudgetConfig, BudgetExceededError, BudgetGuard, type BudgetStore, type CallOptions, type Capability, type ChatInput, type ChatRequest, type ChatResult, type ChatStreamEvent, type ClassifyInput, type ClassifyResult, type ContentPart, type Contracts, type CostQuery, type CostSink, type CostSummary, type CostSummaryQuery, type CostTimeseriesQuery, DEFAULT_TIER_MAP, type DesignInput, type DesignResult, type DialogueRequest, type DialogueTurn, type DiscordSinkConfig, ELEVENLABS_DANISH_VOICES, type EmbeddingInput, type EmbeddingRequest, type EmbeddingResult, type ExtractInput, type ExtractResult, type FalAdapterConfig, type HttpResponse, type ImageInput, type ImageRequest, type ImageResult, type LoraWeight, type Message, type MockupInput, type MockupResult, type ModerationInput, type ModerationItem, type ModerationRequest, type ModerationResult, type OcrInput, type OcrPage, type OcrRequest, type OcrResult, type OpenAICompatibleConfig, type PodcastInput, type PodcastResult, type PricingEntry, type ProviderAdapter, type RefreshOptions, type RefreshResult, type RerankInput, type RerankResult, type Role, SDK_TAG, type SqliteBudgetStoreConfig, type SqliteSinkConfig, StreamHttpError, type SubprocessResponse, type Tier, type TierSpec, type Tool, type ToolCall, type TrainStyleInput, type TrainStyleRequest, type TrainStyleResult, type TranscribeInput, type TranscribeRequest, type TranscribeResult, type TranslateInput, type TranslateResult, type Transport, type TransportRequest, type TransportResponse, type TtsInput, type TtsRequest, type UpmetricsCostClientConfig, UpmetricsCostError, type UpmetricsCostRow, type UpmetricsCostSummary, type UpmetricsCostTimeseries, type UpmetricsSinkConfig, type Usage, VERSION, type VideoInput, type VisionInput, aiConfigSchema, anthropicAdapter, anthropicApiAdapter, anthropicSubprocessAdapter, azureAdapter, bflAdapter, bflCredits, chatInputSchema, computeCost, createAI, deepinfraAdapter, defaultProviders, discordSink, elevenlabsAdapter, embeddingInputSchema, falAdapter, falStubAdapter, freshUsage, fromProviderToolCall, geminiAdapter, getCostSummary, getPrice, httpTransport, imageInputSchema, listAzureDanishVoices, makeContracts, makeOpenAICompatibleAdapter, messageSchema, mistralAdapter, multiSink, noopSink, openaiAdapter, openaiStubAdapter, openrouterAdapter, parseClaudeCliJson, parseJsonLoose, refreshAvailability, resetRefreshState, resetRegistry, resolveAzureVoice, resolveTier, resolveVoice, sqliteBudgetStore, sqliteSink, streamTransport, stubProviders, subprocessTransport, tierSpecSchema, toProviderTools, toolSchema, translateInputSchema, upmetricsCostClient, upmetricsSink, usdFromMicro, visionInputSchema };
2310
+ export { AZURE_DANISH_VOICES, AZURE_DANISH_VOICE_LIST, type AiClient, type AiConfig, type AzureVoiceInfo, type BatchJob, type BatchRequestItem, type BatchResultItem, type BflAdapterConfig, type BflCredits, type BudgetConfig, BudgetExceededError, BudgetGuard, type BudgetStore, type CallOptions, type Capability, type ChatInput, type ChatRequest, type ChatResult, type ChatStreamEvent, type ClassifyInput, type ClassifyResult, type ContentPart, type Contracts, type CostQuery, type CostSink, type CostSummary, type CostSummaryQuery, type CostTimeseriesQuery, DEFAULT_TIER_MAP, type DesignInput, type DesignResult, type DialogueRequest, type DialogueTurn, type DiscordSinkConfig, ELEVENLABS_DANISH_VOICES, type EmbeddingInput, type EmbeddingRequest, type EmbeddingResult, type ExtractInput, type ExtractResult, type FalAdapterConfig, type HttpResponse, type ImageInput, type ImageRequest, type ImageResult, type LoraWeight, type Message, type MockupInput, type MockupResult, type ModerationInput, type ModerationItem, type ModerationRequest, type ModerationResult, type OcrInput, type OcrPage, type OcrRequest, type OcrResult, type OpenAICompatibleConfig, type PodcastInput, type PodcastResult, type PricingEntry, type ProviderAdapter, type RefreshOptions, type RefreshResult, type RerankInput, type RerankResult, type Role, SDK_TAG, type SqliteBudgetStoreConfig, type SqliteSinkConfig, StreamHttpError, type SubprocessResponse, type Tier, type TierSpec, type Tool, type ToolCall, type TrainStyleInput, type TrainStyleRequest, type TrainStyleResult, type TranscribeInput, type TranscribeRequest, type TranscribeResult, type TranslateInput, type TranslateResult, type Transport, type TransportRequest, type TransportResponse, type TtsInput, type TtsRequest, type UpmetricsCostClientConfig, UpmetricsCostError, type UpmetricsCostRow, type UpmetricsCostSummary, type UpmetricsCostTimeseries, type UpmetricsSinkConfig, type Usage, VERSION, type VideoInput, type VisionInput, aiConfigSchema, anthropicAdapter, anthropicApiAdapter, anthropicSubprocessAdapter, azureAdapter, bflAdapter, bflCredits, chatInputSchema, computeCost, createAI, deepinfraAdapter, deepseekAdapter, defaultProviders, discordSink, elevenlabsAdapter, embeddingInputSchema, falAdapter, falStubAdapter, freshUsage, fromProviderToolCall, geminiAdapter, getCostSummary, getPrice, httpTransport, imageInputSchema, listAzureDanishVoices, makeContracts, makeOpenAICompatibleAdapter, messageSchema, mistralAdapter, mistralStubAdapter, multiSink, noopSink, openaiAdapter, openaiStubAdapter, openrouterAdapter, parseClaudeCliJson, parseJsonLoose, refreshAvailability, requestyAdapter, resetRefreshState, resetRegistry, resolveAzureVoice, resolveTier, resolveVoice, sqliteBudgetStore, sqliteSink, streamTransport, stubProviders, subprocessTransport, tierSpecSchema, toProviderTools, toolSchema, translateInputSchema, upmetricsCostClient, upmetricsSink, usdFromMicro, visionInputSchema };
package/dist/index.js CHANGED
@@ -8,17 +8,21 @@ import {
8
8
  } from "./chunk-HVZSYNZ5.js";
9
9
  import {
10
10
  getPrice
11
- } from "./chunk-V5AQYES2.js";
11
+ } from "./chunk-IZG5UZH5.js";
12
12
 
13
13
  // src/routing/tier-map.ts
14
14
  var DEFAULT_TIER_MAP = {
15
- fast: { provider: "anthropic", model: "claude-haiku-4-5", transport: "http" },
16
- smart: { provider: "anthropic", model: "claude-sonnet-4-6", transport: "http" },
17
- powerful: { provider: "anthropic", model: "claude-opus-4-8", transport: "http" },
15
+ fast: { provider: "mistral", model: "mistral-small-latest", transport: "http" },
16
+ smart: { provider: "mistral", model: "mistral-large-latest", transport: "http" },
17
+ powerful: { provider: "mistral", model: "mistral-large-latest", transport: "http" },
18
18
  cheap: { provider: "mistral", model: "mistral-small-latest", transport: "http" },
19
- vision: { provider: "anthropic", model: "claude-sonnet-4-6", transport: "http" },
19
+ // Vision: small-latest (vision-capable, cheap EU) is the default; override to
20
+ // mistral-large-latest for demanding image/spatial/composition work.
21
+ vision: { provider: "mistral", model: "mistral-small-latest", transport: "http" },
20
22
  // Native video understanding — Gemini leads; flash-lite is the cheap default (F019).
23
+ // NOT Anthropic → out of the F030 phase-out (its own EU epic if/when needed).
21
24
  video: { provider: "gemini", model: "gemini-2.5-flash-lite", transport: "http" },
25
+ // NOT Anthropic → out of F030 (EU-embedding migration is its own future epic).
22
26
  embedding: { provider: "openai", model: "text-embedding-3-small", transport: "http" }
23
27
  };
24
28
  function resolveTier(tier, override, configMap) {
@@ -1056,6 +1060,36 @@ function openrouterAdapter(config = {}) {
1056
1060
  });
1057
1061
  }
1058
1062
 
1063
+ // src/providers/requesty.ts
1064
+ var US_BASE = "https://router.requesty.ai/v1";
1065
+ var EU_BASE = "https://router.eu.requesty.ai/v1";
1066
+ function requestyAdapter(config = {}) {
1067
+ return makeOpenAICompatibleAdapter({
1068
+ name: "requesty",
1069
+ baseUrl: config.baseUrl ?? (config.eu ? EU_BASE : US_BASE),
1070
+ apiKey: config.apiKey,
1071
+ extraHeaders: {
1072
+ "HTTP-Referer": config.referer ?? "https://broberg.ai",
1073
+ "X-Title": config.title ?? "@broberg/ai-sdk"
1074
+ },
1075
+ // Requesty returns ground-truth usage.cost (USD) by default — use it over the
1076
+ // local pricing-table estimate (same as OpenRouter, F010).
1077
+ costFromResponseField: true
1078
+ });
1079
+ }
1080
+
1081
+ // src/providers/deepseek.ts
1082
+ function deepseekAdapter(config = {}) {
1083
+ return makeOpenAICompatibleAdapter({
1084
+ name: "deepseek",
1085
+ // → key DEEPSEEK_API_KEY
1086
+ baseUrl: config.baseUrl ?? "https://api.deepseek.com/v1",
1087
+ apiKey: config.apiKey,
1088
+ // Direct API returns no usage.cost → price from the table (not response).
1089
+ costFromResponseField: false
1090
+ });
1091
+ }
1092
+
1059
1093
  // src/providers/mistral.ts
1060
1094
  var MISTRAL_OCR_PRICE_PER_PAGE = 2e-3;
1061
1095
  var VOXTRAL_PRICE_PER_MIN = {
@@ -1305,8 +1339,29 @@ function elevenlabsAdapter(config = {}) {
1305
1339
 
1306
1340
  // src/providers/azure.ts
1307
1341
  var AZURE_TTS_PRICE_PER_1K_CHARS = 0.016;
1342
+ var AZURE_STT_PRICE_PER_MIN = 0.0167;
1343
+ var DEFAULT_STT_API_VERSION = "2025-10-15";
1308
1344
  var DEFAULT_REGION = "westeurope";
1309
1345
  var DEFAULT_FORMAT = "audio-24khz-48kbitrate-mono-mp3";
1346
+ var AZURE_LOCALE_MAP = {
1347
+ da: "da-DK",
1348
+ en: "en-US",
1349
+ de: "de-DE",
1350
+ sv: "sv-SE",
1351
+ nb: "nb-NO",
1352
+ no: "nb-NO",
1353
+ fi: "fi-FI",
1354
+ nl: "nl-NL",
1355
+ fr: "fr-FR",
1356
+ es: "es-ES",
1357
+ it: "it-IT",
1358
+ pt: "pt-PT"
1359
+ };
1360
+ function toAzureLocale(lang) {
1361
+ if (!lang) return "da-DK";
1362
+ if (lang.includes("-")) return lang;
1363
+ return AZURE_LOCALE_MAP[lang.toLowerCase()] ?? lang;
1364
+ }
1310
1365
  var AZURE_DANISH_VOICE_LIST = [
1311
1366
  { name: "christel", voiceId: "da-DK-ChristelNeural", gender: "female", display: "Christel", native: true, defaultRate: 0.85 },
1312
1367
  { name: "seraphina", voiceId: "de-DE-SeraphinaMultilingualNeural", gender: "female", display: "Seraphina", native: false },
@@ -1341,6 +1396,12 @@ function azureAdapter(config = {}) {
1341
1396
  function region() {
1342
1397
  return config.region ?? process.env.AZURE_SPEECH_REGION ?? DEFAULT_REGION;
1343
1398
  }
1399
+ function sttBaseUrl() {
1400
+ if (config.sttBaseUrl) return config.sttBaseUrl.replace(/\/$/, "");
1401
+ const resource = config.resource ?? process.env.AZURE_SPEECH_RESOURCE;
1402
+ if (resource) return `https://${resource}.cognitiveservices.azure.com`;
1403
+ return `https://${region()}.api.cognitive.microsoft.com`;
1404
+ }
1344
1405
  function priceFor(chars, model) {
1345
1406
  const usage = freshUsage({
1346
1407
  provider: "azure",
@@ -1380,7 +1441,40 @@ function azureAdapter(config = {}) {
1380
1441
  const audio = new Uint8Array(await res.arrayBuffer());
1381
1442
  return { audio, mimeType: "audio/mpeg", usage: priceFor(req.text.length, req.spec.model) };
1382
1443
  }
1383
- return { name: "azure", tts };
1444
+ async function transcribe(req) {
1445
+ const locale = toAzureLocale(req.language);
1446
+ const definition = { locales: [locale] };
1447
+ if (req.phrases && req.phrases.length > 0) {
1448
+ definition.phraseList = { phrases: req.phrases, biasingWeight: config.sttBiasingWeight ?? 1.5 };
1449
+ }
1450
+ const form = new FormData();
1451
+ form.append("audio", new Blob([req.audio]), "audio");
1452
+ form.append("definition", JSON.stringify(definition));
1453
+ const url = `${sttBaseUrl()}/speechtotext/transcriptions:transcribe?api-version=${config.sttApiVersion ?? DEFAULT_STT_API_VERSION}`;
1454
+ const res = await fetchImpl(url, {
1455
+ method: "POST",
1456
+ headers: { "Ocp-Apim-Subscription-Key": key() },
1457
+ body: form
1458
+ });
1459
+ if (!res.ok) {
1460
+ const body = await res.text().catch(() => "");
1461
+ throw new Error(`azure transcribe ${res.status}: ${body.slice(0, 300)}`);
1462
+ }
1463
+ const data = await res.json();
1464
+ const text = data.combinedPhrases?.[0]?.text ?? "";
1465
+ const minutes = data.durationMilliseconds != null ? data.durationMilliseconds / 6e4 : (req.durationSec ?? 0) / 60;
1466
+ const usage = freshUsage({
1467
+ provider: "azure",
1468
+ model: req.spec.model,
1469
+ transport: "http",
1470
+ capability: "transcribe",
1471
+ inputTokens: 0,
1472
+ outputTokens: 0
1473
+ });
1474
+ usage.costUsd = minutes * (config.sttPricePerMin ?? AZURE_STT_PRICE_PER_MIN);
1475
+ return { text, usage };
1476
+ }
1477
+ return { name: "azure", tts, transcribe };
1384
1478
  }
1385
1479
 
1386
1480
  // src/providers/fal.ts
@@ -1696,7 +1790,7 @@ function buildZip(files) {
1696
1790
  }
1697
1791
 
1698
1792
  // src/providers/bfl.ts
1699
- var EU_BASE = "https://api.eu.bfl.ai";
1793
+ var EU_BASE2 = "https://api.eu.bfl.ai";
1700
1794
  var BFL_CREDIT_USD = 0.01;
1701
1795
  var BFL_IMAGE_PRICE = 0.06;
1702
1796
  var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
@@ -1707,7 +1801,7 @@ async function bflCredits(opts = {}) {
1707
1801
  const apiKey = opts.apiKey ?? process.env.BFL_API_KEY;
1708
1802
  if (!apiKey) throw new Error("bflCredits: BFL_API_KEY not set");
1709
1803
  const doFetch = opts.fetch ?? fetch;
1710
- const res = await doFetch(`${opts.baseUrl ?? EU_BASE}/v1/credits`, { headers: { "x-key": apiKey } });
1804
+ const res = await doFetch(`${opts.baseUrl ?? EU_BASE2}/v1/credits`, { headers: { "x-key": apiKey } });
1711
1805
  if (!res.ok) {
1712
1806
  throw new Error(`bflCredits ${res.status}: ${(await res.text().catch(() => "")).slice(0, 200)}`);
1713
1807
  }
@@ -1717,7 +1811,7 @@ async function bflCredits(opts = {}) {
1717
1811
  }
1718
1812
  function bflAdapter(config = {}) {
1719
1813
  const doFetch = config.fetch ?? fetch;
1720
- const base = config.baseUrl ?? EU_BASE;
1814
+ const base = config.baseUrl ?? EU_BASE2;
1721
1815
  const pollIntervalMs = config.pollIntervalMs ?? 1500;
1722
1816
  const timeoutMs = config.timeoutMs ?? 12e4;
1723
1817
  const resolveKey = () => config.apiKey ?? process.env.BFL_API_KEY;
@@ -1808,6 +1902,8 @@ var defaultProviders = {
1808
1902
  gemini: geminiAdapter(),
1809
1903
  deepinfra: deepinfraAdapter(),
1810
1904
  openrouter: openrouterAdapter(),
1905
+ requesty: requestyAdapter(),
1906
+ deepseek: deepseekAdapter(),
1811
1907
  mistral: mistralAdapter(),
1812
1908
  elevenlabs: elevenlabsAdapter(),
1813
1909
  azure: azureAdapter(),
@@ -2173,6 +2269,8 @@ var transcribeInputSchema = z.object({
2173
2269
  language: z.string().optional(),
2174
2270
  /** Audio length in seconds — enables Whisper per-minute cost. */
2175
2271
  durationSec: z.number().positive().optional(),
2272
+ /** Bias toward brand/jargon terms (Azure phraseList, F029.3); others ignore it. */
2273
+ phrases: z.array(z.string()).optional(),
2176
2274
  ...callOptions
2177
2275
  });
2178
2276
  var ocrInputSchema = z.object({
@@ -2689,7 +2787,7 @@ function createAI(config = {}) {
2689
2787
  invoke: async (spec) => {
2690
2788
  const adapter = pickProvider(spec.provider);
2691
2789
  if (!adapter.transcribe) throw new Error(`createAI: provider "${spec.provider}" does not support transcribe`);
2692
- return adapter.transcribe({ audio, language: input.language, durationSec: input.durationSec, spec });
2790
+ return adapter.transcribe({ audio, language: input.language, durationSec: input.durationSec, phrases: input.phrases, spec });
2693
2791
  }
2694
2792
  });
2695
2793
  },
@@ -2770,6 +2868,21 @@ var anthropicSubprocessAdapter = {
2770
2868
  return { text: `[stub:anthropic-subprocess] ${lastUserText(req)}`, usage };
2771
2869
  }
2772
2870
  };
2871
+ var mistralStubAdapter = {
2872
+ name: "mistral",
2873
+ async chat(req) {
2874
+ return {
2875
+ text: `[stub:mistral] ${lastUserText(req)}`,
2876
+ usage: stubUsage("mistral", req.spec.model, "http", "chat")
2877
+ };
2878
+ },
2879
+ async vision(req) {
2880
+ return {
2881
+ text: `[stub:mistral:vision] ${lastUserText(req)}`,
2882
+ usage: stubUsage("mistral", req.spec.model, "http", "vision")
2883
+ };
2884
+ }
2885
+ };
2773
2886
  var openaiStubAdapter = {
2774
2887
  name: "openai",
2775
2888
  async chat(req) {
@@ -2796,13 +2909,14 @@ var falStubAdapter = {
2796
2909
  };
2797
2910
  var stubProviders = {
2798
2911
  anthropic: anthropicApiAdapter,
2912
+ mistral: mistralStubAdapter,
2799
2913
  openai: openaiStubAdapter,
2800
2914
  fal: falStubAdapter
2801
2915
  };
2802
2916
 
2803
2917
  // src/version.ts
2804
- var VERSION = "0.19.0";
2805
- var SDK_TAG = "@broberg/ai-sdk@0.19.0";
2918
+ var VERSION = "0.21.0";
2919
+ var SDK_TAG = "@broberg/ai-sdk@0.21.0";
2806
2920
 
2807
2921
  // src/availability/refresh.ts
2808
2922
  var NOT_REFRESHED = { refreshed: false, checked: 0, markedUnavailable: [] };
@@ -3165,6 +3279,7 @@ export {
3165
3279
  computeCost,
3166
3280
  createAI,
3167
3281
  deepinfraAdapter,
3282
+ deepseekAdapter,
3168
3283
  defaultProviders,
3169
3284
  discordSink,
3170
3285
  elevenlabsAdapter,
@@ -3184,6 +3299,7 @@ export {
3184
3299
  makeOpenAICompatibleAdapter,
3185
3300
  messageSchema,
3186
3301
  mistralAdapter,
3302
+ mistralStubAdapter,
3187
3303
  multiSink,
3188
3304
  noopSink,
3189
3305
  openaiAdapter,
@@ -3192,6 +3308,7 @@ export {
3192
3308
  parseClaudeCliJson,
3193
3309
  parseJsonLoose,
3194
3310
  refreshAvailability,
3311
+ requestyAdapter,
3195
3312
  resetRefreshState,
3196
3313
  resetRegistry,
3197
3314
  resolveAzureVoice,