@broberg/ai-sdk 0.17.1 → 0.19.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/chunk-V5AQYES2.js +100 -0
- package/dist/chunk-V5AQYES2.js.map +1 -0
- package/dist/index.d.ts +150 -3
- package/dist/index.js +165 -98
- package/dist/index.js.map +1 -1
- package/dist/pricing.d.ts +40 -0
- package/dist/pricing.js +118 -0
- package/dist/pricing.js.map +1 -0
- package/package.json +7 -2
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// src/cost/pricing.ts
|
|
2
|
+
var V = "2026-06-02";
|
|
3
|
+
var MS = "2026-06-04-mistral.ai";
|
|
4
|
+
var PRICING = {
|
|
5
|
+
// Anthropic (direct API). DEFAULT_TIER_MAP: fast/cheap=haiku, smart/vision=sonnet, powerful=opus.
|
|
6
|
+
"anthropic:claude-haiku-4-5": {
|
|
7
|
+
inputPer1M: 0.8,
|
|
8
|
+
outputPer1M: 4,
|
|
9
|
+
cacheReadPer1M: 0.08,
|
|
10
|
+
cacheWritePer1M: 1,
|
|
11
|
+
version: V
|
|
12
|
+
},
|
|
13
|
+
"anthropic:claude-sonnet-4-6": {
|
|
14
|
+
inputPer1M: 3,
|
|
15
|
+
outputPer1M: 15,
|
|
16
|
+
cacheReadPer1M: 0.3,
|
|
17
|
+
cacheWritePer1M: 3.75,
|
|
18
|
+
version: V
|
|
19
|
+
},
|
|
20
|
+
"anthropic:claude-opus-4-8": {
|
|
21
|
+
inputPer1M: 15,
|
|
22
|
+
outputPer1M: 75,
|
|
23
|
+
cacheReadPer1M: 1.5,
|
|
24
|
+
cacheWritePer1M: 18.75,
|
|
25
|
+
version: V
|
|
26
|
+
},
|
|
27
|
+
// OpenAI. embedding default tier = text-embedding-3-small (no output tokens).
|
|
28
|
+
"openai:text-embedding-3-small": { inputPer1M: 0.02, outputPer1M: 0, version: V },
|
|
29
|
+
"openai:text-embedding-3-large": { inputPer1M: 0.13, outputPer1M: 0, version: V },
|
|
30
|
+
"openai:gpt-4o": { inputPer1M: 2.5, outputPer1M: 10, version: V },
|
|
31
|
+
"openai:gpt-4o-mini": { inputPer1M: 0.15, outputPer1M: 0.6, version: V },
|
|
32
|
+
// Whisper is priced per minute, not per token — not representable here; transcribe
|
|
33
|
+
// (F5.6) computes its own cost. Listed as 0 so token-based compute never charges it.
|
|
34
|
+
"openai:whisper-1": { inputPer1M: 0, outputPer1M: 0, version: V },
|
|
35
|
+
// OpenRouter (meta-router — model slugs include the upstream vendor). Slugs use
|
|
36
|
+
// dots (claude-sonnet-4.6) to match OpenRouter's live ids; the dashed forms
|
|
37
|
+
// never matched a real call. Caught by the F014 catalogue research.
|
|
38
|
+
"openrouter:anthropic/claude-sonnet-4.6": { inputPer1M: 3, outputPer1M: 15, version: V },
|
|
39
|
+
// OpenRouter ground-truth $1/$5 — a markup over Anthropic-direct's $0.8/$4
|
|
40
|
+
// (the `anthropic:` entry above). Was masked while the slug used dashes.
|
|
41
|
+
"openrouter:anthropic/claude-haiku-4.5": { inputPer1M: 1, outputPer1M: 5, version: "2026-06-04" },
|
|
42
|
+
"openrouter:google/gemini-2.5-flash": { inputPer1M: 0.3, outputPer1M: 2.5, version: V },
|
|
43
|
+
// Ground-truth from OpenRouter /api/v1/models (was a 0.3 estimate; now 0.279).
|
|
44
|
+
"openrouter:minimax/minimax-m2.7": {
|
|
45
|
+
inputPer1M: 0.279,
|
|
46
|
+
outputPer1M: 1.2,
|
|
47
|
+
version: "2026-06-04"
|
|
48
|
+
},
|
|
49
|
+
// DeepSeek V4 (CN-hosted — NOT GDPR-safe; non-personal-data workloads only).
|
|
50
|
+
// On 2026-05-22 DeepSeek made the "75% off" promo the permanent official price.
|
|
51
|
+
// V4-Pro $0.435/$0.87 is ~34x cheaper than GPT-5.5 on output; flash is cheaper
|
|
52
|
+
// still. Numbers match OpenRouter /api/v1/models 1:1 (no router markup). A strong
|
|
53
|
+
// cheap route for fleet background work once `claude -p` is API-billed (15 Jun).
|
|
54
|
+
"openrouter:deepseek/deepseek-v4-pro": { inputPer1M: 0.435, outputPer1M: 0.87, version: "2026-05-22-deepseek-official" },
|
|
55
|
+
"openrouter:deepseek/deepseek-v4-flash": { inputPer1M: 0.0983, outputPer1M: 0.1966, version: "2026-05-22-deepseek-official" },
|
|
56
|
+
// Google Gemini (direct). Provider key is "gemini" — matches the adapter's
|
|
57
|
+
// usage.provider + the override.provider callers pass. (Image-gen models are
|
|
58
|
+
// priced per-image in the adapter, not here.)
|
|
59
|
+
"gemini:gemini-2.5-flash": { inputPer1M: 0.3, outputPer1M: 2.5, version: V },
|
|
60
|
+
// flash-lite is the default `video` tier (F019) — cheap native video understanding.
|
|
61
|
+
"gemini:gemini-2.5-flash-lite": { inputPer1M: 0.1, outputPer1M: 0.4, version: "2026-06-04-or-xref" },
|
|
62
|
+
// Mistral (direct, La Plateforme). Official prices from mistral.ai/pricing
|
|
63
|
+
// (2026-06-04, per Christian's CD report). EU/Paris-hosted — the designated
|
|
64
|
+
// GDPR-safe provider for client/personal-data workloads (see F015). NB:
|
|
65
|
+
// medium-3.5 is the premium "Vibe" coding tier ($1.5/$7.5); Large 3 ($0.5/$1.5)
|
|
66
|
+
// is the cheaper frontier general-purpose model despite the higher number.
|
|
67
|
+
"mistral:mistral-large-latest": { inputPer1M: 0.5, outputPer1M: 1.5, version: MS },
|
|
68
|
+
"mistral:mistral-large-2512": { inputPer1M: 0.5, outputPer1M: 1.5, version: MS },
|
|
69
|
+
"mistral:mistral-medium-latest": { inputPer1M: 1.5, outputPer1M: 7.5, version: MS },
|
|
70
|
+
"mistral:mistral-medium-3.5": { inputPer1M: 1.5, outputPer1M: 7.5, version: MS },
|
|
71
|
+
"mistral:mistral-medium-3": { inputPer1M: 0.4, outputPer1M: 2, version: "2026-06-04-or-xref" },
|
|
72
|
+
"mistral:mistral-small-latest": { inputPer1M: 0.1, outputPer1M: 0.3, version: MS },
|
|
73
|
+
"mistral:mistral-small-2603": { inputPer1M: 0.1, outputPer1M: 0.3, version: MS },
|
|
74
|
+
"mistral:ministral-3b-latest": { inputPer1M: 0.1, outputPer1M: 0.1, version: MS },
|
|
75
|
+
"mistral:ministral-8b-latest": { inputPer1M: 0.15, outputPer1M: 0.15, version: MS },
|
|
76
|
+
"mistral:ministral-14b-latest": { inputPer1M: 0.2, outputPer1M: 0.2, version: MS },
|
|
77
|
+
"mistral:magistral-medium-latest": { inputPer1M: 2, outputPer1M: 5, version: MS },
|
|
78
|
+
"mistral:magistral-small-latest": { inputPer1M: 0.5, outputPer1M: 1.5, version: MS },
|
|
79
|
+
"mistral:devstral-latest": { inputPer1M: 0.4, outputPer1M: 2, version: MS },
|
|
80
|
+
"mistral:codestral-latest": { inputPer1M: 0.3, outputPer1M: 0.9, version: MS },
|
|
81
|
+
"mistral:open-mistral-nemo": { inputPer1M: 0.15, outputPer1M: 0.15, version: MS },
|
|
82
|
+
// Moderation (F016.4) — per input token; output 0. (OCR is per-page in the adapter.)
|
|
83
|
+
"mistral:mistral-moderation-latest": { inputPer1M: 0.1, outputPer1M: 0, version: MS },
|
|
84
|
+
// Embeddings (F016.5) — per input token.
|
|
85
|
+
"mistral:mistral-embed": { inputPer1M: 0.1, outputPer1M: 0, version: MS },
|
|
86
|
+
"mistral:codestral-embed": { inputPer1M: 0.15, outputPer1M: 0, version: MS }
|
|
87
|
+
};
|
|
88
|
+
function getPrice(provider, model) {
|
|
89
|
+
const exact = PRICING[`${provider}:${model}`];
|
|
90
|
+
if (exact) return exact;
|
|
91
|
+
const base = model.replace(/-\d{8}$/, "");
|
|
92
|
+
if (base !== model) return PRICING[`${provider}:${base}`];
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
PRICING,
|
|
98
|
+
getPrice
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=chunk-V5AQYES2.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\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,IACb,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,SAAS;AAAA,EACX;AAAA,EACA,6BAA6B;AAAA,IAC3B,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,SAAS;AAAA,EACX;AAAA;AAAA,EAGA,iCAAiC,EAAE,YAAY,MAAM,aAAa,GAAG,SAAS,EAAE;AAAA,EAChF,iCAAiC,EAAE,YAA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"). Azure uses it for SSML xml:lang; ElevenLabs ignores it. */
|
|
302
|
+
lang?: string;
|
|
303
|
+
/** Provider output-format hint (e.g. an Azure X-Microsoft-OutputFormat); ElevenLabs ignores it. */
|
|
304
|
+
format?: string;
|
|
305
|
+
/** Speaking-rate multiplier (Azure): 1 = normal, 0.9 = 10% slower, 1.1 = faster. ElevenLabs ignores it. */
|
|
306
|
+
rate?: number;
|
|
301
307
|
spec: TierSpec;
|
|
302
308
|
}
|
|
303
309
|
interface BatchRequestItem {
|
|
@@ -1585,6 +1591,9 @@ declare const ttsInputSchema: z.ZodObject<{
|
|
|
1585
1591
|
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1586
1592
|
text: z.ZodString;
|
|
1587
1593
|
voice: z.ZodString;
|
|
1594
|
+
lang: z.ZodOptional<z.ZodString>;
|
|
1595
|
+
format: z.ZodOptional<z.ZodString>;
|
|
1596
|
+
rate: z.ZodOptional<z.ZodNumber>;
|
|
1588
1597
|
}, "strip", z.ZodTypeAny, {
|
|
1589
1598
|
text: string;
|
|
1590
1599
|
voice: string;
|
|
@@ -1601,6 +1610,9 @@ declare const ttsInputSchema: z.ZodObject<{
|
|
|
1601
1610
|
transport: "http" | "subprocess";
|
|
1602
1611
|
})[] | undefined;
|
|
1603
1612
|
labels?: Record<string, string> | undefined;
|
|
1613
|
+
format?: string | undefined;
|
|
1614
|
+
lang?: string | undefined;
|
|
1615
|
+
rate?: number | undefined;
|
|
1604
1616
|
}, {
|
|
1605
1617
|
text: string;
|
|
1606
1618
|
voice: string;
|
|
@@ -1617,6 +1629,9 @@ declare const ttsInputSchema: z.ZodObject<{
|
|
|
1617
1629
|
transport: "http" | "subprocess";
|
|
1618
1630
|
})[] | undefined;
|
|
1619
1631
|
labels?: Record<string, string> | undefined;
|
|
1632
|
+
format?: string | undefined;
|
|
1633
|
+
lang?: string | undefined;
|
|
1634
|
+
rate?: number | undefined;
|
|
1620
1635
|
}>;
|
|
1621
1636
|
declare const aiConfigSchema: z.ZodObject<{
|
|
1622
1637
|
defaults: z.ZodOptional<z.ZodRecord<z.ZodEnum<["fast", "smart", "powerful", "cheap", "vision", "video", "embedding"]>, z.ZodObject<{
|
|
@@ -1815,6 +1830,41 @@ declare function elevenlabsAdapter(config?: {
|
|
|
1815
1830
|
listVoices(): Promise<ElevenLabsVoice[]>;
|
|
1816
1831
|
};
|
|
1817
1832
|
|
|
1833
|
+
/** A curated Danish-speaking Azure voice, exposed so a consuming app can render a
|
|
1834
|
+
* picker. `native` = a true da-DK voice (most natural); otherwise a multilingual
|
|
1835
|
+
* voice that also speaks Danish (Azure has only 2 native da-DK voices). */
|
|
1836
|
+
interface AzureVoiceInfo {
|
|
1837
|
+
/** Friendly name a caller passes as `voice` (e.g. "christel"). */
|
|
1838
|
+
name: string;
|
|
1839
|
+
/** Full Azure voice name (e.g. "da-DK-ChristelNeural"). */
|
|
1840
|
+
voiceId: string;
|
|
1841
|
+
gender: "female" | "male";
|
|
1842
|
+
/** Display label for a UI picker. */
|
|
1843
|
+
display: string;
|
|
1844
|
+
/** True for the 2 native da-DK voices; false for multilingual voices speaking Danish. */
|
|
1845
|
+
native: boolean;
|
|
1846
|
+
/** Per-voice default speaking rate, applied when a call passes no explicit `rate`
|
|
1847
|
+
* (e.g. Christel reads a touch fast, so her natural default is 0.85). Omitted = 1 (normal). */
|
|
1848
|
+
defaultRate?: number;
|
|
1849
|
+
}
|
|
1850
|
+
/** Curated da-DK roster (F026) — 2 native + 4 multilingual, 3 of each gender.
|
|
1851
|
+
* Verified against Azure's voices/list (only Christel + Jeppe are native da-DK). */
|
|
1852
|
+
declare const AZURE_DANISH_VOICE_LIST: AzureVoiceInfo[];
|
|
1853
|
+
/** Friendly name → full Azure voice name. Distinct from ELEVENLABS_DANISH_VOICES so
|
|
1854
|
+
* the client's resolveVoice passes these through unchanged to this adapter. */
|
|
1855
|
+
declare const AZURE_DANISH_VOICES: Record<string, string>;
|
|
1856
|
+
/** The curated Danish voice roster, for a consuming app to present in a picker. */
|
|
1857
|
+
declare function listAzureDanishVoices(): AzureVoiceInfo[];
|
|
1858
|
+
/** Resolve a curated friendly name to its full Azure voice; pass a full voice name
|
|
1859
|
+
* (e.g. "da-DK-ChristelNeural") through unchanged. */
|
|
1860
|
+
declare function resolveAzureVoice(nameOrVoice: string): string;
|
|
1861
|
+
declare function azureAdapter(config?: {
|
|
1862
|
+
apiKey?: string;
|
|
1863
|
+
region?: string;
|
|
1864
|
+
fetch?: typeof fetch;
|
|
1865
|
+
pricePer1kChars?: number;
|
|
1866
|
+
}): ProviderAdapter;
|
|
1867
|
+
|
|
1818
1868
|
interface FalAdapterConfig {
|
|
1819
1869
|
apiKey?: string;
|
|
1820
1870
|
/** "sync" (default — fal.run, fast models) or "queue" (queue.fal.run, polled). */
|
|
@@ -1895,8 +1945,8 @@ declare const falStubAdapter: ProviderAdapter;
|
|
|
1895
1945
|
* wires the live adapters. */
|
|
1896
1946
|
declare const stubProviders: Record<string, ProviderAdapter>;
|
|
1897
1947
|
|
|
1898
|
-
declare const VERSION: "0.
|
|
1899
|
-
declare const SDK_TAG: "@broberg/ai-sdk@0.
|
|
1948
|
+
declare const VERSION: "0.19.0";
|
|
1949
|
+
declare const SDK_TAG: "@broberg/ai-sdk@0.19.0";
|
|
1900
1950
|
|
|
1901
1951
|
/** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
|
|
1902
1952
|
* per-call override. Model IDs are current at scaffold time; callers pin their
|
|
@@ -2047,6 +2097,103 @@ interface CostSummary {
|
|
|
2047
2097
|
* DB has never been written to, so an empty DB summarises cleanly to 0. */
|
|
2048
2098
|
declare function getCostSummary(dbPath: string): Promise<CostSummary>;
|
|
2049
2099
|
|
|
2100
|
+
/** Thrown when the cost read-API rejects (e.g. 401 invalid_api_key) or is unreachable. */
|
|
2101
|
+
declare class UpmetricsCostError extends Error {
|
|
2102
|
+
readonly status?: number;
|
|
2103
|
+
readonly code?: string;
|
|
2104
|
+
constructor(message: string, opts?: {
|
|
2105
|
+
status?: number;
|
|
2106
|
+
code?: string;
|
|
2107
|
+
});
|
|
2108
|
+
}
|
|
2109
|
+
interface UpmetricsCostClientConfig {
|
|
2110
|
+
/** Read-API base URL, e.g. https://upmetrics.org */
|
|
2111
|
+
baseUrl: string;
|
|
2112
|
+
/** Per-project api_key (uk_…) — sent as X-Upmetrics-Key; resolves to your own project only. */
|
|
2113
|
+
apiKey: string;
|
|
2114
|
+
/** Injectable fetch for testing; defaults to global fetch. */
|
|
2115
|
+
fetch?: typeof fetch;
|
|
2116
|
+
}
|
|
2117
|
+
/** Shared filter surface for summary + timeseries (mirrors COST-API.md query params). */
|
|
2118
|
+
interface CostQuery {
|
|
2119
|
+
/** Relative window; ignored when from/to are given. */
|
|
2120
|
+
window?: "day" | "week" | "month";
|
|
2121
|
+
/** Explicit window start (ISO-8601 or epoch-ms) — overrides `window`. */
|
|
2122
|
+
from?: string | number;
|
|
2123
|
+
/** Explicit window end (ISO-8601 or epoch-ms) — overrides `window`. */
|
|
2124
|
+
to?: string | number;
|
|
2125
|
+
provider?: string;
|
|
2126
|
+
model?: string;
|
|
2127
|
+
tier?: string;
|
|
2128
|
+
/** Filter to one consumer (the sink's agent_name). */
|
|
2129
|
+
agentName?: string;
|
|
2130
|
+
transport?: "http" | "subprocess";
|
|
2131
|
+
/** Tag filters → `tag.<key>=<value>` (e.g. { tenantId: "sanne" }). */
|
|
2132
|
+
tags?: Record<string, string>;
|
|
2133
|
+
}
|
|
2134
|
+
interface CostSummaryQuery extends CostQuery {
|
|
2135
|
+
/** Break the total down per distinct value of this tag key (the per-tenant view). */
|
|
2136
|
+
groupBy?: string;
|
|
2137
|
+
}
|
|
2138
|
+
interface CostTimeseriesQuery extends CostQuery {
|
|
2139
|
+
/** Bucket granularity (default "day"). */
|
|
2140
|
+
bucket?: "day" | "hour";
|
|
2141
|
+
}
|
|
2142
|
+
/** One breakdown row, ordered by cost desc. `tier`/`capability` fall back to "(none)". */
|
|
2143
|
+
interface UpmetricsCostRow {
|
|
2144
|
+
key: string;
|
|
2145
|
+
micro_usd: number;
|
|
2146
|
+
input_tokens: number;
|
|
2147
|
+
output_tokens: number;
|
|
2148
|
+
run_count: number;
|
|
2149
|
+
}
|
|
2150
|
+
interface UpmetricsCostSummary {
|
|
2151
|
+
generated_at: string;
|
|
2152
|
+
window: {
|
|
2153
|
+
from: string;
|
|
2154
|
+
to: string;
|
|
2155
|
+
};
|
|
2156
|
+
total_micro_usd: number;
|
|
2157
|
+
input_tokens: number;
|
|
2158
|
+
output_tokens: number;
|
|
2159
|
+
cache_read_tokens: number;
|
|
2160
|
+
cache_creation_tokens: number;
|
|
2161
|
+
run_count: number;
|
|
2162
|
+
metered: {
|
|
2163
|
+
metered_micro_usd: number;
|
|
2164
|
+
free_run_count: number;
|
|
2165
|
+
};
|
|
2166
|
+
by_provider: UpmetricsCostRow[];
|
|
2167
|
+
by_model: UpmetricsCostRow[];
|
|
2168
|
+
by_tier: UpmetricsCostRow[];
|
|
2169
|
+
by_capability: UpmetricsCostRow[];
|
|
2170
|
+
/** Present only when `groupBy` was requested. */
|
|
2171
|
+
group_by?: string;
|
|
2172
|
+
by_group?: UpmetricsCostRow[];
|
|
2173
|
+
}
|
|
2174
|
+
interface UpmetricsCostTimeseries {
|
|
2175
|
+
generated_at: string;
|
|
2176
|
+
bucket: "day" | "hour";
|
|
2177
|
+
window: {
|
|
2178
|
+
from: string;
|
|
2179
|
+
to: string;
|
|
2180
|
+
};
|
|
2181
|
+
/** Only non-zero buckets are returned — pad missing buckets yourself. */
|
|
2182
|
+
points: Array<{
|
|
2183
|
+
ts: string;
|
|
2184
|
+
micro_usd: number;
|
|
2185
|
+
input_tokens: number;
|
|
2186
|
+
output_tokens: number;
|
|
2187
|
+
run_count: number;
|
|
2188
|
+
}>;
|
|
2189
|
+
}
|
|
2190
|
+
/** Convert integer micro-USD to a USD float for display. `$1 = 1_000_000`. */
|
|
2191
|
+
declare const usdFromMicro: (microUsd: number) => number;
|
|
2192
|
+
declare function upmetricsCostClient(config: UpmetricsCostClientConfig): {
|
|
2193
|
+
summary(query?: CostSummaryQuery): Promise<UpmetricsCostSummary>;
|
|
2194
|
+
timeseries(query?: CostTimeseriesQuery): Promise<UpmetricsCostTimeseries>;
|
|
2195
|
+
};
|
|
2196
|
+
|
|
2050
2197
|
interface PricingEntry {
|
|
2051
2198
|
/** USD per 1M input tokens. */
|
|
2052
2199
|
inputPer1M: number;
|
|
@@ -2122,4 +2269,4 @@ interface StreamTransportRequest extends TransportRequest {
|
|
|
2122
2269
|
*/
|
|
2123
2270
|
declare function streamTransport(req: StreamTransportRequest): AsyncIterable<string>;
|
|
2124
2271
|
|
|
2125
|
-
export { type AiClient, type AiConfig, 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 CostSink, type CostSummary, 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 UpmetricsSinkConfig, type Usage, VERSION, type VideoInput, type VisionInput, aiConfigSchema, anthropicAdapter, anthropicApiAdapter, anthropicSubprocessAdapter, bflAdapter, bflCredits, chatInputSchema, computeCost, createAI, deepinfraAdapter, defaultProviders, discordSink, elevenlabsAdapter, embeddingInputSchema, falAdapter, falStubAdapter, freshUsage, fromProviderToolCall, geminiAdapter, getCostSummary, getPrice, httpTransport, imageInputSchema, makeContracts, makeOpenAICompatibleAdapter, messageSchema, mistralAdapter, multiSink, noopSink, openaiAdapter, openaiStubAdapter, openrouterAdapter, parseClaudeCliJson, parseJsonLoose, refreshAvailability, resetRefreshState, resetRegistry, resolveTier, resolveVoice, sqliteBudgetStore, sqliteSink, streamTransport, stubProviders, subprocessTransport, tierSpecSchema, toProviderTools, toolSchema, translateInputSchema, upmetricsSink, visionInputSchema };
|
|
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 };
|