@shop-os/modelkit 0.1.4 → 0.1.6
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 +36 -13
- package/dist/index.cjs +938 -609
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -9
- package/dist/index.d.ts +48 -9
- package/dist/index.js +937 -609
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -17,15 +17,35 @@ 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";
|
|
44
|
+
/** Gemini image safety threshold, per category, sent only when the caller opts in. */
|
|
45
|
+
type ImageSafetySetting = {
|
|
46
|
+
category: string;
|
|
47
|
+
threshold: string;
|
|
48
|
+
};
|
|
29
49
|
interface ImageRequest {
|
|
30
50
|
model: string;
|
|
31
51
|
prompt: string;
|
|
@@ -39,6 +59,12 @@ interface ImageRequest {
|
|
|
39
59
|
outputFormat?: OutputFormat;
|
|
40
60
|
/** Upscale factor for upscaler rows; adapters map it to the provider's field. */
|
|
41
61
|
scaleFactor?: number;
|
|
62
|
+
/** Gemini image safety thresholds. Off (provider default) unless supplied. */
|
|
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;
|
|
42
68
|
}
|
|
43
69
|
/**
|
|
44
70
|
* What a caller passes to generateImage. Same field names as the AI SDK's
|
|
@@ -73,6 +99,10 @@ interface VideoRequest {
|
|
|
73
99
|
negativePrompt?: string;
|
|
74
100
|
cfgScale?: number;
|
|
75
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;
|
|
76
106
|
mode?: "standard" | "pro";
|
|
77
107
|
}
|
|
78
108
|
/**
|
|
@@ -99,6 +129,8 @@ interface AudioRequest {
|
|
|
99
129
|
seed?: number;
|
|
100
130
|
/** Music models: no vocals. */
|
|
101
131
|
instrumental?: boolean;
|
|
132
|
+
/** Cancellation; combined with CallContext.signal before dispatch. */
|
|
133
|
+
abortSignal?: AbortSignal;
|
|
102
134
|
}
|
|
103
135
|
interface AudioResult {
|
|
104
136
|
audio: {
|
|
@@ -122,7 +154,7 @@ interface MediaPart {
|
|
|
122
154
|
cleanup?: () => Promise<void>;
|
|
123
155
|
}
|
|
124
156
|
type RequiredInput = "firstFrame" | "sourceVideo" | "references";
|
|
125
|
-
type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "instrumental";
|
|
157
|
+
type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "instrumental";
|
|
126
158
|
interface ReferenceLimits {
|
|
127
159
|
images?: number;
|
|
128
160
|
videos?: number;
|
|
@@ -261,7 +293,7 @@ interface UsageEvent {
|
|
|
261
293
|
reportedCostUsd?: number;
|
|
262
294
|
raw?: unknown;
|
|
263
295
|
}
|
|
264
|
-
type ProviderKeyName = "openai" | "anthropic" | "google" | "xai" | "perplexity" | "deepseek" | "moonshot" | "minimax" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "
|
|
296
|
+
type ProviderKeyName = "openai" | "anthropic" | "google" | "xai" | "perplexity" | "deepseek" | "moonshot" | "minimax" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "cloudflare";
|
|
265
297
|
type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
266
298
|
/** Higgsfield needs the pair; both switch together. */
|
|
267
299
|
higgsfieldSecret?: string;
|
|
@@ -274,8 +306,8 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
|
274
306
|
};
|
|
275
307
|
};
|
|
276
308
|
interface Routing {
|
|
277
|
-
/** Text models: direct provider
|
|
278
|
-
text?: "direct" | "cloudflare"
|
|
309
|
+
/** Text models: direct provider or the Cloudflare AI Gateway. */
|
|
310
|
+
text?: "direct" | "cloudflare";
|
|
279
311
|
/** Anthropic chat via Bedrock (us. prefixed ids) or the Anthropic API. */
|
|
280
312
|
anthropic?: "direct" | "bedrock";
|
|
281
313
|
/** fal from geo-blocked regions goes through the Cloudflare passthrough. */
|
|
@@ -309,10 +341,6 @@ interface CallContext {
|
|
|
309
341
|
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. */
|
|
310
342
|
tier?: "pro" | "enterprise";
|
|
311
343
|
signal?: AbortSignal;
|
|
312
|
-
/** Seedance: input urls that are verified assets and may contain human faces. */
|
|
313
|
-
verifiedAssetUrls?: string[];
|
|
314
|
-
/** Space Builder: center-crop the image to the requested ratio after generation. */
|
|
315
|
-
postCropToAspect?: boolean;
|
|
316
344
|
onUnsupported?: "error" | "coerce";
|
|
317
345
|
}
|
|
318
346
|
|
|
@@ -369,6 +397,7 @@ interface ResolveResult<T> {
|
|
|
369
397
|
declare function nearestAspectRatio(requested: AspectRatio, supported: AspectRatio[]): AspectRatio;
|
|
370
398
|
declare function resolveImageOptions(model: CatalogModel, request: ImageRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest>;
|
|
371
399
|
declare function resolveVideoOptions(model: CatalogModel, request: VideoRequest, onUnsupported?: OnUnsupported): ResolveResult<VideoRequest>;
|
|
400
|
+
declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<AudioRequest>;
|
|
372
401
|
|
|
373
402
|
/** Which key names an adapter needs. All of them must be set on a tier for that tier to win. */
|
|
374
403
|
declare const ADAPTER_KEYS: Record<AdapterId, ProviderKeyName[]>;
|
|
@@ -488,6 +517,11 @@ declare function passthroughTextModel(model: TextModelInstance): CatalogModel;
|
|
|
488
517
|
/** Canonical token usage for a completed text call. Quantity is total tokens. */
|
|
489
518
|
declare function textUsageEvent(model: CatalogModel, provider: string, usage: LanguageModelUsage): UsageEvent;
|
|
490
519
|
|
|
520
|
+
/** The SDK's streamText option union; `experimental_prepareStep` is a generateText-only alias. */
|
|
521
|
+
type StreamTextCallOptions<TOOLS extends ToolSet, OUTPUT extends Output.Output = Output.Output<string, string, never>> = ModelkitStreamTextOptions<TOOLS, OUTPUT> & {
|
|
522
|
+
/** @deprecated Use `prepareStep`; accepted for parity with `generateText`. */
|
|
523
|
+
experimental_prepareStep?: Parameters<typeof streamText$1<TOOLS, OUTPUT>>[0]["prepareStep"];
|
|
524
|
+
};
|
|
491
525
|
interface ModelKit extends TextMethods {
|
|
492
526
|
catalog: Catalog;
|
|
493
527
|
/**
|
|
@@ -504,6 +538,11 @@ interface ModelKit extends TextMethods {
|
|
|
504
538
|
languageModel(modelId: string, call?: CallContext): LanguageModelHandle;
|
|
505
539
|
/** Generate music or a soundtrack. Blocks until the provider returns audio. */
|
|
506
540
|
generateAudio(req: AudioRequest, call?: CallContext): Promise<AudioResult>;
|
|
541
|
+
/**
|
|
542
|
+
* Stream text. Mirrors `TextMethods.streamText` and also accepts the
|
|
543
|
+
* deprecated `experimental_prepareStep` alias that `generateText` takes.
|
|
544
|
+
*/
|
|
545
|
+
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>>;
|
|
507
546
|
/**
|
|
508
547
|
* Prepare a video or document for a language model call (video understanding).
|
|
509
548
|
* Uses the provider file store when the payload is too large to inline.
|
|
@@ -590,4 +629,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
590
629
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
591
630
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
592
631
|
|
|
593
|
-
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 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 };
|
|
632
|
+
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 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,15 +17,35 @@ 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";
|
|
44
|
+
/** Gemini image safety threshold, per category, sent only when the caller opts in. */
|
|
45
|
+
type ImageSafetySetting = {
|
|
46
|
+
category: string;
|
|
47
|
+
threshold: string;
|
|
48
|
+
};
|
|
29
49
|
interface ImageRequest {
|
|
30
50
|
model: string;
|
|
31
51
|
prompt: string;
|
|
@@ -39,6 +59,12 @@ interface ImageRequest {
|
|
|
39
59
|
outputFormat?: OutputFormat;
|
|
40
60
|
/** Upscale factor for upscaler rows; adapters map it to the provider's field. */
|
|
41
61
|
scaleFactor?: number;
|
|
62
|
+
/** Gemini image safety thresholds. Off (provider default) unless supplied. */
|
|
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;
|
|
42
68
|
}
|
|
43
69
|
/**
|
|
44
70
|
* What a caller passes to generateImage. Same field names as the AI SDK's
|
|
@@ -73,6 +99,10 @@ interface VideoRequest {
|
|
|
73
99
|
negativePrompt?: string;
|
|
74
100
|
cfgScale?: number;
|
|
75
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;
|
|
76
106
|
mode?: "standard" | "pro";
|
|
77
107
|
}
|
|
78
108
|
/**
|
|
@@ -99,6 +129,8 @@ interface AudioRequest {
|
|
|
99
129
|
seed?: number;
|
|
100
130
|
/** Music models: no vocals. */
|
|
101
131
|
instrumental?: boolean;
|
|
132
|
+
/** Cancellation; combined with CallContext.signal before dispatch. */
|
|
133
|
+
abortSignal?: AbortSignal;
|
|
102
134
|
}
|
|
103
135
|
interface AudioResult {
|
|
104
136
|
audio: {
|
|
@@ -122,7 +154,7 @@ interface MediaPart {
|
|
|
122
154
|
cleanup?: () => Promise<void>;
|
|
123
155
|
}
|
|
124
156
|
type RequiredInput = "firstFrame" | "sourceVideo" | "references";
|
|
125
|
-
type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "instrumental";
|
|
157
|
+
type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "instrumental";
|
|
126
158
|
interface ReferenceLimits {
|
|
127
159
|
images?: number;
|
|
128
160
|
videos?: number;
|
|
@@ -261,7 +293,7 @@ interface UsageEvent {
|
|
|
261
293
|
reportedCostUsd?: number;
|
|
262
294
|
raw?: unknown;
|
|
263
295
|
}
|
|
264
|
-
type ProviderKeyName = "openai" | "anthropic" | "google" | "xai" | "perplexity" | "deepseek" | "moonshot" | "minimax" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "
|
|
296
|
+
type ProviderKeyName = "openai" | "anthropic" | "google" | "xai" | "perplexity" | "deepseek" | "moonshot" | "minimax" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "cloudflare";
|
|
265
297
|
type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
266
298
|
/** Higgsfield needs the pair; both switch together. */
|
|
267
299
|
higgsfieldSecret?: string;
|
|
@@ -274,8 +306,8 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
|
274
306
|
};
|
|
275
307
|
};
|
|
276
308
|
interface Routing {
|
|
277
|
-
/** Text models: direct provider
|
|
278
|
-
text?: "direct" | "cloudflare"
|
|
309
|
+
/** Text models: direct provider or the Cloudflare AI Gateway. */
|
|
310
|
+
text?: "direct" | "cloudflare";
|
|
279
311
|
/** Anthropic chat via Bedrock (us. prefixed ids) or the Anthropic API. */
|
|
280
312
|
anthropic?: "direct" | "bedrock";
|
|
281
313
|
/** fal from geo-blocked regions goes through the Cloudflare passthrough. */
|
|
@@ -309,10 +341,6 @@ interface CallContext {
|
|
|
309
341
|
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. */
|
|
310
342
|
tier?: "pro" | "enterprise";
|
|
311
343
|
signal?: AbortSignal;
|
|
312
|
-
/** Seedance: input urls that are verified assets and may contain human faces. */
|
|
313
|
-
verifiedAssetUrls?: string[];
|
|
314
|
-
/** Space Builder: center-crop the image to the requested ratio after generation. */
|
|
315
|
-
postCropToAspect?: boolean;
|
|
316
344
|
onUnsupported?: "error" | "coerce";
|
|
317
345
|
}
|
|
318
346
|
|
|
@@ -369,6 +397,7 @@ interface ResolveResult<T> {
|
|
|
369
397
|
declare function nearestAspectRatio(requested: AspectRatio, supported: AspectRatio[]): AspectRatio;
|
|
370
398
|
declare function resolveImageOptions(model: CatalogModel, request: ImageRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest>;
|
|
371
399
|
declare function resolveVideoOptions(model: CatalogModel, request: VideoRequest, onUnsupported?: OnUnsupported): ResolveResult<VideoRequest>;
|
|
400
|
+
declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<AudioRequest>;
|
|
372
401
|
|
|
373
402
|
/** Which key names an adapter needs. All of them must be set on a tier for that tier to win. */
|
|
374
403
|
declare const ADAPTER_KEYS: Record<AdapterId, ProviderKeyName[]>;
|
|
@@ -488,6 +517,11 @@ declare function passthroughTextModel(model: TextModelInstance): CatalogModel;
|
|
|
488
517
|
/** Canonical token usage for a completed text call. Quantity is total tokens. */
|
|
489
518
|
declare function textUsageEvent(model: CatalogModel, provider: string, usage: LanguageModelUsage): UsageEvent;
|
|
490
519
|
|
|
520
|
+
/** The SDK's streamText option union; `experimental_prepareStep` is a generateText-only alias. */
|
|
521
|
+
type StreamTextCallOptions<TOOLS extends ToolSet, OUTPUT extends Output.Output = Output.Output<string, string, never>> = ModelkitStreamTextOptions<TOOLS, OUTPUT> & {
|
|
522
|
+
/** @deprecated Use `prepareStep`; accepted for parity with `generateText`. */
|
|
523
|
+
experimental_prepareStep?: Parameters<typeof streamText$1<TOOLS, OUTPUT>>[0]["prepareStep"];
|
|
524
|
+
};
|
|
491
525
|
interface ModelKit extends TextMethods {
|
|
492
526
|
catalog: Catalog;
|
|
493
527
|
/**
|
|
@@ -504,6 +538,11 @@ interface ModelKit extends TextMethods {
|
|
|
504
538
|
languageModel(modelId: string, call?: CallContext): LanguageModelHandle;
|
|
505
539
|
/** Generate music or a soundtrack. Blocks until the provider returns audio. */
|
|
506
540
|
generateAudio(req: AudioRequest, call?: CallContext): Promise<AudioResult>;
|
|
541
|
+
/**
|
|
542
|
+
* Stream text. Mirrors `TextMethods.streamText` and also accepts the
|
|
543
|
+
* deprecated `experimental_prepareStep` alias that `generateText` takes.
|
|
544
|
+
*/
|
|
545
|
+
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>>;
|
|
507
546
|
/**
|
|
508
547
|
* Prepare a video or document for a language model call (video understanding).
|
|
509
548
|
* Uses the provider file store when the payload is too large to inline.
|
|
@@ -590,4 +629,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
590
629
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
591
630
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
592
631
|
|
|
593
|
-
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 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 };
|
|
632
|
+
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 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 };
|