@shop-os/modelkit 0.1.5 → 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 +11 -11
- package/dist/index.cjs +538 -302
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -9
- package/dist/index.d.ts +41 -9
- package/dist/index.js +537 -302
- 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;
|
|
@@ -268,7 +293,7 @@ interface UsageEvent {
|
|
|
268
293
|
reportedCostUsd?: number;
|
|
269
294
|
raw?: unknown;
|
|
270
295
|
}
|
|
271
|
-
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";
|
|
272
297
|
type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
273
298
|
/** Higgsfield needs the pair; both switch together. */
|
|
274
299
|
higgsfieldSecret?: string;
|
|
@@ -281,8 +306,8 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
|
281
306
|
};
|
|
282
307
|
};
|
|
283
308
|
interface Routing {
|
|
284
|
-
/** Text models: direct provider
|
|
285
|
-
text?: "direct" | "cloudflare"
|
|
309
|
+
/** Text models: direct provider or the Cloudflare AI Gateway. */
|
|
310
|
+
text?: "direct" | "cloudflare";
|
|
286
311
|
/** Anthropic chat via Bedrock (us. prefixed ids) or the Anthropic API. */
|
|
287
312
|
anthropic?: "direct" | "bedrock";
|
|
288
313
|
/** fal from geo-blocked regions goes through the Cloudflare passthrough. */
|
|
@@ -316,10 +341,6 @@ interface CallContext {
|
|
|
316
341
|
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. */
|
|
317
342
|
tier?: "pro" | "enterprise";
|
|
318
343
|
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
344
|
onUnsupported?: "error" | "coerce";
|
|
324
345
|
}
|
|
325
346
|
|
|
@@ -376,6 +397,7 @@ interface ResolveResult<T> {
|
|
|
376
397
|
declare function nearestAspectRatio(requested: AspectRatio, supported: AspectRatio[]): AspectRatio;
|
|
377
398
|
declare function resolveImageOptions(model: CatalogModel, request: ImageRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest>;
|
|
378
399
|
declare function resolveVideoOptions(model: CatalogModel, request: VideoRequest, onUnsupported?: OnUnsupported): ResolveResult<VideoRequest>;
|
|
400
|
+
declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<AudioRequest>;
|
|
379
401
|
|
|
380
402
|
/** Which key names an adapter needs. All of them must be set on a tier for that tier to win. */
|
|
381
403
|
declare const ADAPTER_KEYS: Record<AdapterId, ProviderKeyName[]>;
|
|
@@ -495,6 +517,11 @@ declare function passthroughTextModel(model: TextModelInstance): CatalogModel;
|
|
|
495
517
|
/** Canonical token usage for a completed text call. Quantity is total tokens. */
|
|
496
518
|
declare function textUsageEvent(model: CatalogModel, provider: string, usage: LanguageModelUsage): UsageEvent;
|
|
497
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
|
+
};
|
|
498
525
|
interface ModelKit extends TextMethods {
|
|
499
526
|
catalog: Catalog;
|
|
500
527
|
/**
|
|
@@ -511,6 +538,11 @@ interface ModelKit extends TextMethods {
|
|
|
511
538
|
languageModel(modelId: string, call?: CallContext): LanguageModelHandle;
|
|
512
539
|
/** Generate music or a soundtrack. Blocks until the provider returns audio. */
|
|
513
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>>;
|
|
514
546
|
/**
|
|
515
547
|
* Prepare a video or document for a language model call (video understanding).
|
|
516
548
|
* Uses the provider file store when the payload is too large to inline.
|
|
@@ -597,4 +629,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
597
629
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
598
630
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
599
631
|
|
|
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 };
|
|
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,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;
|
|
@@ -268,7 +293,7 @@ interface UsageEvent {
|
|
|
268
293
|
reportedCostUsd?: number;
|
|
269
294
|
raw?: unknown;
|
|
270
295
|
}
|
|
271
|
-
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";
|
|
272
297
|
type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
273
298
|
/** Higgsfield needs the pair; both switch together. */
|
|
274
299
|
higgsfieldSecret?: string;
|
|
@@ -281,8 +306,8 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
|
281
306
|
};
|
|
282
307
|
};
|
|
283
308
|
interface Routing {
|
|
284
|
-
/** Text models: direct provider
|
|
285
|
-
text?: "direct" | "cloudflare"
|
|
309
|
+
/** Text models: direct provider or the Cloudflare AI Gateway. */
|
|
310
|
+
text?: "direct" | "cloudflare";
|
|
286
311
|
/** Anthropic chat via Bedrock (us. prefixed ids) or the Anthropic API. */
|
|
287
312
|
anthropic?: "direct" | "bedrock";
|
|
288
313
|
/** fal from geo-blocked regions goes through the Cloudflare passthrough. */
|
|
@@ -316,10 +341,6 @@ interface CallContext {
|
|
|
316
341
|
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. */
|
|
317
342
|
tier?: "pro" | "enterprise";
|
|
318
343
|
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
344
|
onUnsupported?: "error" | "coerce";
|
|
324
345
|
}
|
|
325
346
|
|
|
@@ -376,6 +397,7 @@ interface ResolveResult<T> {
|
|
|
376
397
|
declare function nearestAspectRatio(requested: AspectRatio, supported: AspectRatio[]): AspectRatio;
|
|
377
398
|
declare function resolveImageOptions(model: CatalogModel, request: ImageRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest>;
|
|
378
399
|
declare function resolveVideoOptions(model: CatalogModel, request: VideoRequest, onUnsupported?: OnUnsupported): ResolveResult<VideoRequest>;
|
|
400
|
+
declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<AudioRequest>;
|
|
379
401
|
|
|
380
402
|
/** Which key names an adapter needs. All of them must be set on a tier for that tier to win. */
|
|
381
403
|
declare const ADAPTER_KEYS: Record<AdapterId, ProviderKeyName[]>;
|
|
@@ -495,6 +517,11 @@ declare function passthroughTextModel(model: TextModelInstance): CatalogModel;
|
|
|
495
517
|
/** Canonical token usage for a completed text call. Quantity is total tokens. */
|
|
496
518
|
declare function textUsageEvent(model: CatalogModel, provider: string, usage: LanguageModelUsage): UsageEvent;
|
|
497
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
|
+
};
|
|
498
525
|
interface ModelKit extends TextMethods {
|
|
499
526
|
catalog: Catalog;
|
|
500
527
|
/**
|
|
@@ -511,6 +538,11 @@ interface ModelKit extends TextMethods {
|
|
|
511
538
|
languageModel(modelId: string, call?: CallContext): LanguageModelHandle;
|
|
512
539
|
/** Generate music or a soundtrack. Blocks until the provider returns audio. */
|
|
513
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>>;
|
|
514
546
|
/**
|
|
515
547
|
* Prepare a video or document for a language model call (video understanding).
|
|
516
548
|
* Uses the provider file store when the payload is too large to inline.
|
|
@@ -597,4 +629,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
597
629
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
598
630
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
599
631
|
|
|
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 };
|
|
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 };
|