@shop-os/modelkit 0.1.5 → 0.1.7
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/README.md +12 -11
- package/dist/index.cjs +1156 -380
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -9
- package/dist/index.d.ts +69 -9
- package/dist/index.js +1155 -380
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -17,12 +17,27 @@ type VideoResolution = "360p" | "480p" | "720p" | "768p" | "1080p" | "2k" | "4k"
|
|
|
17
17
|
/** "xhigh" and "max" exist only on gpt-image-2.5; gpt-image-2 rejects them at the provider. */
|
|
18
18
|
type ImageQuality = "auto" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
19
19
|
type OutputFormat = "png" | "jpeg" | "webp";
|
|
20
|
+
/**
|
|
21
|
+
* A media input. `label` is a caption the adapter emits as a text part right
|
|
22
|
+
* before the media where the provider takes interleaved content (Gemini image,
|
|
23
|
+
* Omni), so a prompt can address "Image 2" or "the brand logo" by name.
|
|
24
|
+
*/
|
|
20
25
|
type MediaRef = {
|
|
21
26
|
url: string;
|
|
27
|
+
label?: string;
|
|
22
28
|
} | {
|
|
23
29
|
bytes: Uint8Array;
|
|
24
30
|
mime: string;
|
|
31
|
+
label?: string;
|
|
25
32
|
};
|
|
33
|
+
/** Caller-driven Topaz upscale controls; see the topaz row and TopazImageInput. */
|
|
34
|
+
interface UpscaleOptions {
|
|
35
|
+
enhanceModel?: string;
|
|
36
|
+
subjectDetection?: string;
|
|
37
|
+
faceEnhancement?: boolean;
|
|
38
|
+
faceEnhancementCreativity?: number;
|
|
39
|
+
faceEnhancementStrength?: number;
|
|
40
|
+
}
|
|
26
41
|
type ModelType = "text" | "image" | "video" | "audio" | "upscale" | "bg-remove";
|
|
27
42
|
type Lifecycle = "active" | "hidden" | "deprecated" | "retired";
|
|
28
43
|
type AdapterId = "ai-sdk-text" | "google-image" | "openai-image" | "google-genai" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "xai-video";
|
|
@@ -46,6 +61,10 @@ interface ImageRequest {
|
|
|
46
61
|
scaleFactor?: number;
|
|
47
62
|
/** Gemini image safety thresholds. Off (provider default) unless supplied. */
|
|
48
63
|
safetySettings?: ImageSafetySetting[];
|
|
64
|
+
/** Sampling temperature where the provider exposes one for images (Gemini). */
|
|
65
|
+
temperature?: number;
|
|
66
|
+
/** Upscaler controls beyond `scaleFactor`/`outputFormat` (Topaz). */
|
|
67
|
+
upscale?: UpscaleOptions;
|
|
49
68
|
}
|
|
50
69
|
/**
|
|
51
70
|
* What a caller passes to generateImage. Same field names as the AI SDK's
|
|
@@ -80,6 +99,10 @@ interface VideoRequest {
|
|
|
80
99
|
negativePrompt?: string;
|
|
81
100
|
cfgScale?: number;
|
|
82
101
|
promptExpansion?: "fast" | "balanced" | "quality";
|
|
102
|
+
/** Provider watermark toggle (Seedance). */
|
|
103
|
+
watermark?: boolean;
|
|
104
|
+
/** Provider-side safety checker toggle (fal MiniMax). Provider default when unset. */
|
|
105
|
+
safetyChecker?: boolean;
|
|
83
106
|
mode?: "standard" | "pro";
|
|
84
107
|
}
|
|
85
108
|
/**
|
|
@@ -106,6 +129,8 @@ interface AudioRequest {
|
|
|
106
129
|
seed?: number;
|
|
107
130
|
/** Music models: no vocals. */
|
|
108
131
|
instrumental?: boolean;
|
|
132
|
+
/** Cancellation; combined with CallContext.signal before dispatch. */
|
|
133
|
+
abortSignal?: AbortSignal;
|
|
109
134
|
}
|
|
110
135
|
interface AudioResult {
|
|
111
136
|
audio: {
|
|
@@ -129,7 +154,7 @@ interface MediaPart {
|
|
|
129
154
|
cleanup?: () => Promise<void>;
|
|
130
155
|
}
|
|
131
156
|
type RequiredInput = "firstFrame" | "sourceVideo" | "references";
|
|
132
|
-
type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "instrumental";
|
|
157
|
+
type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "instrumental";
|
|
133
158
|
interface ReferenceLimits {
|
|
134
159
|
images?: number;
|
|
135
160
|
videos?: number;
|
|
@@ -175,6 +200,31 @@ type ProviderOptions = {
|
|
|
175
200
|
type UsageUnit = "tokens" | "images" | "seconds" | "reported_cost_usd" | "compute_seconds";
|
|
176
201
|
type UsageModality = "TEXT" | "IMAGE" | "VIDEO" | "AUDIO";
|
|
177
202
|
type PricingKind = "token" | "image_size" | "video_per_second" | "flat";
|
|
203
|
+
/** What a model picker shows for a row. Free of any surface-specific ids. */
|
|
204
|
+
interface CatalogDisplay {
|
|
205
|
+
/** Vendor as the UI names it: "google", "openai", "meta", "bytedance", "xai", "kuaishou", ... */
|
|
206
|
+
provider: string;
|
|
207
|
+
/** One or two sentences for the picker card. */
|
|
208
|
+
description: string;
|
|
209
|
+
/** CDN URL of the vendor or model logo. */
|
|
210
|
+
logo?: string;
|
|
211
|
+
}
|
|
212
|
+
/** Capability flags a UI keys off. Absent means false / unknown. */
|
|
213
|
+
interface CatalogCapabilities {
|
|
214
|
+
/** Image rows: generates from a prompt alone. */
|
|
215
|
+
imageGenerate?: boolean;
|
|
216
|
+
/** Image rows: edits or conditions on reference images. */
|
|
217
|
+
imageEdit?: boolean;
|
|
218
|
+
/** Video rows: takes an existing video as the thing to edit or extend. */
|
|
219
|
+
acceptsSourceVideo?: boolean;
|
|
220
|
+
/** Video rows: first/last frames and reference images are mutually exclusive inputs. */
|
|
221
|
+
framesExcludeReferences?: boolean;
|
|
222
|
+
/** Text rows. */
|
|
223
|
+
vision?: boolean;
|
|
224
|
+
tools?: boolean;
|
|
225
|
+
structuredOutput?: boolean;
|
|
226
|
+
contextWindow?: number;
|
|
227
|
+
}
|
|
178
228
|
interface CatalogModel {
|
|
179
229
|
/** Canonical id. Equals the pricing key in pro-backend credit_pricing_* tables. */
|
|
180
230
|
id: string;
|
|
@@ -194,6 +244,9 @@ interface CatalogModel {
|
|
|
194
244
|
modality: UsageModality;
|
|
195
245
|
};
|
|
196
246
|
pricingKind: PricingKind;
|
|
247
|
+
/** Required on every `active` row so a picker can render it without a hand-written catalog. */
|
|
248
|
+
display?: CatalogDisplay;
|
|
249
|
+
capabilities?: CatalogCapabilities;
|
|
197
250
|
}
|
|
198
251
|
interface Warning {
|
|
199
252
|
code: "ratio_coerced" | "ratio_dropped" | "size_coerced" | "resolution_coerced" | "duration_coerced" | "references_trimmed" | "option_ignored";
|
|
@@ -268,7 +321,7 @@ interface UsageEvent {
|
|
|
268
321
|
reportedCostUsd?: number;
|
|
269
322
|
raw?: unknown;
|
|
270
323
|
}
|
|
271
|
-
type ProviderKeyName = "openai" | "anthropic" | "google" | "xai" | "perplexity" | "deepseek" | "moonshot" | "minimax" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "
|
|
324
|
+
type ProviderKeyName = "openai" | "anthropic" | "google" | "xai" | "perplexity" | "deepseek" | "moonshot" | "minimax" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "cloudflare";
|
|
272
325
|
type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
273
326
|
/** Higgsfield needs the pair; both switch together. */
|
|
274
327
|
higgsfieldSecret?: string;
|
|
@@ -281,8 +334,8 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
|
281
334
|
};
|
|
282
335
|
};
|
|
283
336
|
interface Routing {
|
|
284
|
-
/** Text models: direct provider
|
|
285
|
-
text?: "direct" | "cloudflare"
|
|
337
|
+
/** Text models: direct provider or the Cloudflare AI Gateway. */
|
|
338
|
+
text?: "direct" | "cloudflare";
|
|
286
339
|
/** Anthropic chat via Bedrock (us. prefixed ids) or the Anthropic API. */
|
|
287
340
|
anthropic?: "direct" | "bedrock";
|
|
288
341
|
/** fal from geo-blocked regions goes through the Cloudflare passthrough. */
|
|
@@ -316,10 +369,6 @@ interface CallContext {
|
|
|
316
369
|
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. */
|
|
317
370
|
tier?: "pro" | "enterprise";
|
|
318
371
|
signal?: AbortSignal;
|
|
319
|
-
/** Seedance: input urls that are verified assets and may contain human faces. */
|
|
320
|
-
verifiedAssetUrls?: string[];
|
|
321
|
-
/** Space Builder: center-crop the image to the requested ratio after generation. */
|
|
322
|
-
postCropToAspect?: boolean;
|
|
323
372
|
onUnsupported?: "error" | "coerce";
|
|
324
373
|
}
|
|
325
374
|
|
|
@@ -376,6 +425,7 @@ interface ResolveResult<T> {
|
|
|
376
425
|
declare function nearestAspectRatio(requested: AspectRatio, supported: AspectRatio[]): AspectRatio;
|
|
377
426
|
declare function resolveImageOptions(model: CatalogModel, request: ImageRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest>;
|
|
378
427
|
declare function resolveVideoOptions(model: CatalogModel, request: VideoRequest, onUnsupported?: OnUnsupported): ResolveResult<VideoRequest>;
|
|
428
|
+
declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<AudioRequest>;
|
|
379
429
|
|
|
380
430
|
/** Which key names an adapter needs. All of them must be set on a tier for that tier to win. */
|
|
381
431
|
declare const ADAPTER_KEYS: Record<AdapterId, ProviderKeyName[]>;
|
|
@@ -495,6 +545,11 @@ declare function passthroughTextModel(model: TextModelInstance): CatalogModel;
|
|
|
495
545
|
/** Canonical token usage for a completed text call. Quantity is total tokens. */
|
|
496
546
|
declare function textUsageEvent(model: CatalogModel, provider: string, usage: LanguageModelUsage): UsageEvent;
|
|
497
547
|
|
|
548
|
+
/** The SDK's streamText option union; `experimental_prepareStep` is a generateText-only alias. */
|
|
549
|
+
type StreamTextCallOptions<TOOLS extends ToolSet, OUTPUT extends Output.Output = Output.Output<string, string, never>> = ModelkitStreamTextOptions<TOOLS, OUTPUT> & {
|
|
550
|
+
/** @deprecated Use `prepareStep`; accepted for parity with `generateText`. */
|
|
551
|
+
experimental_prepareStep?: Parameters<typeof streamText$1<TOOLS, OUTPUT>>[0]["prepareStep"];
|
|
552
|
+
};
|
|
498
553
|
interface ModelKit extends TextMethods {
|
|
499
554
|
catalog: Catalog;
|
|
500
555
|
/**
|
|
@@ -511,6 +566,11 @@ interface ModelKit extends TextMethods {
|
|
|
511
566
|
languageModel(modelId: string, call?: CallContext): LanguageModelHandle;
|
|
512
567
|
/** Generate music or a soundtrack. Blocks until the provider returns audio. */
|
|
513
568
|
generateAudio(req: AudioRequest, call?: CallContext): Promise<AudioResult>;
|
|
569
|
+
/**
|
|
570
|
+
* Stream text. Mirrors `TextMethods.streamText` and also accepts the
|
|
571
|
+
* deprecated `experimental_prepareStep` alias that `generateText` takes.
|
|
572
|
+
*/
|
|
573
|
+
streamText<TOOLS extends ToolSet, OUTPUT extends Output.Output = Output.Output<string, string, never>>(options: StreamTextCallOptions<TOOLS, OUTPUT>, call?: CallContext): ReturnType<typeof streamText$1<TOOLS, OUTPUT>>;
|
|
514
574
|
/**
|
|
515
575
|
* Prepare a video or document for a language model call (video understanding).
|
|
516
576
|
* Uses the provider file store when the payload is too large to inline.
|
|
@@ -597,4 +657,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
597
657
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
598
658
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
599
659
|
|
|
600
|
-
export { ADAPTER_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogModel, type CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, type GeneratedImage, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type LanguageModelHandle, type Lifecycle, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, type TextMethods, type TextModelInstance, type UsageEvent, type UsageModality, type UsageUnit, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, higgsfieldAdapter, isModelKitError, keysFromEnv, languageModel, mergeTextProviderOptions, nearestAspectRatio, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, prodiaAdapter, readErrorBody, replicateAdapter, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
|
|
660
|
+
export { ADAPTER_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogCapabilities, type CatalogDisplay, type CatalogModel, type CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, type GeneratedImage, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type LanguageModelHandle, type Lifecycle, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, higgsfieldAdapter, isModelKitError, keysFromEnv, languageModel, mergeTextProviderOptions, nearestAspectRatio, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, prodiaAdapter, readErrorBody, replicateAdapter, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
|
package/dist/index.d.ts
CHANGED
|
@@ -17,12 +17,27 @@ type VideoResolution = "360p" | "480p" | "720p" | "768p" | "1080p" | "2k" | "4k"
|
|
|
17
17
|
/** "xhigh" and "max" exist only on gpt-image-2.5; gpt-image-2 rejects them at the provider. */
|
|
18
18
|
type ImageQuality = "auto" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
19
19
|
type OutputFormat = "png" | "jpeg" | "webp";
|
|
20
|
+
/**
|
|
21
|
+
* A media input. `label` is a caption the adapter emits as a text part right
|
|
22
|
+
* before the media where the provider takes interleaved content (Gemini image,
|
|
23
|
+
* Omni), so a prompt can address "Image 2" or "the brand logo" by name.
|
|
24
|
+
*/
|
|
20
25
|
type MediaRef = {
|
|
21
26
|
url: string;
|
|
27
|
+
label?: string;
|
|
22
28
|
} | {
|
|
23
29
|
bytes: Uint8Array;
|
|
24
30
|
mime: string;
|
|
31
|
+
label?: string;
|
|
25
32
|
};
|
|
33
|
+
/** Caller-driven Topaz upscale controls; see the topaz row and TopazImageInput. */
|
|
34
|
+
interface UpscaleOptions {
|
|
35
|
+
enhanceModel?: string;
|
|
36
|
+
subjectDetection?: string;
|
|
37
|
+
faceEnhancement?: boolean;
|
|
38
|
+
faceEnhancementCreativity?: number;
|
|
39
|
+
faceEnhancementStrength?: number;
|
|
40
|
+
}
|
|
26
41
|
type ModelType = "text" | "image" | "video" | "audio" | "upscale" | "bg-remove";
|
|
27
42
|
type Lifecycle = "active" | "hidden" | "deprecated" | "retired";
|
|
28
43
|
type AdapterId = "ai-sdk-text" | "google-image" | "openai-image" | "google-genai" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "xai-video";
|
|
@@ -46,6 +61,10 @@ interface ImageRequest {
|
|
|
46
61
|
scaleFactor?: number;
|
|
47
62
|
/** Gemini image safety thresholds. Off (provider default) unless supplied. */
|
|
48
63
|
safetySettings?: ImageSafetySetting[];
|
|
64
|
+
/** Sampling temperature where the provider exposes one for images (Gemini). */
|
|
65
|
+
temperature?: number;
|
|
66
|
+
/** Upscaler controls beyond `scaleFactor`/`outputFormat` (Topaz). */
|
|
67
|
+
upscale?: UpscaleOptions;
|
|
49
68
|
}
|
|
50
69
|
/**
|
|
51
70
|
* What a caller passes to generateImage. Same field names as the AI SDK's
|
|
@@ -80,6 +99,10 @@ interface VideoRequest {
|
|
|
80
99
|
negativePrompt?: string;
|
|
81
100
|
cfgScale?: number;
|
|
82
101
|
promptExpansion?: "fast" | "balanced" | "quality";
|
|
102
|
+
/** Provider watermark toggle (Seedance). */
|
|
103
|
+
watermark?: boolean;
|
|
104
|
+
/** Provider-side safety checker toggle (fal MiniMax). Provider default when unset. */
|
|
105
|
+
safetyChecker?: boolean;
|
|
83
106
|
mode?: "standard" | "pro";
|
|
84
107
|
}
|
|
85
108
|
/**
|
|
@@ -106,6 +129,8 @@ interface AudioRequest {
|
|
|
106
129
|
seed?: number;
|
|
107
130
|
/** Music models: no vocals. */
|
|
108
131
|
instrumental?: boolean;
|
|
132
|
+
/** Cancellation; combined with CallContext.signal before dispatch. */
|
|
133
|
+
abortSignal?: AbortSignal;
|
|
109
134
|
}
|
|
110
135
|
interface AudioResult {
|
|
111
136
|
audio: {
|
|
@@ -129,7 +154,7 @@ interface MediaPart {
|
|
|
129
154
|
cleanup?: () => Promise<void>;
|
|
130
155
|
}
|
|
131
156
|
type RequiredInput = "firstFrame" | "sourceVideo" | "references";
|
|
132
|
-
type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "instrumental";
|
|
157
|
+
type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "instrumental";
|
|
133
158
|
interface ReferenceLimits {
|
|
134
159
|
images?: number;
|
|
135
160
|
videos?: number;
|
|
@@ -175,6 +200,31 @@ type ProviderOptions = {
|
|
|
175
200
|
type UsageUnit = "tokens" | "images" | "seconds" | "reported_cost_usd" | "compute_seconds";
|
|
176
201
|
type UsageModality = "TEXT" | "IMAGE" | "VIDEO" | "AUDIO";
|
|
177
202
|
type PricingKind = "token" | "image_size" | "video_per_second" | "flat";
|
|
203
|
+
/** What a model picker shows for a row. Free of any surface-specific ids. */
|
|
204
|
+
interface CatalogDisplay {
|
|
205
|
+
/** Vendor as the UI names it: "google", "openai", "meta", "bytedance", "xai", "kuaishou", ... */
|
|
206
|
+
provider: string;
|
|
207
|
+
/** One or two sentences for the picker card. */
|
|
208
|
+
description: string;
|
|
209
|
+
/** CDN URL of the vendor or model logo. */
|
|
210
|
+
logo?: string;
|
|
211
|
+
}
|
|
212
|
+
/** Capability flags a UI keys off. Absent means false / unknown. */
|
|
213
|
+
interface CatalogCapabilities {
|
|
214
|
+
/** Image rows: generates from a prompt alone. */
|
|
215
|
+
imageGenerate?: boolean;
|
|
216
|
+
/** Image rows: edits or conditions on reference images. */
|
|
217
|
+
imageEdit?: boolean;
|
|
218
|
+
/** Video rows: takes an existing video as the thing to edit or extend. */
|
|
219
|
+
acceptsSourceVideo?: boolean;
|
|
220
|
+
/** Video rows: first/last frames and reference images are mutually exclusive inputs. */
|
|
221
|
+
framesExcludeReferences?: boolean;
|
|
222
|
+
/** Text rows. */
|
|
223
|
+
vision?: boolean;
|
|
224
|
+
tools?: boolean;
|
|
225
|
+
structuredOutput?: boolean;
|
|
226
|
+
contextWindow?: number;
|
|
227
|
+
}
|
|
178
228
|
interface CatalogModel {
|
|
179
229
|
/** Canonical id. Equals the pricing key in pro-backend credit_pricing_* tables. */
|
|
180
230
|
id: string;
|
|
@@ -194,6 +244,9 @@ interface CatalogModel {
|
|
|
194
244
|
modality: UsageModality;
|
|
195
245
|
};
|
|
196
246
|
pricingKind: PricingKind;
|
|
247
|
+
/** Required on every `active` row so a picker can render it without a hand-written catalog. */
|
|
248
|
+
display?: CatalogDisplay;
|
|
249
|
+
capabilities?: CatalogCapabilities;
|
|
197
250
|
}
|
|
198
251
|
interface Warning {
|
|
199
252
|
code: "ratio_coerced" | "ratio_dropped" | "size_coerced" | "resolution_coerced" | "duration_coerced" | "references_trimmed" | "option_ignored";
|
|
@@ -268,7 +321,7 @@ interface UsageEvent {
|
|
|
268
321
|
reportedCostUsd?: number;
|
|
269
322
|
raw?: unknown;
|
|
270
323
|
}
|
|
271
|
-
type ProviderKeyName = "openai" | "anthropic" | "google" | "xai" | "perplexity" | "deepseek" | "moonshot" | "minimax" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "
|
|
324
|
+
type ProviderKeyName = "openai" | "anthropic" | "google" | "xai" | "perplexity" | "deepseek" | "moonshot" | "minimax" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "cloudflare";
|
|
272
325
|
type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
273
326
|
/** Higgsfield needs the pair; both switch together. */
|
|
274
327
|
higgsfieldSecret?: string;
|
|
@@ -281,8 +334,8 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
|
281
334
|
};
|
|
282
335
|
};
|
|
283
336
|
interface Routing {
|
|
284
|
-
/** Text models: direct provider
|
|
285
|
-
text?: "direct" | "cloudflare"
|
|
337
|
+
/** Text models: direct provider or the Cloudflare AI Gateway. */
|
|
338
|
+
text?: "direct" | "cloudflare";
|
|
286
339
|
/** Anthropic chat via Bedrock (us. prefixed ids) or the Anthropic API. */
|
|
287
340
|
anthropic?: "direct" | "bedrock";
|
|
288
341
|
/** fal from geo-blocked regions goes through the Cloudflare passthrough. */
|
|
@@ -316,10 +369,6 @@ interface CallContext {
|
|
|
316
369
|
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. */
|
|
317
370
|
tier?: "pro" | "enterprise";
|
|
318
371
|
signal?: AbortSignal;
|
|
319
|
-
/** Seedance: input urls that are verified assets and may contain human faces. */
|
|
320
|
-
verifiedAssetUrls?: string[];
|
|
321
|
-
/** Space Builder: center-crop the image to the requested ratio after generation. */
|
|
322
|
-
postCropToAspect?: boolean;
|
|
323
372
|
onUnsupported?: "error" | "coerce";
|
|
324
373
|
}
|
|
325
374
|
|
|
@@ -376,6 +425,7 @@ interface ResolveResult<T> {
|
|
|
376
425
|
declare function nearestAspectRatio(requested: AspectRatio, supported: AspectRatio[]): AspectRatio;
|
|
377
426
|
declare function resolveImageOptions(model: CatalogModel, request: ImageRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest>;
|
|
378
427
|
declare function resolveVideoOptions(model: CatalogModel, request: VideoRequest, onUnsupported?: OnUnsupported): ResolveResult<VideoRequest>;
|
|
428
|
+
declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<AudioRequest>;
|
|
379
429
|
|
|
380
430
|
/** Which key names an adapter needs. All of them must be set on a tier for that tier to win. */
|
|
381
431
|
declare const ADAPTER_KEYS: Record<AdapterId, ProviderKeyName[]>;
|
|
@@ -495,6 +545,11 @@ declare function passthroughTextModel(model: TextModelInstance): CatalogModel;
|
|
|
495
545
|
/** Canonical token usage for a completed text call. Quantity is total tokens. */
|
|
496
546
|
declare function textUsageEvent(model: CatalogModel, provider: string, usage: LanguageModelUsage): UsageEvent;
|
|
497
547
|
|
|
548
|
+
/** The SDK's streamText option union; `experimental_prepareStep` is a generateText-only alias. */
|
|
549
|
+
type StreamTextCallOptions<TOOLS extends ToolSet, OUTPUT extends Output.Output = Output.Output<string, string, never>> = ModelkitStreamTextOptions<TOOLS, OUTPUT> & {
|
|
550
|
+
/** @deprecated Use `prepareStep`; accepted for parity with `generateText`. */
|
|
551
|
+
experimental_prepareStep?: Parameters<typeof streamText$1<TOOLS, OUTPUT>>[0]["prepareStep"];
|
|
552
|
+
};
|
|
498
553
|
interface ModelKit extends TextMethods {
|
|
499
554
|
catalog: Catalog;
|
|
500
555
|
/**
|
|
@@ -511,6 +566,11 @@ interface ModelKit extends TextMethods {
|
|
|
511
566
|
languageModel(modelId: string, call?: CallContext): LanguageModelHandle;
|
|
512
567
|
/** Generate music or a soundtrack. Blocks until the provider returns audio. */
|
|
513
568
|
generateAudio(req: AudioRequest, call?: CallContext): Promise<AudioResult>;
|
|
569
|
+
/**
|
|
570
|
+
* Stream text. Mirrors `TextMethods.streamText` and also accepts the
|
|
571
|
+
* deprecated `experimental_prepareStep` alias that `generateText` takes.
|
|
572
|
+
*/
|
|
573
|
+
streamText<TOOLS extends ToolSet, OUTPUT extends Output.Output = Output.Output<string, string, never>>(options: StreamTextCallOptions<TOOLS, OUTPUT>, call?: CallContext): ReturnType<typeof streamText$1<TOOLS, OUTPUT>>;
|
|
514
574
|
/**
|
|
515
575
|
* Prepare a video or document for a language model call (video understanding).
|
|
516
576
|
* Uses the provider file store when the payload is too large to inline.
|
|
@@ -597,4 +657,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
597
657
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
598
658
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
599
659
|
|
|
600
|
-
export { ADAPTER_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogModel, type CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, type GeneratedImage, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type LanguageModelHandle, type Lifecycle, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, type TextMethods, type TextModelInstance, type UsageEvent, type UsageModality, type UsageUnit, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, higgsfieldAdapter, isModelKitError, keysFromEnv, languageModel, mergeTextProviderOptions, nearestAspectRatio, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, prodiaAdapter, readErrorBody, replicateAdapter, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
|
|
660
|
+
export { ADAPTER_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogCapabilities, type CatalogDisplay, type CatalogModel, type CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, type GeneratedImage, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type LanguageModelHandle, type Lifecycle, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, higgsfieldAdapter, isModelKitError, keysFromEnv, languageModel, mergeTextProviderOptions, nearestAspectRatio, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, prodiaAdapter, readErrorBody, replicateAdapter, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
|