@shop-os/modelkit 0.1.3 → 0.1.5
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 +42 -19
- package/dist/index.cjs +500 -339
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +500 -339
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -12,7 +12,7 @@ import { z } from 'zod';
|
|
|
12
12
|
/** The AI SDK video model spelling: a catalog id or a provider video model instance. */
|
|
13
13
|
type VideoModel = Parameters<typeof experimental_generateVideo>[0]["model"];
|
|
14
14
|
type AspectRatio = "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | "3:2" | "2:3" | "4:5" | "5:4" | "21:9" | "9:21" | "97:30" | "adaptive";
|
|
15
|
-
type ImageSize = "1K" | "2K" | "4K";
|
|
15
|
+
type ImageSize = "512" | "1K" | "2K" | "4K";
|
|
16
16
|
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";
|
|
@@ -26,6 +26,11 @@ type MediaRef = {
|
|
|
26
26
|
type ModelType = "text" | "image" | "video" | "audio" | "upscale" | "bg-remove";
|
|
27
27
|
type Lifecycle = "active" | "hidden" | "deprecated" | "retired";
|
|
28
28
|
type AdapterId = "ai-sdk-text" | "google-image" | "openai-image" | "google-genai" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "xai-video";
|
|
29
|
+
/** Gemini image safety threshold, per category, sent only when the caller opts in. */
|
|
30
|
+
type ImageSafetySetting = {
|
|
31
|
+
category: string;
|
|
32
|
+
threshold: string;
|
|
33
|
+
};
|
|
29
34
|
interface ImageRequest {
|
|
30
35
|
model: string;
|
|
31
36
|
prompt: string;
|
|
@@ -37,6 +42,10 @@ interface ImageRequest {
|
|
|
37
42
|
seed?: number;
|
|
38
43
|
count?: number;
|
|
39
44
|
outputFormat?: OutputFormat;
|
|
45
|
+
/** Upscale factor for upscaler rows; adapters map it to the provider's field. */
|
|
46
|
+
scaleFactor?: number;
|
|
47
|
+
/** Gemini image safety thresholds. Off (provider default) unless supplied. */
|
|
48
|
+
safetySettings?: ImageSafetySetting[];
|
|
40
49
|
}
|
|
41
50
|
/**
|
|
42
51
|
* What a caller passes to generateImage. Same field names as the AI SDK's
|
|
@@ -120,7 +129,7 @@ interface MediaPart {
|
|
|
120
129
|
cleanup?: () => Promise<void>;
|
|
121
130
|
}
|
|
122
131
|
type RequiredInput = "firstFrame" | "sourceVideo" | "references";
|
|
123
|
-
type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "instrumental";
|
|
132
|
+
type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "instrumental";
|
|
124
133
|
interface ReferenceLimits {
|
|
125
134
|
images?: number;
|
|
126
135
|
videos?: number;
|
|
@@ -208,6 +217,8 @@ interface ImageResult {
|
|
|
208
217
|
images: ImageBytes[];
|
|
209
218
|
usage: UsageEvent;
|
|
210
219
|
raw?: unknown;
|
|
220
|
+
/** The provider URL the images were downloaded from, when the provider hands one back. */
|
|
221
|
+
outputUrl?: string;
|
|
211
222
|
}
|
|
212
223
|
/** What generateImage returns: the adapter result plus `image`, SDK accessors and warnings. */
|
|
213
224
|
interface ImageCallResult extends ImageResult {
|
|
@@ -586,4 +597,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
586
597
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
587
598
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
588
599
|
|
|
589
|
-
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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { z } from 'zod';
|
|
|
12
12
|
/** The AI SDK video model spelling: a catalog id or a provider video model instance. */
|
|
13
13
|
type VideoModel = Parameters<typeof experimental_generateVideo>[0]["model"];
|
|
14
14
|
type AspectRatio = "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | "3:2" | "2:3" | "4:5" | "5:4" | "21:9" | "9:21" | "97:30" | "adaptive";
|
|
15
|
-
type ImageSize = "1K" | "2K" | "4K";
|
|
15
|
+
type ImageSize = "512" | "1K" | "2K" | "4K";
|
|
16
16
|
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";
|
|
@@ -26,6 +26,11 @@ type MediaRef = {
|
|
|
26
26
|
type ModelType = "text" | "image" | "video" | "audio" | "upscale" | "bg-remove";
|
|
27
27
|
type Lifecycle = "active" | "hidden" | "deprecated" | "retired";
|
|
28
28
|
type AdapterId = "ai-sdk-text" | "google-image" | "openai-image" | "google-genai" | "ark" | "fal" | "replicate" | "prodia" | "higgsfield" | "xai-video";
|
|
29
|
+
/** Gemini image safety threshold, per category, sent only when the caller opts in. */
|
|
30
|
+
type ImageSafetySetting = {
|
|
31
|
+
category: string;
|
|
32
|
+
threshold: string;
|
|
33
|
+
};
|
|
29
34
|
interface ImageRequest {
|
|
30
35
|
model: string;
|
|
31
36
|
prompt: string;
|
|
@@ -37,6 +42,10 @@ interface ImageRequest {
|
|
|
37
42
|
seed?: number;
|
|
38
43
|
count?: number;
|
|
39
44
|
outputFormat?: OutputFormat;
|
|
45
|
+
/** Upscale factor for upscaler rows; adapters map it to the provider's field. */
|
|
46
|
+
scaleFactor?: number;
|
|
47
|
+
/** Gemini image safety thresholds. Off (provider default) unless supplied. */
|
|
48
|
+
safetySettings?: ImageSafetySetting[];
|
|
40
49
|
}
|
|
41
50
|
/**
|
|
42
51
|
* What a caller passes to generateImage. Same field names as the AI SDK's
|
|
@@ -120,7 +129,7 @@ interface MediaPart {
|
|
|
120
129
|
cleanup?: () => Promise<void>;
|
|
121
130
|
}
|
|
122
131
|
type RequiredInput = "firstFrame" | "sourceVideo" | "references";
|
|
123
|
-
type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "instrumental";
|
|
132
|
+
type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "instrumental";
|
|
124
133
|
interface ReferenceLimits {
|
|
125
134
|
images?: number;
|
|
126
135
|
videos?: number;
|
|
@@ -208,6 +217,8 @@ interface ImageResult {
|
|
|
208
217
|
images: ImageBytes[];
|
|
209
218
|
usage: UsageEvent;
|
|
210
219
|
raw?: unknown;
|
|
220
|
+
/** The provider URL the images were downloaded from, when the provider hands one back. */
|
|
221
|
+
outputUrl?: string;
|
|
211
222
|
}
|
|
212
223
|
/** What generateImage returns: the adapter result plus `image`, SDK accessors and warnings. */
|
|
213
224
|
interface ImageCallResult extends ImageResult {
|
|
@@ -586,4 +597,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
586
597
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
587
598
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
588
599
|
|
|
589
|
-
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 };
|
|
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 };
|