@broberg/ai-sdk 0.69.4 → 0.70.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/{chunk-NDLYPW3M.js → chunk-4YQVYVTA.js} +3 -1
- package/dist/chunk-4YQVYVTA.js.map +1 -0
- package/dist/index.d.ts +58 -5
- package/dist/index.js +104 -7
- package/dist/index.js.map +1 -1
- package/dist/pricing.js +1 -1
- package/dist/{registry-rn-6k7Zt.d.ts → registry-CCKJyveA.d.ts} +16 -2
- package/dist/registry.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-NDLYPW3M.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CostSink, T as Tier, U as Usage, 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, 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-
|
|
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,
|
|
1
|
+
import { C as CostSink, T as Tier, U as Usage, 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-CCKJyveA.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-CCKJyveA.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
|
|
|
@@ -837,6 +837,49 @@ declare const moderationInputSchema: z.ZodObject<{
|
|
|
837
837
|
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
838
838
|
input: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
839
839
|
}, z.core.$strip>;
|
|
840
|
+
declare const vectorizeInputSchema: z.ZodObject<{
|
|
841
|
+
tier: z.ZodOptional<z.ZodEnum<{
|
|
842
|
+
vision: "vision";
|
|
843
|
+
video: "video";
|
|
844
|
+
embedding: "embedding";
|
|
845
|
+
fast: "fast";
|
|
846
|
+
smart: "smart";
|
|
847
|
+
powerful: "powerful";
|
|
848
|
+
cheap: "cheap";
|
|
849
|
+
}>>;
|
|
850
|
+
override: z.ZodOptional<z.ZodObject<{
|
|
851
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
852
|
+
model: z.ZodOptional<z.ZodString>;
|
|
853
|
+
transport: z.ZodOptional<z.ZodEnum<{
|
|
854
|
+
http: "http";
|
|
855
|
+
subprocess: "subprocess";
|
|
856
|
+
}>>;
|
|
857
|
+
}, z.core.$strip>>;
|
|
858
|
+
fallback: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
|
|
859
|
+
vision: "vision";
|
|
860
|
+
video: "video";
|
|
861
|
+
embedding: "embedding";
|
|
862
|
+
fast: "fast";
|
|
863
|
+
smart: "smart";
|
|
864
|
+
powerful: "powerful";
|
|
865
|
+
cheap: "cheap";
|
|
866
|
+
}>, z.ZodObject<{
|
|
867
|
+
provider: z.ZodString;
|
|
868
|
+
model: z.ZodString;
|
|
869
|
+
transport: z.ZodEnum<{
|
|
870
|
+
http: "http";
|
|
871
|
+
subprocess: "subprocess";
|
|
872
|
+
}>;
|
|
873
|
+
}, z.core.$strip>]>>>;
|
|
874
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
875
|
+
allowFloating: z.ZodOptional<z.ZodBoolean>;
|
|
876
|
+
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
877
|
+
image: z.ZodUnion<readonly [z.ZodString, z.ZodInstanceOf<Uint8Array<ArrayBuffer>>]>;
|
|
878
|
+
shapeStacking: z.ZodOptional<z.ZodEnum<{
|
|
879
|
+
hierarchical: "hierarchical";
|
|
880
|
+
cut_out: "cut_out";
|
|
881
|
+
}>>;
|
|
882
|
+
}, z.core.$strip>;
|
|
840
883
|
declare const judgeInputSchema: z.ZodObject<{
|
|
841
884
|
tier: z.ZodOptional<z.ZodEnum<{
|
|
842
885
|
vision: "vision";
|
|
@@ -1040,6 +1083,7 @@ type TranscribeInput = z.infer<typeof transcribeInputSchema>;
|
|
|
1040
1083
|
type OcrInput = z.infer<typeof ocrInputSchema>;
|
|
1041
1084
|
type ModerationInput = z.infer<typeof moderationInputSchema>;
|
|
1042
1085
|
type JudgeInput = z.infer<typeof judgeInputSchema>;
|
|
1086
|
+
type VectorizeInput = z.infer<typeof vectorizeInputSchema>;
|
|
1043
1087
|
type PodcastInput = z.infer<typeof podcastInputSchema>;
|
|
1044
1088
|
type TtsInput = z.infer<typeof ttsInputSchema>;
|
|
1045
1089
|
type AiConfig = z.infer<typeof aiConfigSchema>;
|
|
@@ -1076,6 +1120,8 @@ interface AiClient {
|
|
|
1076
1120
|
/** F078 — web search through ai-sdk; reports every call to this client's cost sink
|
|
1077
1121
|
* with the client's labels. Same request/result as the standalone `search()`. */
|
|
1078
1122
|
search(req: SearchRequest, opts?: Omit<SearchOptions, "costSink">): Promise<SearchResult>;
|
|
1123
|
+
/** F070 — raster image → SVG (Recraft). Returns the SVG text, already downloaded. */
|
|
1124
|
+
vectorize(input: VectorizeInput): Promise<VectorizeResult>;
|
|
1079
1125
|
/** Podcast (F020) — a finished manuscript → one multi-voice audio episode. ElevenLabs. */
|
|
1080
1126
|
podcast(input: PodcastInput): Promise<PodcastResult>;
|
|
1081
1127
|
/** Single-voice TTS (F020.4) — text → audio. `voice` = curated name or voiceId. ElevenLabs. */
|
|
@@ -1297,6 +1343,12 @@ declare function microsoftDecisionAdapter(config?: {
|
|
|
1297
1343
|
fetch?: typeof fetch;
|
|
1298
1344
|
}): ProviderAdapter;
|
|
1299
1345
|
|
|
1346
|
+
declare function recraftAdapter(config?: {
|
|
1347
|
+
apiKey?: string;
|
|
1348
|
+
baseUrl?: string;
|
|
1349
|
+
fetch?: typeof fetch;
|
|
1350
|
+
}): ProviderAdapter;
|
|
1351
|
+
|
|
1300
1352
|
interface FalAdapterConfig {
|
|
1301
1353
|
apiKey?: string;
|
|
1302
1354
|
/** "sync" (default — fal.run, fast models) or "queue" (queue.fal.run, polled). */
|
|
@@ -1447,8 +1499,8 @@ declare const falStubAdapter: ProviderAdapter;
|
|
|
1447
1499
|
* wires the live adapters. */
|
|
1448
1500
|
declare const stubProviders: Record<string, ProviderAdapter>;
|
|
1449
1501
|
|
|
1450
|
-
declare const VERSION: "0.
|
|
1451
|
-
declare const SDK_TAG: "@broberg/ai-sdk@0.
|
|
1502
|
+
declare const VERSION: "0.70.1";
|
|
1503
|
+
declare const SDK_TAG: "@broberg/ai-sdk@0.70.1";
|
|
1452
1504
|
|
|
1453
1505
|
/** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
|
|
1454
1506
|
* per-call override.
|
|
@@ -1883,6 +1935,7 @@ declare const DEFAULT_BASE_URLS: {
|
|
|
1883
1935
|
readonly openai: "https://api.openai.com/v1";
|
|
1884
1936
|
readonly openrouter: "https://openrouter.ai/api/v1";
|
|
1885
1937
|
readonly typesafe: "https://api.typesafe.ai/v1";
|
|
1938
|
+
readonly recraft: "https://external.api.recraft.ai/v1";
|
|
1886
1939
|
};
|
|
1887
1940
|
type FixedHostProvider = keyof typeof DEFAULT_BASE_URLS;
|
|
1888
1941
|
/** `bfl` is DELIBERATELY ABSENT. Its adapter hard-pins `https://api.eu.bfl.ai` in a local
|
|
@@ -2014,4 +2067,4 @@ declare function memorySearchCache(max?: number): SearchCache;
|
|
|
2014
2067
|
|
|
2015
2068
|
declare function search(req: SearchRequest, opts?: SearchOptions): Promise<SearchResult>;
|
|
2016
2069
|
|
|
2017
|
-
export { AZURE_DANISH_VOICES, AZURE_DANISH_VOICE_LIST, type AiClient, type AiConfig, type AzureVoiceInfo, BatchJob, BatchRequestItem, BatchResultItem, type BflAdapterConfig, type BflCredits, BudgetConfig, BudgetExceededError, BudgetGuard, BudgetStore, CONFIG_DERIVED_HOSTS, Capability, type ChatInput, ChatResult, ChatStreamEvent, type CheckVoiceOptions, type ClassifyInput, type ClassifyResult, type Contracts, type CostQuery, CostSink, type CostSummary, type CostSummaryQuery, type CostTimeseriesQuery, DEFAULT_BASE_URLS, DEFAULT_SEARCH_ROUTES, DEFAULT_TIER_MAP, type DesignInput, type DesignResult, type DiscordSinkConfig, ELEVENLABS_DANISH_VOICES, type EmbeddingInput, EmbeddingResult, type ExtractInput, type ExtractResult, type FalAdapterConfig, type FixedHostProvider, type HttpResponse, INPUT_LIMITS, type ImageInput, ImageResult, type JudgeInput, JudgeResult, LOCALLY_PINNED_HOSTS, MICROSOFT_DECISION_DEFAULT_DEPLOYMENT, type MockupInput, type MockupResult, type ModerationInput, ModerationResult, type OcrInput, OcrResult, type OpenAICompatibleConfig, type PodcastInput, PodcastResult, type PriceDriftResult, type PriceDriftRow, type PricingEntry, ProviderAdapter, type RefreshOptions, type RefreshResult, Region, type RerankInput, type RerankResult, type RouteForecast, SDK_TAG, SEARCH_CACHE_TTL_MS, SEARCH_PRICE_USD, SearchBudgetExceededError, type SearchCache, type SearchCapStore, type SearchCredentials, type SearchItem, SearchKeyMissingError, type SearchOptions, type SearchProviderId, type SearchPurpose, type SearchRequest, type SearchResult, type SearchRoute, type SqliteBudgetStoreConfig, type SqliteSinkConfig, StreamHttpError, type SubprocessResponse, Tier, TierSpec, Tool, ToolCall, type TrainStyleInput, TrainStyleResult, type TranscribeInput, TranscribeResult, type TranslateInput, TranslateResult, Transport, type TransportRequest, type TransportResponse, type TtsInput, type UpmetricsCostClientConfig, UpmetricsCostError, type UpmetricsCostRow, type UpmetricsCostSummary, type UpmetricsCostTimeseries, type UpmetricsSink, type UpmetricsSinkConfig, type UpmetricsSinkStats, Usage, VERSION, type VideoInput, type VisionInput, type VoiceInfo, type VoiceProvider, type VoiceResolveResult, type VoiceStatus, VoiceUnavailableError, type WebSearchContext, type WebSearchToolResult, ZDR_PROVIDERS, aiConfigSchema, anthropicAdapter, anthropicApiAdapter, anthropicSubprocessAdapter, azureAdapter, bflAdapter, bflCredits, byokAdapter, chatInputSchema, checkPriceDrift, checkVoice, computeCost, createAI, deepinfraAdapter, deeplAdapter, deepseekAdapter, defaultBaseUrl, defaultProviders, discordSink, elevenlabsAdapter, embeddingInputSchema, falAdapter, falStubAdapter, freshUsage, fromProviderToolCall, geminiAdapter, getCostSummary, getPrice, httpTransport, imageInputSchema, isByokKeyed, listAzureDanishVoices, listVoices, makeContracts, makeOpenAICompatibleAdapter, matchLabel, memorySearchCache, messageSchema, microsoftDecisionAdapter, mistralAdapter, mistralStubAdapter, multiSink, noopSink, openaiAdapter, openaiStubAdapter, openrouterAdapter, parseClaudeCliJson, parseJsonLoose, refreshAvailability, requestyAdapter, resetRefreshState, resetRegistry, resolveAzureVoice, resolveTier, resolveVoice, routeSearch, runWebSearch, search, sqliteBudgetStore, sqliteSink, streamTransport, stubProviders, subprocessTransport, tierSpecSchema, toProviderTools, toolSchema, translateInputSchema, typesafeAdapter, upmetricsCostClient, upmetricsSink, usdFromMicro, vertexAdapter, visionInputSchema, webSearchTool, wouldProviderRouteTo, wouldRouteTo };
|
|
2070
|
+
export { AZURE_DANISH_VOICES, AZURE_DANISH_VOICE_LIST, type AiClient, type AiConfig, type AzureVoiceInfo, BatchJob, BatchRequestItem, BatchResultItem, type BflAdapterConfig, type BflCredits, BudgetConfig, BudgetExceededError, BudgetGuard, BudgetStore, CONFIG_DERIVED_HOSTS, Capability, type ChatInput, ChatResult, ChatStreamEvent, type CheckVoiceOptions, type ClassifyInput, type ClassifyResult, type Contracts, type CostQuery, CostSink, type CostSummary, type CostSummaryQuery, type CostTimeseriesQuery, DEFAULT_BASE_URLS, DEFAULT_SEARCH_ROUTES, DEFAULT_TIER_MAP, type DesignInput, type DesignResult, type DiscordSinkConfig, ELEVENLABS_DANISH_VOICES, type EmbeddingInput, EmbeddingResult, type ExtractInput, type ExtractResult, type FalAdapterConfig, type FixedHostProvider, type HttpResponse, INPUT_LIMITS, type ImageInput, ImageResult, type JudgeInput, JudgeResult, LOCALLY_PINNED_HOSTS, MICROSOFT_DECISION_DEFAULT_DEPLOYMENT, type MockupInput, type MockupResult, type ModerationInput, ModerationResult, type OcrInput, OcrResult, type OpenAICompatibleConfig, type PodcastInput, PodcastResult, type PriceDriftResult, type PriceDriftRow, type PricingEntry, ProviderAdapter, type RefreshOptions, type RefreshResult, Region, type RerankInput, type RerankResult, type RouteForecast, SDK_TAG, SEARCH_CACHE_TTL_MS, SEARCH_PRICE_USD, SearchBudgetExceededError, type SearchCache, type SearchCapStore, type SearchCredentials, type SearchItem, SearchKeyMissingError, type SearchOptions, type SearchProviderId, type SearchPurpose, type SearchRequest, type SearchResult, type SearchRoute, type SqliteBudgetStoreConfig, type SqliteSinkConfig, StreamHttpError, type SubprocessResponse, Tier, TierSpec, Tool, ToolCall, type TrainStyleInput, TrainStyleResult, type TranscribeInput, TranscribeResult, type TranslateInput, TranslateResult, Transport, type TransportRequest, type TransportResponse, type TtsInput, type UpmetricsCostClientConfig, UpmetricsCostError, type UpmetricsCostRow, type UpmetricsCostSummary, type UpmetricsCostTimeseries, type UpmetricsSink, type UpmetricsSinkConfig, type UpmetricsSinkStats, Usage, VERSION, type VideoInput, type VisionInput, type VoiceInfo, type VoiceProvider, type VoiceResolveResult, type VoiceStatus, VoiceUnavailableError, type WebSearchContext, type WebSearchToolResult, ZDR_PROVIDERS, aiConfigSchema, anthropicAdapter, anthropicApiAdapter, anthropicSubprocessAdapter, azureAdapter, bflAdapter, bflCredits, byokAdapter, chatInputSchema, checkPriceDrift, checkVoice, computeCost, createAI, deepinfraAdapter, deeplAdapter, deepseekAdapter, defaultBaseUrl, defaultProviders, discordSink, elevenlabsAdapter, embeddingInputSchema, falAdapter, falStubAdapter, freshUsage, fromProviderToolCall, geminiAdapter, getCostSummary, getPrice, httpTransport, imageInputSchema, isByokKeyed, listAzureDanishVoices, listVoices, makeContracts, makeOpenAICompatibleAdapter, matchLabel, memorySearchCache, messageSchema, microsoftDecisionAdapter, mistralAdapter, mistralStubAdapter, multiSink, noopSink, openaiAdapter, openaiStubAdapter, openrouterAdapter, parseClaudeCliJson, parseJsonLoose, recraftAdapter, refreshAvailability, requestyAdapter, resetRefreshState, resetRegistry, resolveAzureVoice, resolveTier, resolveVoice, routeSearch, runWebSearch, search, sqliteBudgetStore, sqliteSink, streamTransport, stubProviders, subprocessTransport, tierSpecSchema, toProviderTools, toolSchema, translateInputSchema, typesafeAdapter, upmetricsCostClient, upmetricsSink, usdFromMicro, vertexAdapter, visionInputSchema, webSearchTool, wouldProviderRouteTo, wouldRouteTo };
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
listMediaPrices,
|
|
24
24
|
pricingFreshness,
|
|
25
25
|
pricingGeneratedAt
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-4YQVYVTA.js";
|
|
27
27
|
import {
|
|
28
28
|
PRICING,
|
|
29
29
|
getPrice
|
|
@@ -410,7 +410,9 @@ var DEFAULT_BASE_URLS = {
|
|
|
410
410
|
openai: "https://api.openai.com/v1",
|
|
411
411
|
openrouter: "https://openrouter.ai/api/v1",
|
|
412
412
|
// F066. US-hosted per the TypeSafe privacy policy — see region.ts.
|
|
413
|
-
typesafe: "https://api.typesafe.ai/v1"
|
|
413
|
+
typesafe: "https://api.typesafe.ai/v1",
|
|
414
|
+
// F070 — Recraft (vectorize). Residency not stated where we looked — see region.ts.
|
|
415
|
+
recraft: "https://external.api.recraft.ai/v1"
|
|
414
416
|
};
|
|
415
417
|
var LOCALLY_PINNED_HOSTS = {
|
|
416
418
|
bfl: "https://api.eu.bfl.ai"
|
|
@@ -655,6 +657,9 @@ var HOST_REGION = {
|
|
|
655
657
|
// COPENHAGEN edge (cf-ray …-CPH). That is where the TLS terminated, not where the data
|
|
656
658
|
// is processed — a host behind a CDN cannot have its residency read off the edge.
|
|
657
659
|
"api.typesafe.ai": "us",
|
|
660
|
+
// F070 — Recraft. We have not found where it processes data (read 2026-10-07), so
|
|
661
|
+
// "unknown": only "eu" is a residency claim, and we will not invent one.
|
|
662
|
+
"external.api.recraft.ai": "unknown",
|
|
658
663
|
// Aggregators: the host is theirs, the upstream is not ours to know.
|
|
659
664
|
"openrouter.ai": "unknown",
|
|
660
665
|
"router.requesty.ai": "unknown"
|
|
@@ -3449,6 +3454,52 @@ function bflAdapter(config = {}) {
|
|
|
3449
3454
|
return { name: "bfl", image, animate };
|
|
3450
3455
|
}
|
|
3451
3456
|
|
|
3457
|
+
// src/providers/recraft.ts
|
|
3458
|
+
function recraftAdapter(config = {}) {
|
|
3459
|
+
const fetchImpl = config.fetch ?? fetch;
|
|
3460
|
+
const baseUrl = config.baseUrl ?? DEFAULT_BASE_URLS.recraft;
|
|
3461
|
+
function key() {
|
|
3462
|
+
const k = config.apiKey ?? process.env.RECRAFT_API_TOKEN;
|
|
3463
|
+
if (!k) throw new Error("recraft adapter: API token not set (env RECRAFT_API_TOKEN)");
|
|
3464
|
+
return k;
|
|
3465
|
+
}
|
|
3466
|
+
async function vectorize(req) {
|
|
3467
|
+
const token = key();
|
|
3468
|
+
const imageUrl = typeof req.image === "string" && /^https?:\/\//i.test(req.image) ? req.image : await toInlineImage(req.image, fetchImpl).then(({ data: data2, mimeType }) => `data:${mimeType};base64,${data2}`);
|
|
3469
|
+
const body = { image_url: imageUrl };
|
|
3470
|
+
if (req.shapeStacking) body.shape_stacking = req.shapeStacking;
|
|
3471
|
+
const res = await fetchImpl(`${baseUrl}/images/vectorize`, {
|
|
3472
|
+
method: "POST",
|
|
3473
|
+
headers: { "content-type": "application/json", authorization: `Bearer ${token}` },
|
|
3474
|
+
body: JSON.stringify(body)
|
|
3475
|
+
});
|
|
3476
|
+
if (!res.ok) {
|
|
3477
|
+
const errBody = await res.text().catch(() => "");
|
|
3478
|
+
throw new Error(`recraft vectorize ${res.status}: ${errBody.slice(0, 300)}`);
|
|
3479
|
+
}
|
|
3480
|
+
const data = await res.json();
|
|
3481
|
+
const url = data.image?.url;
|
|
3482
|
+
if (!url) throw new Error("recraft vectorize: response contained no image url");
|
|
3483
|
+
const svgRes = await fetchImpl(url);
|
|
3484
|
+
if (!svgRes.ok) throw new Error(`recraft vectorize: could not download the SVG (${svgRes.status})`);
|
|
3485
|
+
const svg = await svgRes.text();
|
|
3486
|
+
if (!svg.includes("<svg")) throw new Error("recraft vectorize: downloaded file is not an SVG");
|
|
3487
|
+
const usage = freshUsage({
|
|
3488
|
+
provider: "recraft",
|
|
3489
|
+
region: regionOfHost(baseUrl),
|
|
3490
|
+
model: req.spec.model,
|
|
3491
|
+
transport: "http",
|
|
3492
|
+
capability: "vectorize",
|
|
3493
|
+
inputTokens: 0,
|
|
3494
|
+
outputTokens: 0
|
|
3495
|
+
});
|
|
3496
|
+
usage.costUsd = getMediaPrice("recraft", "vectorize")?.usd ?? 0;
|
|
3497
|
+
usage.costBasis = "estimated";
|
|
3498
|
+
return { svg, usage };
|
|
3499
|
+
}
|
|
3500
|
+
return { name: "recraft", vectorize };
|
|
3501
|
+
}
|
|
3502
|
+
|
|
3452
3503
|
// src/providers/registry.ts
|
|
3453
3504
|
var defaultProviders = {
|
|
3454
3505
|
anthropic: anthropicAdapter(),
|
|
@@ -3466,7 +3517,8 @@ var defaultProviders = {
|
|
|
3466
3517
|
typesafe: typesafeAdapter(),
|
|
3467
3518
|
"microsoft-decision": microsoftDecisionAdapter(),
|
|
3468
3519
|
fal: falAdapter(),
|
|
3469
|
-
bfl: bflAdapter()
|
|
3520
|
+
bfl: bflAdapter(),
|
|
3521
|
+
recraft: recraftAdapter()
|
|
3470
3522
|
};
|
|
3471
3523
|
|
|
3472
3524
|
// src/cost/budget.ts
|
|
@@ -4119,6 +4171,11 @@ var judgeQuestionSchema = z.discriminatedUnion("type", [
|
|
|
4119
4171
|
criteria: z.array(judgeEntrySchema).min(2).max(10)
|
|
4120
4172
|
})
|
|
4121
4173
|
]);
|
|
4174
|
+
var vectorizeInputSchema = z.object({
|
|
4175
|
+
image: z.union([z.string().min(1), z.instanceof(Uint8Array)]),
|
|
4176
|
+
shapeStacking: z.enum(["hierarchical", "cut_out"]).optional(),
|
|
4177
|
+
...callOptions
|
|
4178
|
+
});
|
|
4122
4179
|
var judgeInputSchema = z.object({
|
|
4123
4180
|
state: z.union([z.string().min(1), z.array(z.string()).max(L.stateItems), z.record(z.string(), z.unknown())]),
|
|
4124
4181
|
questions: z.record(z.string(), judgeQuestionSchema).refine((q) => Object.keys(q).length > 0, {
|
|
@@ -4207,8 +4264,8 @@ var aiConfigSchema = z.object({
|
|
|
4207
4264
|
import { randomUUID } from "crypto";
|
|
4208
4265
|
|
|
4209
4266
|
// src/version.ts
|
|
4210
|
-
var VERSION = "0.
|
|
4211
|
-
var SDK_TAG = "@broberg/ai-sdk@0.
|
|
4267
|
+
var VERSION = "0.70.1";
|
|
4268
|
+
var SDK_TAG = "@broberg/ai-sdk@0.70.1";
|
|
4212
4269
|
|
|
4213
4270
|
// src/cost/sinks/upmetrics.ts
|
|
4214
4271
|
function isRetryableStatus(status) {
|
|
@@ -4542,8 +4599,18 @@ function judgeSpecFromEnv() {
|
|
|
4542
4599
|
if (!spec) throw new Error(`createAI: AI_JUDGE_PROVIDER="${v}" is not a judge route \u2014 use ${Object.keys(JUDGE_SPECS).join(" or ")}`);
|
|
4543
4600
|
return spec;
|
|
4544
4601
|
}
|
|
4602
|
+
var DEFAULT_VECTORIZE_SPEC = { provider: "recraft", model: "vectorize", transport: "http" };
|
|
4545
4603
|
var DEFAULT_PODCAST_SPEC = { provider: "elevenlabs", model: "eleven_v3", transport: "http" };
|
|
4546
4604
|
var DEFAULT_TTS_SPEC = { provider: "elevenlabs", model: "eleven_multilingual_v2", transport: "http" };
|
|
4605
|
+
var TTS_MODEL_BY_PROVIDER = {
|
|
4606
|
+
elevenlabs: DEFAULT_TTS_SPEC.model,
|
|
4607
|
+
azure: "neural",
|
|
4608
|
+
mistral: MISTRAL_TTS_DEFAULT_MODEL
|
|
4609
|
+
};
|
|
4610
|
+
var TRANSCRIBE_MODEL_BY_PROVIDER = {
|
|
4611
|
+
openai: DEFAULT_TRANSCRIBE_SPEC.model,
|
|
4612
|
+
azure: "fast-transcription"
|
|
4613
|
+
};
|
|
4547
4614
|
var DEFAULT_BATCH_SPEC = { provider: "mistral", model: "mistral-small-2603", transport: "http" };
|
|
4548
4615
|
var ROUTED_SPECS = [
|
|
4549
4616
|
DEFAULT_IMAGE_SPEC,
|
|
@@ -4556,6 +4623,7 @@ var ROUTED_SPECS = [
|
|
|
4556
4623
|
DEFAULT_MODERATION_SPEC,
|
|
4557
4624
|
DEFAULT_JUDGE_SPEC,
|
|
4558
4625
|
EU_JUDGE_SPEC,
|
|
4626
|
+
DEFAULT_VECTORIZE_SPEC,
|
|
4559
4627
|
DEFAULT_PODCAST_SPEC,
|
|
4560
4628
|
DEFAULT_TTS_SPEC,
|
|
4561
4629
|
DEFAULT_BATCH_SPEC,
|
|
@@ -4602,6 +4670,17 @@ function createAI(config = {}) {
|
|
|
4602
4670
|
void why;
|
|
4603
4671
|
return { ...base, ...override };
|
|
4604
4672
|
}
|
|
4673
|
+
function voiceRoute(base, override, defaults, label) {
|
|
4674
|
+
const spec = mergeUnguarded(base, override, "routes by voice, not by model \u2014 the adapter never sends spec.model");
|
|
4675
|
+
if (!override?.provider || override.provider === base.provider || override.model) return spec;
|
|
4676
|
+
const model = defaults[override.provider];
|
|
4677
|
+
if (!model) {
|
|
4678
|
+
throw new Error(
|
|
4679
|
+
`${label}: override:{provider:"${override.provider}"} needs a model \u2014 pass override:{ provider:"${override.provider}", model:"\u2026" }.`
|
|
4680
|
+
);
|
|
4681
|
+
}
|
|
4682
|
+
return { ...spec, model };
|
|
4683
|
+
}
|
|
4605
4684
|
function pickProvider(name) {
|
|
4606
4685
|
const adapter = Object.hasOwn(providers, name) ? providers[name] : void 0;
|
|
4607
4686
|
if (!adapter) {
|
|
@@ -5053,6 +5132,23 @@ function createAI(config = {}) {
|
|
|
5053
5132
|
}
|
|
5054
5133
|
});
|
|
5055
5134
|
},
|
|
5135
|
+
async vectorize(input) {
|
|
5136
|
+
input = vectorizeInputSchema.parse(input);
|
|
5137
|
+
return runCapability({
|
|
5138
|
+
primary: withOverride(DEFAULT_VECTORIZE_SPEC, input.override, "vectorize"),
|
|
5139
|
+
fallback: input.fallback,
|
|
5140
|
+
capability: "vectorize",
|
|
5141
|
+
purpose: input.purpose,
|
|
5142
|
+
labels: input.labels,
|
|
5143
|
+
estIn: 0,
|
|
5144
|
+
estOut: 0,
|
|
5145
|
+
invoke: async (spec) => {
|
|
5146
|
+
const adapter = pickProvider(spec.provider);
|
|
5147
|
+
if (!adapter.vectorize) throw new Error(`createAI: provider "${spec.provider}" does not support vectorize`);
|
|
5148
|
+
return adapter.vectorize({ image: input.image, shapeStacking: input.shapeStacking, spec });
|
|
5149
|
+
}
|
|
5150
|
+
});
|
|
5151
|
+
},
|
|
5056
5152
|
async podcast(input) {
|
|
5057
5153
|
input = podcastInputSchema.parse(input);
|
|
5058
5154
|
const inputs = input.script.map((turn) => {
|
|
@@ -5084,7 +5180,7 @@ function createAI(config = {}) {
|
|
|
5084
5180
|
input = ttsInputSchema.parse(input);
|
|
5085
5181
|
const { voiceId } = checkVoice(input.voice, { fallback: input.voiceFallback, throwIfUnavailable: true });
|
|
5086
5182
|
return runCapability({
|
|
5087
|
-
primary:
|
|
5183
|
+
primary: voiceRoute(DEFAULT_TTS_SPEC, input.override, TTS_MODEL_BY_PROVIDER, "tts"),
|
|
5088
5184
|
fallback: input.fallback,
|
|
5089
5185
|
capability: "tts",
|
|
5090
5186
|
purpose: input.purpose,
|
|
@@ -5134,7 +5230,7 @@ function createAI(config = {}) {
|
|
|
5134
5230
|
input = transcribeInputSchema.parse(input);
|
|
5135
5231
|
const audio = await resolveAudio(input.audio);
|
|
5136
5232
|
return runCapability({
|
|
5137
|
-
primary:
|
|
5233
|
+
primary: voiceRoute(DEFAULT_TRANSCRIBE_SPEC, input.override, TRANSCRIBE_MODEL_BY_PROVIDER, "transcribe"),
|
|
5138
5234
|
fallback: input.fallback,
|
|
5139
5235
|
capability: "transcribe",
|
|
5140
5236
|
purpose: input.purpose,
|
|
@@ -5848,6 +5944,7 @@ export {
|
|
|
5848
5944
|
parseJsonLoose,
|
|
5849
5945
|
pricingFreshness,
|
|
5850
5946
|
pricingGeneratedAt,
|
|
5947
|
+
recraftAdapter,
|
|
5851
5948
|
refreshAvailability,
|
|
5852
5949
|
regionOfHost,
|
|
5853
5950
|
regionOfProvider,
|