@broberg/ai-sdk 0.69.3 → 0.70.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-NDLYPW3M.js → chunk-4YQVYVTA.js} +3 -1
- package/dist/chunk-4YQVYVTA.js.map +1 -0
- package/dist/index.d.ts +60 -5
- package/dist/index.js +88 -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
|
|
|
@@ -441,6 +441,8 @@ declare const visionInputSchema: z.ZodObject<{
|
|
|
441
441
|
medium: "medium";
|
|
442
442
|
high: "high";
|
|
443
443
|
}>>;
|
|
444
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
445
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
444
446
|
}, z.core.$strip>;
|
|
445
447
|
declare const videoInputSchema: z.ZodObject<{
|
|
446
448
|
tier: z.ZodOptional<z.ZodEnum<{
|
|
@@ -835,6 +837,49 @@ declare const moderationInputSchema: z.ZodObject<{
|
|
|
835
837
|
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
836
838
|
input: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
837
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>;
|
|
838
883
|
declare const judgeInputSchema: z.ZodObject<{
|
|
839
884
|
tier: z.ZodOptional<z.ZodEnum<{
|
|
840
885
|
vision: "vision";
|
|
@@ -1038,6 +1083,7 @@ type TranscribeInput = z.infer<typeof transcribeInputSchema>;
|
|
|
1038
1083
|
type OcrInput = z.infer<typeof ocrInputSchema>;
|
|
1039
1084
|
type ModerationInput = z.infer<typeof moderationInputSchema>;
|
|
1040
1085
|
type JudgeInput = z.infer<typeof judgeInputSchema>;
|
|
1086
|
+
type VectorizeInput = z.infer<typeof vectorizeInputSchema>;
|
|
1041
1087
|
type PodcastInput = z.infer<typeof podcastInputSchema>;
|
|
1042
1088
|
type TtsInput = z.infer<typeof ttsInputSchema>;
|
|
1043
1089
|
type AiConfig = z.infer<typeof aiConfigSchema>;
|
|
@@ -1074,6 +1120,8 @@ interface AiClient {
|
|
|
1074
1120
|
/** F078 — web search through ai-sdk; reports every call to this client's cost sink
|
|
1075
1121
|
* with the client's labels. Same request/result as the standalone `search()`. */
|
|
1076
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>;
|
|
1077
1125
|
/** Podcast (F020) — a finished manuscript → one multi-voice audio episode. ElevenLabs. */
|
|
1078
1126
|
podcast(input: PodcastInput): Promise<PodcastResult>;
|
|
1079
1127
|
/** Single-voice TTS (F020.4) — text → audio. `voice` = curated name or voiceId. ElevenLabs. */
|
|
@@ -1295,6 +1343,12 @@ declare function microsoftDecisionAdapter(config?: {
|
|
|
1295
1343
|
fetch?: typeof fetch;
|
|
1296
1344
|
}): ProviderAdapter;
|
|
1297
1345
|
|
|
1346
|
+
declare function recraftAdapter(config?: {
|
|
1347
|
+
apiKey?: string;
|
|
1348
|
+
baseUrl?: string;
|
|
1349
|
+
fetch?: typeof fetch;
|
|
1350
|
+
}): ProviderAdapter;
|
|
1351
|
+
|
|
1298
1352
|
interface FalAdapterConfig {
|
|
1299
1353
|
apiKey?: string;
|
|
1300
1354
|
/** "sync" (default — fal.run, fast models) or "queue" (queue.fal.run, polled). */
|
|
@@ -1445,8 +1499,8 @@ declare const falStubAdapter: ProviderAdapter;
|
|
|
1445
1499
|
* wires the live adapters. */
|
|
1446
1500
|
declare const stubProviders: Record<string, ProviderAdapter>;
|
|
1447
1501
|
|
|
1448
|
-
declare const VERSION: "0.
|
|
1449
|
-
declare const SDK_TAG: "@broberg/ai-sdk@0.
|
|
1502
|
+
declare const VERSION: "0.70.0";
|
|
1503
|
+
declare const SDK_TAG: "@broberg/ai-sdk@0.70.0";
|
|
1450
1504
|
|
|
1451
1505
|
/** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
|
|
1452
1506
|
* per-call override.
|
|
@@ -1881,6 +1935,7 @@ declare const DEFAULT_BASE_URLS: {
|
|
|
1881
1935
|
readonly openai: "https://api.openai.com/v1";
|
|
1882
1936
|
readonly openrouter: "https://openrouter.ai/api/v1";
|
|
1883
1937
|
readonly typesafe: "https://api.typesafe.ai/v1";
|
|
1938
|
+
readonly recraft: "https://external.api.recraft.ai/v1";
|
|
1884
1939
|
};
|
|
1885
1940
|
type FixedHostProvider = keyof typeof DEFAULT_BASE_URLS;
|
|
1886
1941
|
/** `bfl` is DELIBERATELY ABSENT. Its adapter hard-pins `https://api.eu.bfl.ai` in a local
|
|
@@ -2012,4 +2067,4 @@ declare function memorySearchCache(max?: number): SearchCache;
|
|
|
2012
2067
|
|
|
2013
2068
|
declare function search(req: SearchRequest, opts?: SearchOptions): Promise<SearchResult>;
|
|
2014
2069
|
|
|
2015
|
-
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
|
|
@@ -3990,6 +4042,10 @@ var visionInputSchema = z.object({
|
|
|
3990
4042
|
system: z.string().optional(),
|
|
3991
4043
|
/** F085.5 — as on chat: Mistral reasoning effort (Large 4). Mistral only. */
|
|
3992
4044
|
reasoningEffort: z.enum(["none", "low", "medium", "high"]).optional(),
|
|
4045
|
+
/** F087 — as on chat. Without it the adapter's default applies: Anthropic stops at
|
|
4046
|
+
* 1024 output tokens (measured 2026-10-31: a vision SVG cut off mid-path). */
|
|
4047
|
+
maxTokens: z.number().int().positive().optional(),
|
|
4048
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
3993
4049
|
...callOptions
|
|
3994
4050
|
});
|
|
3995
4051
|
var videoInputSchema = z.object({
|
|
@@ -4115,6 +4171,11 @@ var judgeQuestionSchema = z.discriminatedUnion("type", [
|
|
|
4115
4171
|
criteria: z.array(judgeEntrySchema).min(2).max(10)
|
|
4116
4172
|
})
|
|
4117
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
|
+
});
|
|
4118
4179
|
var judgeInputSchema = z.object({
|
|
4119
4180
|
state: z.union([z.string().min(1), z.array(z.string()).max(L.stateItems), z.record(z.string(), z.unknown())]),
|
|
4120
4181
|
questions: z.record(z.string(), judgeQuestionSchema).refine((q) => Object.keys(q).length > 0, {
|
|
@@ -4203,8 +4264,8 @@ var aiConfigSchema = z.object({
|
|
|
4203
4264
|
import { randomUUID } from "crypto";
|
|
4204
4265
|
|
|
4205
4266
|
// src/version.ts
|
|
4206
|
-
var VERSION = "0.
|
|
4207
|
-
var SDK_TAG = "@broberg/ai-sdk@0.
|
|
4267
|
+
var VERSION = "0.70.0";
|
|
4268
|
+
var SDK_TAG = "@broberg/ai-sdk@0.70.0";
|
|
4208
4269
|
|
|
4209
4270
|
// src/cost/sinks/upmetrics.ts
|
|
4210
4271
|
function isRetryableStatus(status) {
|
|
@@ -4538,6 +4599,7 @@ function judgeSpecFromEnv() {
|
|
|
4538
4599
|
if (!spec) throw new Error(`createAI: AI_JUDGE_PROVIDER="${v}" is not a judge route \u2014 use ${Object.keys(JUDGE_SPECS).join(" or ")}`);
|
|
4539
4600
|
return spec;
|
|
4540
4601
|
}
|
|
4602
|
+
var DEFAULT_VECTORIZE_SPEC = { provider: "recraft", model: "vectorize", transport: "http" };
|
|
4541
4603
|
var DEFAULT_PODCAST_SPEC = { provider: "elevenlabs", model: "eleven_v3", transport: "http" };
|
|
4542
4604
|
var DEFAULT_TTS_SPEC = { provider: "elevenlabs", model: "eleven_multilingual_v2", transport: "http" };
|
|
4543
4605
|
var DEFAULT_BATCH_SPEC = { provider: "mistral", model: "mistral-small-2603", transport: "http" };
|
|
@@ -4552,6 +4614,7 @@ var ROUTED_SPECS = [
|
|
|
4552
4614
|
DEFAULT_MODERATION_SPEC,
|
|
4553
4615
|
DEFAULT_JUDGE_SPEC,
|
|
4554
4616
|
EU_JUDGE_SPEC,
|
|
4617
|
+
DEFAULT_VECTORIZE_SPEC,
|
|
4555
4618
|
DEFAULT_PODCAST_SPEC,
|
|
4556
4619
|
DEFAULT_TTS_SPEC,
|
|
4557
4620
|
DEFAULT_BATCH_SPEC,
|
|
@@ -4835,11 +4898,11 @@ function createAI(config = {}) {
|
|
|
4835
4898
|
allowFloating: input.allowFloating,
|
|
4836
4899
|
estIn: estTokens(input.prompt) + 1e3,
|
|
4837
4900
|
// prompt + ~1k image payload
|
|
4838
|
-
estOut: 512,
|
|
4901
|
+
estOut: input.maxTokens ?? 512,
|
|
4839
4902
|
invoke: async (spec) => {
|
|
4840
4903
|
const adapter = pickProvider(spec.provider);
|
|
4841
4904
|
if (!adapter.vision) throw new Error(`createAI: provider "${spec.provider}" does not support vision`);
|
|
4842
|
-
return adapter.vision({ messages, spec, reasoningEffort: input.reasoningEffort });
|
|
4905
|
+
return adapter.vision({ messages, spec, reasoningEffort: input.reasoningEffort, maxTokens: input.maxTokens, temperature: input.temperature });
|
|
4843
4906
|
}
|
|
4844
4907
|
});
|
|
4845
4908
|
},
|
|
@@ -5049,6 +5112,23 @@ function createAI(config = {}) {
|
|
|
5049
5112
|
}
|
|
5050
5113
|
});
|
|
5051
5114
|
},
|
|
5115
|
+
async vectorize(input) {
|
|
5116
|
+
input = vectorizeInputSchema.parse(input);
|
|
5117
|
+
return runCapability({
|
|
5118
|
+
primary: withOverride(DEFAULT_VECTORIZE_SPEC, input.override, "vectorize"),
|
|
5119
|
+
fallback: input.fallback,
|
|
5120
|
+
capability: "vectorize",
|
|
5121
|
+
purpose: input.purpose,
|
|
5122
|
+
labels: input.labels,
|
|
5123
|
+
estIn: 0,
|
|
5124
|
+
estOut: 0,
|
|
5125
|
+
invoke: async (spec) => {
|
|
5126
|
+
const adapter = pickProvider(spec.provider);
|
|
5127
|
+
if (!adapter.vectorize) throw new Error(`createAI: provider "${spec.provider}" does not support vectorize`);
|
|
5128
|
+
return adapter.vectorize({ image: input.image, shapeStacking: input.shapeStacking, spec });
|
|
5129
|
+
}
|
|
5130
|
+
});
|
|
5131
|
+
},
|
|
5052
5132
|
async podcast(input) {
|
|
5053
5133
|
input = podcastInputSchema.parse(input);
|
|
5054
5134
|
const inputs = input.script.map((turn) => {
|
|
@@ -5844,6 +5924,7 @@ export {
|
|
|
5844
5924
|
parseJsonLoose,
|
|
5845
5925
|
pricingFreshness,
|
|
5846
5926
|
pricingGeneratedAt,
|
|
5927
|
+
recraftAdapter,
|
|
5847
5928
|
refreshAvailability,
|
|
5848
5929
|
regionOfHost,
|
|
5849
5930
|
regionOfProvider,
|