@broberg/ai-sdk 0.45.0 → 0.45.1
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 +13 -4
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2385,8 +2385,17 @@ declare function azureAdapter(config?: {
|
|
|
2385
2385
|
sttPricePerMin?: number;
|
|
2386
2386
|
/** STT base URL override (e.g. a resource custom domain). */
|
|
2387
2387
|
sttBaseUrl?: string;
|
|
2388
|
-
/** Resource name → custom-domain
|
|
2389
|
-
* (or env AZURE_SPEECH_RESOURCE).
|
|
2388
|
+
/** Resource name → custom-domain host `{resource}.cognitiveservices.azure.com`
|
|
2389
|
+
* (or env AZURE_SPEECH_RESOURCE).
|
|
2390
|
+
*
|
|
2391
|
+
* **STT works without it** — the regional host is a legitimate route for
|
|
2392
|
+
* `speechtotext/transcriptions` and is the tested default (F029).
|
|
2393
|
+
*
|
|
2394
|
+
* **BATCH SYNTHESIS REQUIRES IT.** Every example in Microsoft's batch-synthesis
|
|
2395
|
+
* docs uses the resource host; the regional host is shown nowhere, and cms measured
|
|
2396
|
+
* it answering 401 with a valid key (F055.3). Without this set, `wordTimings` fails
|
|
2397
|
+
* before the call rather than spending your time on Azure's "invalid subscription
|
|
2398
|
+
* key or wrong API endpoint" — which names the key first and sends you the wrong way. */
|
|
2390
2399
|
resource?: string;
|
|
2391
2400
|
/** Fast-transcription api-version (overrides the GA default). */
|
|
2392
2401
|
sttApiVersion?: string;
|
|
@@ -2514,8 +2523,8 @@ declare const falStubAdapter: ProviderAdapter;
|
|
|
2514
2523
|
* wires the live adapters. */
|
|
2515
2524
|
declare const stubProviders: Record<string, ProviderAdapter>;
|
|
2516
2525
|
|
|
2517
|
-
declare const VERSION: "0.45.
|
|
2518
|
-
declare const SDK_TAG: "@broberg/ai-sdk@0.45.
|
|
2526
|
+
declare const VERSION: "0.45.1";
|
|
2527
|
+
declare const SDK_TAG: "@broberg/ai-sdk@0.45.1";
|
|
2519
2528
|
|
|
2520
2529
|
/** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
|
|
2521
2530
|
* per-call override.
|
package/dist/index.js
CHANGED
|
@@ -1836,11 +1836,14 @@ function azureAdapter(config = {}) {
|
|
|
1836
1836
|
}
|
|
1837
1837
|
return classifyRegionName(region());
|
|
1838
1838
|
}
|
|
1839
|
-
function
|
|
1840
|
-
if (config.sttBaseUrl) return config.sttBaseUrl.replace(/\/$/, "");
|
|
1839
|
+
function sttHost() {
|
|
1840
|
+
if (config.sttBaseUrl) return { url: config.sttBaseUrl.replace(/\/$/, ""), source: "explicit" };
|
|
1841
1841
|
const resource = config.resource ?? process.env.AZURE_SPEECH_RESOURCE;
|
|
1842
|
-
if (resource) return `https://${resource}.cognitiveservices.azure.com
|
|
1843
|
-
return `https://${region()}.api.cognitive.microsoft.com
|
|
1842
|
+
if (resource) return { url: `https://${resource}.cognitiveservices.azure.com`, source: "resource" };
|
|
1843
|
+
return { url: `https://${region()}.api.cognitive.microsoft.com`, source: "regional-fallback" };
|
|
1844
|
+
}
|
|
1845
|
+
function sttBaseUrl() {
|
|
1846
|
+
return sttHost().url;
|
|
1844
1847
|
}
|
|
1845
1848
|
function priceFor(chars, model) {
|
|
1846
1849
|
const usage = freshUsage({
|
|
@@ -1894,7 +1897,13 @@ function azureAdapter(config = {}) {
|
|
|
1894
1897
|
return { audio, mimeType: "audio/mpeg", usage: priceFor(req.text.length, req.spec.model) };
|
|
1895
1898
|
}
|
|
1896
1899
|
async function ttsBatch(req) {
|
|
1897
|
-
const
|
|
1900
|
+
const picked = sttHost();
|
|
1901
|
+
if (picked.source === "regional-fallback") {
|
|
1902
|
+
throw new Error(
|
|
1903
|
+
`azure batch synthesis (wordTimings) needs the resource's custom subdomain, not the regional host ${picked.url}. Set AZURE_SPEECH_RESOURCE (or config.resource) to your Speech resource name so the call goes to {resource}.cognitiveservices.azure.com, and make sure custom subdomain is enabled on that resource. Azure answers 401 here with a VALID key, and its message blames the key \u2014 measured by cms 11 September 2026.`
|
|
1904
|
+
);
|
|
1905
|
+
}
|
|
1906
|
+
const host = picked.url;
|
|
1898
1907
|
const api = "api-version=2024-04-01";
|
|
1899
1908
|
const id = `wt-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
1900
1909
|
const headers = { "Ocp-Apim-Subscription-Key": key(), "Content-Type": "application/json" };
|
|
@@ -3325,8 +3334,8 @@ var aiConfigSchema = z.object({
|
|
|
3325
3334
|
});
|
|
3326
3335
|
|
|
3327
3336
|
// src/version.ts
|
|
3328
|
-
var VERSION = "0.45.
|
|
3329
|
-
var SDK_TAG = "@broberg/ai-sdk@0.45.
|
|
3337
|
+
var VERSION = "0.45.1";
|
|
3338
|
+
var SDK_TAG = "@broberg/ai-sdk@0.45.1";
|
|
3330
3339
|
|
|
3331
3340
|
// src/cost/sinks/upmetrics.ts
|
|
3332
3341
|
function upmetricsSink(config) {
|