@shop-os/modelkit 0.2.23 → 0.2.25
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/CHANGELOG.md +14 -0
- package/README.md +1 -1
- package/dist/catalog.cjs +26 -0
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +6 -3
- package/dist/catalog.d.ts +6 -3
- package/dist/catalog.js +26 -0
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +121 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -6
- package/dist/index.d.ts +12 -6
- package/dist/index.js +120 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -440,6 +440,8 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
|
440
440
|
}>;
|
|
441
441
|
};
|
|
442
442
|
};
|
|
443
|
+
/** Which key set a call uses. Enterprise falls back to pro; sloosh never falls back. */
|
|
444
|
+
type KeyTier = "pro" | "enterprise" | "sloosh";
|
|
443
445
|
/** Key names a call can require, including the Bedrock credentials object. */
|
|
444
446
|
type RequiredKeyName = ProviderKeyName | "aws";
|
|
445
447
|
/** True when region is set AND (apiKey OR credentialProvider OR both static keys). */
|
|
@@ -471,6 +473,7 @@ interface ModelKitConfig {
|
|
|
471
473
|
keys: {
|
|
472
474
|
pro: ProviderKeys;
|
|
473
475
|
enterprise?: ProviderKeys;
|
|
476
|
+
sloosh?: ProviderKeys;
|
|
474
477
|
};
|
|
475
478
|
routing?: Routing;
|
|
476
479
|
/** Provider base-url overrides; unset entries use each adapter's documented default. */
|
|
@@ -483,8 +486,8 @@ interface ModelKitConfig {
|
|
|
483
486
|
logger?: Pick<Console, "debug" | "info" | "warn" | "error">;
|
|
484
487
|
}
|
|
485
488
|
interface CallContext {
|
|
486
|
-
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. */
|
|
487
|
-
tier?:
|
|
489
|
+
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. "sloosh" uses keys.sloosh only and never falls back. */
|
|
490
|
+
tier?: KeyTier;
|
|
488
491
|
signal?: AbortSignal;
|
|
489
492
|
/** Media retries after the initial request. Set 0 when a durable host owns recovery.
|
|
490
493
|
* Unset preserves adapter defaults. Successful pending-job polls are not retries.
|
|
@@ -1036,12 +1039,15 @@ declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest,
|
|
|
1036
1039
|
|
|
1037
1040
|
/** Which key names an adapter needs. All of them must be set on a tier for that tier to win. */
|
|
1038
1041
|
declare const ADAPTER_KEYS: Record<AdapterId, ProviderKeyName[]>;
|
|
1042
|
+
/** The required names the given non-pro tier is missing. */
|
|
1043
|
+
declare function missingTierKeys(config: ModelKitConfig, tier: Exclude<KeyTier, "pro">, names: RequiredKeyName[]): RequiredKeyName[];
|
|
1039
1044
|
/**
|
|
1040
1045
|
* Enterprise wins only when every key the adapter needs is set on the
|
|
1041
1046
|
* enterprise tier; otherwise the pro keys are used. Mirrors trigger-workflows
|
|
1042
|
-
* enterprise-keys.ts, extended to Ark and Prodia.
|
|
1047
|
+
* enterprise-keys.ts, extended to Ark and Prodia. Sloosh never falls back:
|
|
1048
|
+
* a sloosh call with a missing key throws.
|
|
1043
1049
|
*/
|
|
1044
|
-
declare function resolveKeys(config: ModelKitConfig, names: RequiredKeyName[], tier?:
|
|
1050
|
+
declare function resolveKeys(config: ModelKitConfig, names: RequiredKeyName[], tier?: KeyTier): ProviderKeys;
|
|
1045
1051
|
/** Build a ProviderKeys map from env with the given prefix ("" for pro, "ENTERPRISE_" for enterprise). */
|
|
1046
1052
|
declare function keysFromEnv(env: NodeJS.ProcessEnv, prefix?: string): ProviderKeys;
|
|
1047
1053
|
|
|
@@ -1204,7 +1210,7 @@ declare const DEFAULT_ADAPTERS: Record<AdapterId, Adapter>;
|
|
|
1204
1210
|
|
|
1205
1211
|
/**
|
|
1206
1212
|
* All adapters registered. Keys default to process.env (pro = bare names,
|
|
1207
|
-
* enterprise = ENTERPRISE_ prefix) when `keys` is omitted.
|
|
1213
|
+
* enterprise = ENTERPRISE_ prefix, sloosh = SLOOSH_ prefix) when `keys` is omitted.
|
|
1208
1214
|
*/
|
|
1209
1215
|
declare function createDefaultModelKit(config?: Partial<ModelKitConfig>): ModelKit;
|
|
1210
1216
|
/**
|
|
@@ -1237,4 +1243,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
1237
1243
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
1238
1244
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
1239
1245
|
|
|
1240
|
-
export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type GeneratedImage, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, 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 PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, withRetry, xaiVideoAdapter };
|
|
1246
|
+
export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type GeneratedImage, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, 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 PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, withRetry, xaiVideoAdapter };
|
package/dist/index.d.ts
CHANGED
|
@@ -440,6 +440,8 @@ type ProviderKeys = Partial<Record<ProviderKeyName, string>> & {
|
|
|
440
440
|
}>;
|
|
441
441
|
};
|
|
442
442
|
};
|
|
443
|
+
/** Which key set a call uses. Enterprise falls back to pro; sloosh never falls back. */
|
|
444
|
+
type KeyTier = "pro" | "enterprise" | "sloosh";
|
|
443
445
|
/** Key names a call can require, including the Bedrock credentials object. */
|
|
444
446
|
type RequiredKeyName = ProviderKeyName | "aws";
|
|
445
447
|
/** True when region is set AND (apiKey OR credentialProvider OR both static keys). */
|
|
@@ -471,6 +473,7 @@ interface ModelKitConfig {
|
|
|
471
473
|
keys: {
|
|
472
474
|
pro: ProviderKeys;
|
|
473
475
|
enterprise?: ProviderKeys;
|
|
476
|
+
sloosh?: ProviderKeys;
|
|
474
477
|
};
|
|
475
478
|
routing?: Routing;
|
|
476
479
|
/** Provider base-url overrides; unset entries use each adapter's documented default. */
|
|
@@ -483,8 +486,8 @@ interface ModelKitConfig {
|
|
|
483
486
|
logger?: Pick<Console, "debug" | "info" | "warn" | "error">;
|
|
484
487
|
}
|
|
485
488
|
interface CallContext {
|
|
486
|
-
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. */
|
|
487
|
-
tier?:
|
|
489
|
+
/** "enterprise" picks keys.enterprise when every key for the provider is set, else falls back to pro. "sloosh" uses keys.sloosh only and never falls back. */
|
|
490
|
+
tier?: KeyTier;
|
|
488
491
|
signal?: AbortSignal;
|
|
489
492
|
/** Media retries after the initial request. Set 0 when a durable host owns recovery.
|
|
490
493
|
* Unset preserves adapter defaults. Successful pending-job polls are not retries.
|
|
@@ -1036,12 +1039,15 @@ declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest,
|
|
|
1036
1039
|
|
|
1037
1040
|
/** Which key names an adapter needs. All of them must be set on a tier for that tier to win. */
|
|
1038
1041
|
declare const ADAPTER_KEYS: Record<AdapterId, ProviderKeyName[]>;
|
|
1042
|
+
/** The required names the given non-pro tier is missing. */
|
|
1043
|
+
declare function missingTierKeys(config: ModelKitConfig, tier: Exclude<KeyTier, "pro">, names: RequiredKeyName[]): RequiredKeyName[];
|
|
1039
1044
|
/**
|
|
1040
1045
|
* Enterprise wins only when every key the adapter needs is set on the
|
|
1041
1046
|
* enterprise tier; otherwise the pro keys are used. Mirrors trigger-workflows
|
|
1042
|
-
* enterprise-keys.ts, extended to Ark and Prodia.
|
|
1047
|
+
* enterprise-keys.ts, extended to Ark and Prodia. Sloosh never falls back:
|
|
1048
|
+
* a sloosh call with a missing key throws.
|
|
1043
1049
|
*/
|
|
1044
|
-
declare function resolveKeys(config: ModelKitConfig, names: RequiredKeyName[], tier?:
|
|
1050
|
+
declare function resolveKeys(config: ModelKitConfig, names: RequiredKeyName[], tier?: KeyTier): ProviderKeys;
|
|
1045
1051
|
/** Build a ProviderKeys map from env with the given prefix ("" for pro, "ENTERPRISE_" for enterprise). */
|
|
1046
1052
|
declare function keysFromEnv(env: NodeJS.ProcessEnv, prefix?: string): ProviderKeys;
|
|
1047
1053
|
|
|
@@ -1204,7 +1210,7 @@ declare const DEFAULT_ADAPTERS: Record<AdapterId, Adapter>;
|
|
|
1204
1210
|
|
|
1205
1211
|
/**
|
|
1206
1212
|
* All adapters registered. Keys default to process.env (pro = bare names,
|
|
1207
|
-
* enterprise = ENTERPRISE_ prefix) when `keys` is omitted.
|
|
1213
|
+
* enterprise = ENTERPRISE_ prefix, sloosh = SLOOSH_ prefix) when `keys` is omitted.
|
|
1208
1214
|
*/
|
|
1209
1215
|
declare function createDefaultModelKit(config?: Partial<ModelKitConfig>): ModelKit;
|
|
1210
1216
|
/**
|
|
@@ -1237,4 +1243,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
1237
1243
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
1238
1244
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
1239
1245
|
|
|
1240
|
-
export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type GeneratedImage, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, 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 PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, withRetry, xaiVideoAdapter };
|
|
1246
|
+
export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type GeneratedImage, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, 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 PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, withRetry, xaiVideoAdapter };
|
package/dist/index.js
CHANGED
|
@@ -396,6 +396,32 @@ var IMAGE_MODELS = [
|
|
|
396
396
|
logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/characters/1787909065794-k9a7zz.png"
|
|
397
397
|
}
|
|
398
398
|
},
|
|
399
|
+
{
|
|
400
|
+
// References switch to the edit endpoint: the first is the image to edit,
|
|
401
|
+
// the rest (up to 4) guide it.
|
|
402
|
+
id: "ideogram-4.5",
|
|
403
|
+
aliases: [],
|
|
404
|
+
label: "Ideogram 4.5",
|
|
405
|
+
type: "image",
|
|
406
|
+
adapter: "fal",
|
|
407
|
+
providerModelId: "ideogram/v4.5",
|
|
408
|
+
lifecycle: "active",
|
|
409
|
+
exposure: ["cowork", "space_builder"],
|
|
410
|
+
constraints: {
|
|
411
|
+
aspectRatios: ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "5:4", "4:5"],
|
|
412
|
+
sizes: ["1K", "2K"],
|
|
413
|
+
qualityOptions: ["auto", "low", "medium", "high"],
|
|
414
|
+
references: { images: 5 },
|
|
415
|
+
supports: ["quality", "count", "seed"]
|
|
416
|
+
},
|
|
417
|
+
defaults: { size: "2K", aspectRatio: "1:1", quality: "medium", count: 1 },
|
|
418
|
+
usage: { ...IMAGE_USAGE, slug: "ideogram" },
|
|
419
|
+
pricingKind: "image_size",
|
|
420
|
+
display: {
|
|
421
|
+
provider: "ideogram",
|
|
422
|
+
description: "Ideogram's precise edit model: repeated edits keep the untouched pixels and colours intact, at the source's native resolution. Also generates from text."
|
|
423
|
+
}
|
|
424
|
+
},
|
|
399
425
|
{
|
|
400
426
|
id: "seedream-5-0-pro",
|
|
401
427
|
aliases: ["seedream-4-5"],
|
|
@@ -3585,6 +3611,7 @@ function createFalAdapter(deps = defaultDeps) {
|
|
|
3585
3611
|
id: "fal",
|
|
3586
3612
|
generateImage: (req, ctx) => {
|
|
3587
3613
|
throwIfAborted(ctx.signal);
|
|
3614
|
+
if (isIdeogram(ctx.model.providerModelId)) return generateIdeogramImage(req, ctx, deps);
|
|
3588
3615
|
return generateMuseImage(req, ctx, deps);
|
|
3589
3616
|
},
|
|
3590
3617
|
generateVideo: (req, ctx) => {
|
|
@@ -3841,6 +3868,72 @@ async function generateMuseImage(req, ctx, deps) {
|
|
|
3841
3868
|
raw: payload
|
|
3842
3869
|
};
|
|
3843
3870
|
}
|
|
3871
|
+
var IDEOGRAM_MODEL_IDS = /* @__PURE__ */ new Set(["ideogram/v4.5"]);
|
|
3872
|
+
function isIdeogram(providerModelId) {
|
|
3873
|
+
return IDEOGRAM_MODEL_IDS.has(providerModelId.toLowerCase());
|
|
3874
|
+
}
|
|
3875
|
+
var IDEOGRAM_SIZES = {
|
|
3876
|
+
"1:1": { "1K": "1024x1024", "2K": "2048x2048" },
|
|
3877
|
+
"16:9": { "1K": "1280x720", "2K": "2560x1440" },
|
|
3878
|
+
"9:16": { "1K": "720x1280", "2K": "1440x2560" },
|
|
3879
|
+
"4:3": { "1K": "1152x864", "2K": "2304x1728" },
|
|
3880
|
+
"3:4": { "1K": "864x1152", "2K": "1728x2304" },
|
|
3881
|
+
"3:2": { "1K": "1248x832", "2K": "2496x1664" },
|
|
3882
|
+
"2:3": { "1K": "832x1248", "2K": "1664x2496" },
|
|
3883
|
+
"5:4": { "1K": "1120x896", "2K": "2240x1792" },
|
|
3884
|
+
"4:5": { "1K": "896x1120", "2K": "1792x2240" }
|
|
3885
|
+
};
|
|
3886
|
+
function parseExactSize(value) {
|
|
3887
|
+
const match = /^(\d+)x(\d+)$/.exec(value ?? "");
|
|
3888
|
+
return match ? { width: Number(match[1]), height: Number(match[2]) } : void 0;
|
|
3889
|
+
}
|
|
3890
|
+
function ideogramImageSize(req) {
|
|
3891
|
+
const exact = parseExactSize(req.exactSize);
|
|
3892
|
+
if (exact) return exact;
|
|
3893
|
+
if (req.aspectRatio === void 0 || req.aspectRatio === "adaptive") return void 0;
|
|
3894
|
+
return parseExactSize(IDEOGRAM_SIZES[req.aspectRatio]?.[req.size === "1K" ? "1K" : "2K"]);
|
|
3895
|
+
}
|
|
3896
|
+
async function generateIdeogramImage(req, ctx, deps) {
|
|
3897
|
+
const [source, ...references] = (req.references ?? []).map(refToUrl);
|
|
3898
|
+
const input = { prompt: req.prompt, num_images: req.count ?? 1 };
|
|
3899
|
+
if (req.quality !== void 0 && req.quality !== "auto") input.quality = req.quality;
|
|
3900
|
+
if (req.seed !== void 0) input.seed = req.seed;
|
|
3901
|
+
const id = ctx.model.providerModelId;
|
|
3902
|
+
let endpoint = id;
|
|
3903
|
+
if (source === void 0) {
|
|
3904
|
+
input.enable_prompt_expansion = false;
|
|
3905
|
+
const size = ideogramImageSize(req);
|
|
3906
|
+
if (size) input.image_size = size;
|
|
3907
|
+
} else {
|
|
3908
|
+
endpoint = `${id}/edit`;
|
|
3909
|
+
input.image_url = source;
|
|
3910
|
+
input.edit_precision = "high";
|
|
3911
|
+
if (references.length > 0) input.reference_image_urls = references;
|
|
3912
|
+
}
|
|
3913
|
+
const payload = await runJob(ctx, deps, endpoint, input);
|
|
3914
|
+
const parsed = museImageResultSchema.safeParse(payload);
|
|
3915
|
+
const images = parsed.success ? parsed.data.images ?? [] : [];
|
|
3916
|
+
const files = await Promise.all(
|
|
3917
|
+
images.flatMap((img) => {
|
|
3918
|
+
if (img.url === void 0) return [];
|
|
3919
|
+
return [decodeImage(ctx, img.url, img.content_type ?? void 0)];
|
|
3920
|
+
})
|
|
3921
|
+
);
|
|
3922
|
+
if (files.length === 0) {
|
|
3923
|
+
throw new ModelKitError({
|
|
3924
|
+
code: "provider_rejected",
|
|
3925
|
+
message: "fal Ideogram returned no image",
|
|
3926
|
+
provider: "fal",
|
|
3927
|
+
model: ctx.model.id,
|
|
3928
|
+
retryable: false
|
|
3929
|
+
});
|
|
3930
|
+
}
|
|
3931
|
+
return {
|
|
3932
|
+
images: files.map((f) => ({ bytes: f.bytes, mime: f.mime })),
|
|
3933
|
+
usage: imageUsage(ctx, req, files.length),
|
|
3934
|
+
raw: payload
|
|
3935
|
+
};
|
|
3936
|
+
}
|
|
3844
3937
|
var H3_MAX_MODEL_IDS = /* @__PURE__ */ new Set([
|
|
3845
3938
|
"minimax/h3-max",
|
|
3846
3939
|
"minimax/h3-max/reference-to-video"
|
|
@@ -7894,10 +7987,22 @@ function hasAll(keys, names) {
|
|
|
7894
7987
|
function hasKey(keys, name) {
|
|
7895
7988
|
return hasAll(keys, [name]);
|
|
7896
7989
|
}
|
|
7990
|
+
function missingTierKeys(config, tier, names) {
|
|
7991
|
+
return names.filter((name) => !hasAll(config.keys[tier], [name]));
|
|
7992
|
+
}
|
|
7897
7993
|
function missingEnterpriseKeys(config, names) {
|
|
7898
|
-
return
|
|
7994
|
+
return missingTierKeys(config, "enterprise", names);
|
|
7899
7995
|
}
|
|
7900
7996
|
function resolveKeys(config, names, tier = "pro") {
|
|
7997
|
+
if (tier === "sloosh") {
|
|
7998
|
+
if (names.length === 0) return config.keys.sloosh ?? {};
|
|
7999
|
+
if (hasAll(config.keys.sloosh, names)) return config.keys.sloosh;
|
|
8000
|
+
throw new ModelKitError({
|
|
8001
|
+
code: "auth",
|
|
8002
|
+
message: `Missing Sloosh API key for ${names.join(", ")}`,
|
|
8003
|
+
retryable: false
|
|
8004
|
+
});
|
|
8005
|
+
}
|
|
7901
8006
|
if (tier === "enterprise" && hasAll(config.keys.enterprise, names))
|
|
7902
8007
|
return config.keys.enterprise;
|
|
7903
8008
|
if (names.length > 0 && !hasAll(config.keys.pro, names)) {
|
|
@@ -8093,6 +8198,7 @@ function resolveAnthropicTransport(model, config, tier, warn) {
|
|
|
8093
8198
|
const preferred = preferredAnthropicTransport(model, config.routing ?? {});
|
|
8094
8199
|
const usable = (transport) => {
|
|
8095
8200
|
const name = transport === "bedrock" ? "aws" : "anthropic";
|
|
8201
|
+
if (tier === "sloosh") return hasKey(config.keys.sloosh, name);
|
|
8096
8202
|
return hasKey(config.keys.pro, name) || tier === "enterprise" && hasKey(config.keys.enterprise, name);
|
|
8097
8203
|
};
|
|
8098
8204
|
if (usable(preferred)) return preferred;
|
|
@@ -8674,11 +8780,19 @@ function createModelKit(config, adapters) {
|
|
|
8674
8780
|
}
|
|
8675
8781
|
|
|
8676
8782
|
// src/default.ts
|
|
8783
|
+
function withSharedAws(keys) {
|
|
8784
|
+
const { pro, sloosh } = keys;
|
|
8785
|
+
if (!sloosh || sloosh.aws || !pro.aws) return keys;
|
|
8786
|
+
return { ...keys, sloosh: { ...sloosh, aws: pro.aws } };
|
|
8787
|
+
}
|
|
8677
8788
|
function createDefaultModelKit(config = {}) {
|
|
8678
|
-
const keys =
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8789
|
+
const keys = withSharedAws(
|
|
8790
|
+
config.keys ?? {
|
|
8791
|
+
pro: keysFromEnv(process.env),
|
|
8792
|
+
enterprise: keysFromEnv(process.env, "ENTERPRISE_"),
|
|
8793
|
+
sloosh: keysFromEnv(process.env, "SLOOSH_")
|
|
8794
|
+
}
|
|
8795
|
+
);
|
|
8682
8796
|
return createModelKit({ ...config, keys }, DEFAULT_ADAPTERS);
|
|
8683
8797
|
}
|
|
8684
8798
|
var generateText2 = (options, call) => createDefaultModelKit().generateText(options, call);
|
|
@@ -8742,6 +8856,7 @@ export {
|
|
|
8742
8856
|
liveCatalog,
|
|
8743
8857
|
liveState,
|
|
8744
8858
|
mergeTextProviderOptions,
|
|
8859
|
+
missingTierKeys,
|
|
8745
8860
|
nearestAspectRatio,
|
|
8746
8861
|
normalizeExposure,
|
|
8747
8862
|
openaiImageAdapter,
|