@shop-os/modelkit 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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";
@@ -37,6 +37,8 @@ interface ImageRequest {
37
37
  seed?: number;
38
38
  count?: number;
39
39
  outputFormat?: OutputFormat;
40
+ /** Upscale factor for upscaler rows; adapters map it to the provider's field. */
41
+ scaleFactor?: number;
40
42
  }
41
43
  /**
42
44
  * What a caller passes to generateImage. Same field names as the AI SDK's
@@ -120,7 +122,7 @@ interface MediaPart {
120
122
  cleanup?: () => Promise<void>;
121
123
  }
122
124
  type RequiredInput = "firstFrame" | "sourceVideo" | "references";
123
- type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "instrumental";
125
+ type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "instrumental";
124
126
  interface ReferenceLimits {
125
127
  images?: number;
126
128
  videos?: number;
@@ -208,6 +210,8 @@ interface ImageResult {
208
210
  images: ImageBytes[];
209
211
  usage: UsageEvent;
210
212
  raw?: unknown;
213
+ /** The provider URL the images were downloaded from, when the provider hands one back. */
214
+ outputUrl?: string;
211
215
  }
212
216
  /** What generateImage returns: the adapter result plus `image`, SDK accessors and warnings. */
213
217
  interface ImageCallResult extends ImageResult {
@@ -281,12 +285,19 @@ interface Routing {
281
285
  gatewayId: string;
282
286
  };
283
287
  }
288
+ /** Regional or proxy endpoints for providers whose base url is configurable. */
289
+ interface AdapterEndpoints {
290
+ /** Ark (Seedream images, Seedance videos). Defaults to the BytePlus ap-southeast endpoint. */
291
+ ark?: string;
292
+ }
284
293
  interface ModelKitConfig {
285
294
  keys: {
286
295
  pro: ProviderKeys;
287
296
  enterprise?: ProviderKeys;
288
297
  };
289
298
  routing?: Routing;
299
+ /** Provider base-url overrides; unset entries use each adapter's documented default. */
300
+ endpoints?: AdapterEndpoints;
290
301
  /** Called once per completed provider call. */
291
302
  onUsage?: (event: UsageEvent) => void | Promise<void>;
292
303
  /** Extra or replacement catalog rows, merged by id. */
@@ -400,6 +411,7 @@ interface AdapterContext {
400
411
  model: CatalogModel;
401
412
  keys: ProviderKeys;
402
413
  routing: Routing;
414
+ endpoints?: AdapterEndpoints;
403
415
  fetch: typeof fetch;
404
416
  logger: Pick<Console, "debug" | "info" | "warn" | "error">;
405
417
  signal?: AbortSignal;
@@ -578,4 +590,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
578
590
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
579
591
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
580
592
 
581
- export { ADAPTER_KEYS, type Adapter, type AdapterContext, 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 };
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 };
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";
@@ -37,6 +37,8 @@ interface ImageRequest {
37
37
  seed?: number;
38
38
  count?: number;
39
39
  outputFormat?: OutputFormat;
40
+ /** Upscale factor for upscaler rows; adapters map it to the provider's field. */
41
+ scaleFactor?: number;
40
42
  }
41
43
  /**
42
44
  * What a caller passes to generateImage. Same field names as the AI SDK's
@@ -120,7 +122,7 @@ interface MediaPart {
120
122
  cleanup?: () => Promise<void>;
121
123
  }
122
124
  type RequiredInput = "firstFrame" | "sourceVideo" | "references";
123
- type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "instrumental";
125
+ type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "instrumental";
124
126
  interface ReferenceLimits {
125
127
  images?: number;
126
128
  videos?: number;
@@ -208,6 +210,8 @@ interface ImageResult {
208
210
  images: ImageBytes[];
209
211
  usage: UsageEvent;
210
212
  raw?: unknown;
213
+ /** The provider URL the images were downloaded from, when the provider hands one back. */
214
+ outputUrl?: string;
211
215
  }
212
216
  /** What generateImage returns: the adapter result plus `image`, SDK accessors and warnings. */
213
217
  interface ImageCallResult extends ImageResult {
@@ -281,12 +285,19 @@ interface Routing {
281
285
  gatewayId: string;
282
286
  };
283
287
  }
288
+ /** Regional or proxy endpoints for providers whose base url is configurable. */
289
+ interface AdapterEndpoints {
290
+ /** Ark (Seedream images, Seedance videos). Defaults to the BytePlus ap-southeast endpoint. */
291
+ ark?: string;
292
+ }
284
293
  interface ModelKitConfig {
285
294
  keys: {
286
295
  pro: ProviderKeys;
287
296
  enterprise?: ProviderKeys;
288
297
  };
289
298
  routing?: Routing;
299
+ /** Provider base-url overrides; unset entries use each adapter's documented default. */
300
+ endpoints?: AdapterEndpoints;
290
301
  /** Called once per completed provider call. */
291
302
  onUsage?: (event: UsageEvent) => void | Promise<void>;
292
303
  /** Extra or replacement catalog rows, merged by id. */
@@ -400,6 +411,7 @@ interface AdapterContext {
400
411
  model: CatalogModel;
401
412
  keys: ProviderKeys;
402
413
  routing: Routing;
414
+ endpoints?: AdapterEndpoints;
403
415
  fetch: typeof fetch;
404
416
  logger: Pick<Console, "debug" | "info" | "warn" | "error">;
405
417
  signal?: AbortSignal;
@@ -578,4 +590,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
578
590
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
579
591
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
580
592
 
581
- export { ADAPTER_KEYS, type Adapter, type AdapterContext, 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 };
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 };