@shop-os/modelkit 0.20.0 → 0.21.1

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
@@ -856,7 +856,25 @@ interface ModelConstraints {
856
856
  audio?: AudioOutput;
857
857
  /** Prompt conventions. Read them through `promptConventions(row)`, which fills the default. */
858
858
  prompt?: PromptConventions;
859
+ /**
860
+ * Video rows whose provider bills what the request sends (input video, reference images)
861
+ * on top of what it renders. Read it through `inputBillingOf(row)`, which also covers
862
+ * Seedance (`ark`) rows and data-only rows. Kits before 0.21.0 ignore it.
863
+ */
864
+ inputBilling?: InputBilling;
859
865
  }
866
+ /**
867
+ * How a provider bills a request's inputs. The apps own the rates; this names the rule.
868
+ * - `seedance`: input plus output seconds at the row's video-input rate.
869
+ * - `omni`: input video as input tokens, billed as equivalent output seconds.
870
+ * - `h3-max-reference`: reference image, video and audio tokens past a shared allowance.
871
+ * - `h3-reference`: a fee for each reference image past the fifth.
872
+ * - `grok-input-image`: a fee for each input image, frames included.
873
+ * - `source-video-rate`: the output alone, at the row's video-input rate.
874
+ * - `kling-v4`: output plus max(input, output) seconds at the row's video-input rate.
875
+ * - `input-plus-output`: input plus output seconds at the row's base rate.
876
+ */
877
+ type InputBilling = "seedance" | "omni" | "h3-max-reference" | "h3-reference" | "grok-input-image" | "source-video-rate" | "kling-v4" | "input-plus-output";
860
878
  /** JSON-compatible value. Provider options and raw payloads carry these, never `unknown`. */
861
879
  type JsonPrimitive = string | number | boolean | null;
862
880
  type JsonValue = JsonPrimitive | JsonValue[] | {
@@ -1590,6 +1608,7 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
1590
1608
  }, z.core.$loose>>;
1591
1609
  }, z.core.$loose>>;
1592
1610
  audio: z.ZodOptional<z.ZodUnknown>;
1611
+ inputBilling: z.ZodOptional<z.ZodUnknown>;
1593
1612
  prompt: z.ZodOptional<z.ZodUnknown>;
1594
1613
  }, z.core.$loose>;
1595
1614
  defaults: z.ZodObject<{
@@ -2021,6 +2040,19 @@ declare function resetLiveCatalog(): void;
2021
2040
 
2022
2041
  declare function fileCatalogCache(path: string): CatalogCache;
2023
2042
 
2043
+ /**
2044
+ * The input-billing rule of a row, or null when the provider bills only what it renders. The
2045
+ * row's own `constraints.inputBilling` wins. A live row an older seed wrote, without the field,
2046
+ * takes the kit row of the same id; an `ark` (Seedance) row is `seedance`.
2047
+ */
2048
+ declare function inputBillingOf(row: {
2049
+ id: string;
2050
+ adapter: string;
2051
+ constraints?: unknown;
2052
+ }): InputBilling | null;
2053
+
2054
+ declare const INPUT_BILLINGS: ("seedance" | "omni" | "h3-max-reference" | "h3-reference" | "grok-input-image" | "source-video-rate" | "kling-v4" | "input-plus-output")[];
2055
+
2024
2056
  type OnUnsupported = "error" | "coerce";
2025
2057
  interface ResolveResult<T> {
2026
2058
  request: T;
@@ -2227,6 +2259,12 @@ interface RetryOptions {
2227
2259
  maxDelayMs?: number;
2228
2260
  factor?: number;
2229
2261
  signal?: AbortSignal;
2262
+ /** A separate, jittered schedule and budget for `rate_limited` errors; other errors keep the one above. */
2263
+ rateLimited?: {
2264
+ attempts: number;
2265
+ baseDelayMs: number;
2266
+ maxDelayMs: number;
2267
+ };
2230
2268
  }
2231
2269
  declare function withRetry<T>(fn: (attempt: number) => Promise<T>, opts?: RetryOptions): Promise<T>;
2232
2270
  declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
@@ -2581,4 +2619,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
2581
2619
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
2582
2620
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
2583
2621
 
2584
- export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AnimationFrameSize, type AnimationLimits, type ArrayInputSpecKey, type AspectLimits, type AspectRatio, type AudioNodeMethods, type AudioOutput, type AudioRequest, type AudioResult, BYOK_PROVIDERS, type ByokField, type ByokFieldId, type ByokProvider, type ByokProviderId, type ByokSecret, type ByokTestResult, 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 DubbingOutcome, type DubbingRequest, type DubbingResult, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageAnimation, type ImageBackground, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImagePixelLimits, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecDimensions, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeySource, type KeyTier, type LanguageModelHandle, type LanguageOption, type Lifecycle, type LipsyncRequest, type LipsyncResult, type LiveCatalogState, MODEL3D_IMAGE_SLOTS, MODEL3D_MODELS, MODELS, type MaskBox, type MaskPoint, type MediaJobCallContext, type MediaNodeDefaults, type MediaOutput, type MediaPart, type MediaRef, type Model3dCall, type Model3dConstraints, type Model3dEndpoints, type Model3dFamily, type Model3dInputRefusal, type Model3dPricedInputs, type Model3dPricedOptions, type Model3dRequest, type Model3dResult, type Model3dStatus, type Model3dSubmission, type Model3dTexture, type Model3dViews, type Model3dWired, 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, REFERENCE_VIDEO_CONFORM_PROFILE, type ReferenceImageConformPlan, type ReferenceImageConformReason, type ReferenceImageProbe, type ReferenceLimits, type ReferenceSyntax, type ReferenceVideoConformPlan, type ReferenceVideoConformReason, type ReferenceVideoProbe, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SpeechRequest, type SubtitleOptions, type SubtitleTextStyle, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type TranscriptWord, type TranscriptionRequest, type TranscriptionResult, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoFpsLimits, type VideoJob, type VideoModel, type VideoPixelLimits, type VideoRequest, type VideoResolution, VideoResolutionSchema, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type VoiceCandidate, type VoiceChangeRequest, type VoiceCloneRequest, type VoiceCloneResult, type VoiceCloneState, type VoiceDeleteRequest, type VoiceDesignRequest, type VoiceDesignResult, type VoiceGender, type VoiceOption, type VoiceSample, type Warning, adapterServesType, aiSdkTextAdapter, alibabaAdapter, animationTier, arkAdapter, aspectRatioToSize, byokProviderForModel, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, elevenLabsAdapter, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, fishAdapter, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, imageOutputFormats, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keyOverrideFor, keysFromEnv, languageModel, liveCatalog, liveState, lumaAdapter, lumaReframeTooTall, mergeTextProviderOptions, missingTierKeys, model3dCall, model3dConstraints, model3dInputRefusal, model3dPricingSku, model3dResolution, model3dSeedFits, model3dSkus, model3dTexture, modelsPoweredBy, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, referenceImageConformPlan, referenceVideoConformPlan, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveDubbingOptions, resolveImageOptions, resolveKeys, resolveLipsyncOptions, resolveSpeechOptions, resolveTranscriptionOptions, resolveVideoOptions, resolveVoiceChangeOptions, resolveVoiceCloneOptions, resolveVoiceDesignOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, takesTargetAspectRatio, testProviderKey, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoSizeViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
2622
+ export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AnimationFrameSize, type AnimationLimits, type ArrayInputSpecKey, type AspectLimits, type AspectRatio, type AudioNodeMethods, type AudioOutput, type AudioRequest, type AudioResult, BYOK_PROVIDERS, type ByokField, type ByokFieldId, type ByokProvider, type ByokProviderId, type ByokSecret, type ByokTestResult, 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 DubbingOutcome, type DubbingRequest, type DubbingResult, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_BILLINGS, INPUT_SPEC_SUPPORTS_KEYS, type ImageAnimation, type ImageBackground, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImagePixelLimits, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputBilling, type InputSpec, type InputSpecDimensions, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeySource, type KeyTier, type LanguageModelHandle, type LanguageOption, type Lifecycle, type LipsyncRequest, type LipsyncResult, type LiveCatalogState, MODEL3D_IMAGE_SLOTS, MODEL3D_MODELS, MODELS, type MaskBox, type MaskPoint, type MediaJobCallContext, type MediaNodeDefaults, type MediaOutput, type MediaPart, type MediaRef, type Model3dCall, type Model3dConstraints, type Model3dEndpoints, type Model3dFamily, type Model3dInputRefusal, type Model3dPricedInputs, type Model3dPricedOptions, type Model3dRequest, type Model3dResult, type Model3dStatus, type Model3dSubmission, type Model3dTexture, type Model3dViews, type Model3dWired, 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, REFERENCE_VIDEO_CONFORM_PROFILE, type ReferenceImageConformPlan, type ReferenceImageConformReason, type ReferenceImageProbe, type ReferenceLimits, type ReferenceSyntax, type ReferenceVideoConformPlan, type ReferenceVideoConformReason, type ReferenceVideoProbe, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SpeechRequest, type SubtitleOptions, type SubtitleTextStyle, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type TranscriptWord, type TranscriptionRequest, type TranscriptionResult, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoFpsLimits, type VideoJob, type VideoModel, type VideoPixelLimits, type VideoRequest, type VideoResolution, VideoResolutionSchema, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type VoiceCandidate, type VoiceChangeRequest, type VoiceCloneRequest, type VoiceCloneResult, type VoiceCloneState, type VoiceDeleteRequest, type VoiceDesignRequest, type VoiceDesignResult, type VoiceGender, type VoiceOption, type VoiceSample, type Warning, adapterServesType, aiSdkTextAdapter, alibabaAdapter, animationTier, arkAdapter, aspectRatioToSize, byokProviderForModel, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, elevenLabsAdapter, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, fishAdapter, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, imageOutputFormats, inputBillingOf, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keyOverrideFor, keysFromEnv, languageModel, liveCatalog, liveState, lumaAdapter, lumaReframeTooTall, mergeTextProviderOptions, missingTierKeys, model3dCall, model3dConstraints, model3dInputRefusal, model3dPricingSku, model3dResolution, model3dSeedFits, model3dSkus, model3dTexture, modelsPoweredBy, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, referenceImageConformPlan, referenceVideoConformPlan, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveDubbingOptions, resolveImageOptions, resolveKeys, resolveLipsyncOptions, resolveSpeechOptions, resolveTranscriptionOptions, resolveVideoOptions, resolveVoiceChangeOptions, resolveVoiceCloneOptions, resolveVoiceDesignOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, takesTargetAspectRatio, testProviderKey, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoSizeViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
package/dist/index.d.ts CHANGED
@@ -856,7 +856,25 @@ interface ModelConstraints {
856
856
  audio?: AudioOutput;
857
857
  /** Prompt conventions. Read them through `promptConventions(row)`, which fills the default. */
858
858
  prompt?: PromptConventions;
859
+ /**
860
+ * Video rows whose provider bills what the request sends (input video, reference images)
861
+ * on top of what it renders. Read it through `inputBillingOf(row)`, which also covers
862
+ * Seedance (`ark`) rows and data-only rows. Kits before 0.21.0 ignore it.
863
+ */
864
+ inputBilling?: InputBilling;
859
865
  }
866
+ /**
867
+ * How a provider bills a request's inputs. The apps own the rates; this names the rule.
868
+ * - `seedance`: input plus output seconds at the row's video-input rate.
869
+ * - `omni`: input video as input tokens, billed as equivalent output seconds.
870
+ * - `h3-max-reference`: reference image, video and audio tokens past a shared allowance.
871
+ * - `h3-reference`: a fee for each reference image past the fifth.
872
+ * - `grok-input-image`: a fee for each input image, frames included.
873
+ * - `source-video-rate`: the output alone, at the row's video-input rate.
874
+ * - `kling-v4`: output plus max(input, output) seconds at the row's video-input rate.
875
+ * - `input-plus-output`: input plus output seconds at the row's base rate.
876
+ */
877
+ type InputBilling = "seedance" | "omni" | "h3-max-reference" | "h3-reference" | "grok-input-image" | "source-video-rate" | "kling-v4" | "input-plus-output";
860
878
  /** JSON-compatible value. Provider options and raw payloads carry these, never `unknown`. */
861
879
  type JsonPrimitive = string | number | boolean | null;
862
880
  type JsonValue = JsonPrimitive | JsonValue[] | {
@@ -1590,6 +1608,7 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
1590
1608
  }, z.core.$loose>>;
1591
1609
  }, z.core.$loose>>;
1592
1610
  audio: z.ZodOptional<z.ZodUnknown>;
1611
+ inputBilling: z.ZodOptional<z.ZodUnknown>;
1593
1612
  prompt: z.ZodOptional<z.ZodUnknown>;
1594
1613
  }, z.core.$loose>;
1595
1614
  defaults: z.ZodObject<{
@@ -2021,6 +2040,19 @@ declare function resetLiveCatalog(): void;
2021
2040
 
2022
2041
  declare function fileCatalogCache(path: string): CatalogCache;
2023
2042
 
2043
+ /**
2044
+ * The input-billing rule of a row, or null when the provider bills only what it renders. The
2045
+ * row's own `constraints.inputBilling` wins. A live row an older seed wrote, without the field,
2046
+ * takes the kit row of the same id; an `ark` (Seedance) row is `seedance`.
2047
+ */
2048
+ declare function inputBillingOf(row: {
2049
+ id: string;
2050
+ adapter: string;
2051
+ constraints?: unknown;
2052
+ }): InputBilling | null;
2053
+
2054
+ declare const INPUT_BILLINGS: ("seedance" | "omni" | "h3-max-reference" | "h3-reference" | "grok-input-image" | "source-video-rate" | "kling-v4" | "input-plus-output")[];
2055
+
2024
2056
  type OnUnsupported = "error" | "coerce";
2025
2057
  interface ResolveResult<T> {
2026
2058
  request: T;
@@ -2227,6 +2259,12 @@ interface RetryOptions {
2227
2259
  maxDelayMs?: number;
2228
2260
  factor?: number;
2229
2261
  signal?: AbortSignal;
2262
+ /** A separate, jittered schedule and budget for `rate_limited` errors; other errors keep the one above. */
2263
+ rateLimited?: {
2264
+ attempts: number;
2265
+ baseDelayMs: number;
2266
+ maxDelayMs: number;
2267
+ };
2230
2268
  }
2231
2269
  declare function withRetry<T>(fn: (attempt: number) => Promise<T>, opts?: RetryOptions): Promise<T>;
2232
2270
  declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
@@ -2581,4 +2619,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
2581
2619
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
2582
2620
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
2583
2621
 
2584
- export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AnimationFrameSize, type AnimationLimits, type ArrayInputSpecKey, type AspectLimits, type AspectRatio, type AudioNodeMethods, type AudioOutput, type AudioRequest, type AudioResult, BYOK_PROVIDERS, type ByokField, type ByokFieldId, type ByokProvider, type ByokProviderId, type ByokSecret, type ByokTestResult, 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 DubbingOutcome, type DubbingRequest, type DubbingResult, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageAnimation, type ImageBackground, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImagePixelLimits, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecDimensions, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeySource, type KeyTier, type LanguageModelHandle, type LanguageOption, type Lifecycle, type LipsyncRequest, type LipsyncResult, type LiveCatalogState, MODEL3D_IMAGE_SLOTS, MODEL3D_MODELS, MODELS, type MaskBox, type MaskPoint, type MediaJobCallContext, type MediaNodeDefaults, type MediaOutput, type MediaPart, type MediaRef, type Model3dCall, type Model3dConstraints, type Model3dEndpoints, type Model3dFamily, type Model3dInputRefusal, type Model3dPricedInputs, type Model3dPricedOptions, type Model3dRequest, type Model3dResult, type Model3dStatus, type Model3dSubmission, type Model3dTexture, type Model3dViews, type Model3dWired, 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, REFERENCE_VIDEO_CONFORM_PROFILE, type ReferenceImageConformPlan, type ReferenceImageConformReason, type ReferenceImageProbe, type ReferenceLimits, type ReferenceSyntax, type ReferenceVideoConformPlan, type ReferenceVideoConformReason, type ReferenceVideoProbe, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SpeechRequest, type SubtitleOptions, type SubtitleTextStyle, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type TranscriptWord, type TranscriptionRequest, type TranscriptionResult, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoFpsLimits, type VideoJob, type VideoModel, type VideoPixelLimits, type VideoRequest, type VideoResolution, VideoResolutionSchema, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type VoiceCandidate, type VoiceChangeRequest, type VoiceCloneRequest, type VoiceCloneResult, type VoiceCloneState, type VoiceDeleteRequest, type VoiceDesignRequest, type VoiceDesignResult, type VoiceGender, type VoiceOption, type VoiceSample, type Warning, adapterServesType, aiSdkTextAdapter, alibabaAdapter, animationTier, arkAdapter, aspectRatioToSize, byokProviderForModel, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, elevenLabsAdapter, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, fishAdapter, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, imageOutputFormats, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keyOverrideFor, keysFromEnv, languageModel, liveCatalog, liveState, lumaAdapter, lumaReframeTooTall, mergeTextProviderOptions, missingTierKeys, model3dCall, model3dConstraints, model3dInputRefusal, model3dPricingSku, model3dResolution, model3dSeedFits, model3dSkus, model3dTexture, modelsPoweredBy, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, referenceImageConformPlan, referenceVideoConformPlan, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveDubbingOptions, resolveImageOptions, resolveKeys, resolveLipsyncOptions, resolveSpeechOptions, resolveTranscriptionOptions, resolveVideoOptions, resolveVoiceChangeOptions, resolveVoiceCloneOptions, resolveVoiceDesignOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, takesTargetAspectRatio, testProviderKey, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoSizeViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
2622
+ export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AnimationFrameSize, type AnimationLimits, type ArrayInputSpecKey, type AspectLimits, type AspectRatio, type AudioNodeMethods, type AudioOutput, type AudioRequest, type AudioResult, BYOK_PROVIDERS, type ByokField, type ByokFieldId, type ByokProvider, type ByokProviderId, type ByokSecret, type ByokTestResult, 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 DubbingOutcome, type DubbingRequest, type DubbingResult, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_BILLINGS, INPUT_SPEC_SUPPORTS_KEYS, type ImageAnimation, type ImageBackground, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImagePixelLimits, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputBilling, type InputSpec, type InputSpecDimensions, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeySource, type KeyTier, type LanguageModelHandle, type LanguageOption, type Lifecycle, type LipsyncRequest, type LipsyncResult, type LiveCatalogState, MODEL3D_IMAGE_SLOTS, MODEL3D_MODELS, MODELS, type MaskBox, type MaskPoint, type MediaJobCallContext, type MediaNodeDefaults, type MediaOutput, type MediaPart, type MediaRef, type Model3dCall, type Model3dConstraints, type Model3dEndpoints, type Model3dFamily, type Model3dInputRefusal, type Model3dPricedInputs, type Model3dPricedOptions, type Model3dRequest, type Model3dResult, type Model3dStatus, type Model3dSubmission, type Model3dTexture, type Model3dViews, type Model3dWired, 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, REFERENCE_VIDEO_CONFORM_PROFILE, type ReferenceImageConformPlan, type ReferenceImageConformReason, type ReferenceImageProbe, type ReferenceLimits, type ReferenceSyntax, type ReferenceVideoConformPlan, type ReferenceVideoConformReason, type ReferenceVideoProbe, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SpeechRequest, type SubtitleOptions, type SubtitleTextStyle, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type TranscriptWord, type TranscriptionRequest, type TranscriptionResult, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoFpsLimits, type VideoJob, type VideoModel, type VideoPixelLimits, type VideoRequest, type VideoResolution, VideoResolutionSchema, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type VoiceCandidate, type VoiceChangeRequest, type VoiceCloneRequest, type VoiceCloneResult, type VoiceCloneState, type VoiceDeleteRequest, type VoiceDesignRequest, type VoiceDesignResult, type VoiceGender, type VoiceOption, type VoiceSample, type Warning, adapterServesType, aiSdkTextAdapter, alibabaAdapter, animationTier, arkAdapter, aspectRatioToSize, byokProviderForModel, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, elevenLabsAdapter, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, fishAdapter, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, imageOutputFormats, inputBillingOf, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keyOverrideFor, keysFromEnv, languageModel, liveCatalog, liveState, lumaAdapter, lumaReframeTooTall, mergeTextProviderOptions, missingTierKeys, model3dCall, model3dConstraints, model3dInputRefusal, model3dPricingSku, model3dResolution, model3dSeedFits, model3dSkus, model3dTexture, modelsPoweredBy, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, referenceImageConformPlan, referenceVideoConformPlan, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveDubbingOptions, resolveImageOptions, resolveKeys, resolveLipsyncOptions, resolveSpeechOptions, resolveTranscriptionOptions, resolveVideoOptions, resolveVoiceChangeOptions, resolveVoiceCloneOptions, resolveVoiceDesignOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, takesTargetAspectRatio, testProviderKey, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoSizeViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
package/dist/index.js CHANGED
@@ -5374,6 +5374,7 @@ var VIDEO_FAMILY_MODELS = [
5374
5374
  lifecycle: "active",
5375
5375
  exposure: ["cowork", "space_builder"],
5376
5376
  constraints: {
5377
+ inputBilling: "kling-v4",
5377
5378
  aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
5378
5379
  resolutions: ["720p", "1080p"],
5379
5380
  durations: { min: 3, max: 30 },
@@ -5413,6 +5414,7 @@ var VIDEO_FAMILY_MODELS = [
5413
5414
  lifecycle: "active",
5414
5415
  exposure: ["cowork", "space_builder"],
5415
5416
  constraints: {
5417
+ inputBilling: "kling-v4",
5416
5418
  resolutions: ["720p", "1080p"],
5417
5419
  durations: { min: 3, max: 30 },
5418
5420
  references: { ...NO_REFERENCES, images: 10 },
@@ -5448,6 +5450,7 @@ var VIDEO_FAMILY_MODELS = [
5448
5450
  lifecycle: "active",
5449
5451
  exposure: ["cowork", "space_builder"],
5450
5452
  constraints: {
5453
+ inputBilling: "kling-v4",
5451
5454
  aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
5452
5455
  resolutions: ["720p"],
5453
5456
  durations: { min: 3, max: 20 },
@@ -5486,6 +5489,7 @@ var VIDEO_FAMILY_MODELS = [
5486
5489
  lifecycle: "active",
5487
5490
  exposure: ["cowork", "space_builder"],
5488
5491
  constraints: {
5492
+ inputBilling: "kling-v4",
5489
5493
  resolutions: ["720p"],
5490
5494
  durations: { min: 3, max: 20 },
5491
5495
  references: {
@@ -5567,6 +5571,7 @@ var VIDEO_FAMILY_MODELS = [
5567
5571
  lifecycle: "active",
5568
5572
  exposure: ["cowork", "space_builder"],
5569
5573
  constraints: {
5574
+ inputBilling: "h3-max-reference",
5570
5575
  resolutions: ["480p", "768p"],
5571
5576
  durations: { min: 5, max: 13 },
5572
5577
  references: { images: 9, videos: 3, audios: 0 },
@@ -5804,6 +5809,7 @@ var VIDEO_FAMILY_MODELS = [
5804
5809
  lifecycle: "active",
5805
5810
  exposure: ["cowork", "space_builder"],
5806
5811
  constraints: {
5812
+ inputBilling: "grok-input-image",
5807
5813
  aspectRatios: [...GROK_15_RATIOS],
5808
5814
  resolutions: ["480p", "720p", "1080p"],
5809
5815
  durations: { min: 1, max: 15 },
@@ -6081,6 +6087,7 @@ var VIDEO_MODELS = [
6081
6087
  replacedBy: "gemini-omni-1.1-flash",
6082
6088
  exposure: [],
6083
6089
  constraints: {
6090
+ inputBilling: "omni",
6084
6091
  // 1.0 rejects `resolution`; it renders 720p. No defaults: the adapter
6085
6092
  // sends ratio and duration only when the caller set them, so a
6086
6093
  // reference clip keeps its own framing.
@@ -6112,6 +6119,7 @@ var VIDEO_MODELS = [
6112
6119
  lifecycle: "active",
6113
6120
  exposure: ["cowork", "space_builder"],
6114
6121
  constraints: {
6122
+ inputBilling: "omni",
6115
6123
  aspectRatios: [...OMNI_RATIOS],
6116
6124
  resolutions: ["360p", "720p", "1080p", "4k"],
6117
6125
  durations: [3, 4, 5, 6, 7, 8, 9, 10],
@@ -6156,6 +6164,7 @@ var VIDEO_MODELS = [
6156
6164
  lifecycle: "active",
6157
6165
  exposure: ["cowork", "space_builder"],
6158
6166
  constraints: {
6167
+ inputBilling: "omni",
6159
6168
  aspectRatios: [...OMNI_RATIOS],
6160
6169
  resolutions: ["360p", "720p", "1080p", "4k"],
6161
6170
  durations: { min: 3, max: 15 },
@@ -6332,6 +6341,7 @@ var VIDEO_MODELS = [
6332
6341
  lifecycle: "active",
6333
6342
  exposure: ["cowork", "space_builder"],
6334
6343
  constraints: {
6344
+ inputBilling: "grok-input-image",
6335
6345
  aspectRatios: [...GROK_RATIOS],
6336
6346
  resolutions: ["480p", "720p"],
6337
6347
  durations: { min: 1, max: 15 },
@@ -6533,6 +6543,7 @@ var VIDEO_MODELS = [
6533
6543
  lifecycle: "active",
6534
6544
  exposure: ["cowork", "space_builder"],
6535
6545
  constraints: {
6546
+ inputBilling: "h3-reference",
6536
6547
  aspectRatios: [...H3_REFERENCE_RATIOS],
6537
6548
  resolutions: ["480p", "768p", "2k", "4k"],
6538
6549
  durations: { min: 5, max: 15 },
@@ -6577,6 +6588,7 @@ var VIDEO_MODELS = [
6577
6588
  lifecycle: "active",
6578
6589
  exposure: ["cowork", "space_builder"],
6579
6590
  constraints: {
6591
+ inputBilling: "h3-max-reference",
6580
6592
  aspectRatios: [...H3_REFERENCE_RATIOS],
6581
6593
  resolutions: ["480p", "768p", "1080p"],
6582
6594
  durations: { min: 5, max: 15 },
@@ -6624,6 +6636,7 @@ var VIDEO_MODELS = [
6624
6636
  lifecycle: "active",
6625
6637
  exposure: ["cowork", "space_builder"],
6626
6638
  constraints: {
6639
+ inputBilling: "input-plus-output",
6627
6640
  aspectRatios: [...WAN_RATIOS],
6628
6641
  resolutions: ["480p", "720p", "1080p"],
6629
6642
  durations: { min: 2, max: 30 },
@@ -6665,6 +6678,7 @@ var VIDEO_MODELS = [
6665
6678
  lifecycle: "active",
6666
6679
  exposure: ["cowork", "space_builder"],
6667
6680
  constraints: {
6681
+ inputBilling: "input-plus-output",
6668
6682
  aspectRatios: [...WAN_RATIOS],
6669
6683
  resolutions: ["480p", "720p", "1080p"],
6670
6684
  durations: { min: 2, max: 30 },
@@ -7328,7 +7342,18 @@ var PromptConventionsSchema = z.strictObject({
7328
7342
  referenceSyntax: ReferenceSyntaxSchema,
7329
7343
  maxChars: MaxCharsSchema.optional()
7330
7344
  });
7345
+ var InputBillingSchema = z.enum([
7346
+ "seedance",
7347
+ "omni",
7348
+ "h3-max-reference",
7349
+ "h3-reference",
7350
+ "grok-input-image",
7351
+ "source-video-rate",
7352
+ "kling-v4",
7353
+ "input-plus-output"
7354
+ ]);
7331
7355
  var AUDIO_OUTPUTS = AudioOutputSchema.options;
7356
+ var INPUT_BILLINGS = InputBillingSchema.options;
7332
7357
  var REFERENCE_SYNTAXES = ReferenceSyntaxSchema.options;
7333
7358
  var ConstraintsReadView = z.looseObject({
7334
7359
  audio: AudioOutputSchema.optional().catch(void 0),
@@ -8241,6 +8266,7 @@ var ModelConstraintsSchema = z3.looseObject({
8241
8266
  // Loose on purpose: the read path keeps a row whose value is invalid (the accessors in
8242
8267
  // conventions.ts read it as "not set"); CatalogModelSchema below rejects it on write.
8243
8268
  audio: z3.unknown().optional(),
8269
+ inputBilling: z3.unknown().optional(),
8244
8270
  prompt: z3.unknown().optional()
8245
8271
  });
8246
8272
  var MediaRefSchema = z3.union([
@@ -8433,6 +8459,14 @@ var CatalogModelSchema = CatalogModelSchemaBase.superRefine(
8433
8459
  message: 'audio must be "always", "optional" or "never"'
8434
8460
  });
8435
8461
  }
8462
+ const inputBilling = row2.constraints.inputBilling;
8463
+ if (inputBilling !== void 0 && !InputBillingSchema.safeParse(inputBilling).success) {
8464
+ ctx.addIssue({
8465
+ code: "custom",
8466
+ path: ["constraints", "inputBilling"],
8467
+ message: `inputBilling must be one of ${INPUT_BILLINGS.join(", ")}`
8468
+ });
8469
+ }
8436
8470
  const refs = row2.constraints.references;
8437
8471
  for (const kind of ["images", "videos", "audios"]) {
8438
8472
  const least = refs?.min?.[kind];
@@ -9214,19 +9248,42 @@ async function withRetry(fn, opts = {}) {
9214
9248
  const base = opts.baseDelayMs ?? 1e3;
9215
9249
  const max = opts.maxDelayMs ?? 1e4;
9216
9250
  const factor = opts.factor ?? 2;
9251
+ const rateLimited = opts.rateLimited;
9252
+ let limitedFailures = 0;
9253
+ let otherFailures = 0;
9217
9254
  let last;
9218
- for (let attempt = 1; attempt <= attempts; attempt++) {
9255
+ const ceiling = attempts + (rateLimited?.attempts ?? 0);
9256
+ for (let attempt = 1; attempt <= ceiling; attempt++) {
9219
9257
  if (opts.signal?.aborted) throw throwAborted();
9220
9258
  try {
9221
9259
  return await fn(attempt);
9222
9260
  } catch (cause) {
9223
- last = cause instanceof Error ? cause : new Error(String(cause), { cause });
9224
- if (attempt === attempts || !shouldRetry(last) || opts.signal?.aborted) throw cause;
9225
- await sleep(Math.min(max, base * factor ** (attempt - 1)), opts.signal);
9261
+ last = cause;
9262
+ const err = cause instanceof Error ? cause : new Error(String(cause), { cause });
9263
+ if (!shouldRetry(err) || opts.signal?.aborted) throw cause;
9264
+ let delay;
9265
+ if (rateLimited !== void 0 && err instanceof ModelKitError && err.code === "rate_limited") {
9266
+ limitedFailures += 1;
9267
+ if (limitedFailures >= rateLimited.attempts) throw cause;
9268
+ delay = jitter(
9269
+ Math.min(
9270
+ rateLimited.maxDelayMs,
9271
+ rateLimited.baseDelayMs * factor ** (limitedFailures - 1)
9272
+ )
9273
+ );
9274
+ } else {
9275
+ otherFailures += 1;
9276
+ if (otherFailures >= attempts) throw cause;
9277
+ delay = Math.min(max, base * factor ** (otherFailures - 1));
9278
+ }
9279
+ await sleep(delay, opts.signal);
9226
9280
  }
9227
9281
  }
9228
9282
  throw last;
9229
9283
  }
9284
+ function jitter(ms) {
9285
+ return Math.round(ms * (0.75 + Math.random() * 0.25));
9286
+ }
9230
9287
  function combineSignals(a, b) {
9231
9288
  return a && b ? AbortSignal.any([a, b]) : a ?? b;
9232
9289
  }
@@ -14006,6 +14063,12 @@ async function fishFetch(ctx, path, init) {
14006
14063
  if (!res.ok) throw classifyHttpError(res.status, await readBody(res), "fish", ctx.model.id);
14007
14064
  return res;
14008
14065
  }
14066
+ var FISH_RATE_LIMIT = { attempts: 6, baseDelayMs: 2e3, maxDelayMs: 2e4 };
14067
+ function fishRetryOptions(ctx) {
14068
+ const options = mediaRetryOptions(ctx.call, ctx.signal);
14069
+ if (ctx.call.maxRetries !== void 0) return options;
14070
+ return { ...options, rateLimited: FISH_RATE_LIMIT };
14071
+ }
14009
14072
  function usage3(ctx) {
14010
14073
  return {
14011
14074
  model: ctx.model.id,
@@ -14029,23 +14092,20 @@ async function generateSpeech2(req, ctx) {
14029
14092
  body.reference_id = checkVoiceId2(ctx, req.customVoice ? "customVoice" : "voice", voice);
14030
14093
  }
14031
14094
  if (req.language !== void 0) body.language = req.language;
14032
- const { bytes, mime } = await withRetry(
14033
- async () => {
14034
- const res = await fishFetch(ctx, "/v1/tts", {
14035
- method: "POST",
14036
- headers: { "Content-Type": "application/json", model: ctx.model.providerModelId },
14037
- body: JSON.stringify(body)
14038
- });
14039
- let audio;
14040
- try {
14041
- audio = new Uint8Array(await res.arrayBuffer());
14042
- } catch (cause) {
14043
- throw classifyThrown("fish", cause, ctx.model.id);
14044
- }
14045
- return { bytes: audio, mime: audioMime2(res, format) };
14046
- },
14047
- mediaRetryOptions(ctx.call, ctx.signal)
14048
- );
14095
+ const { bytes, mime } = await withRetry(async () => {
14096
+ const res = await fishFetch(ctx, "/v1/tts", {
14097
+ method: "POST",
14098
+ headers: { "Content-Type": "application/json", model: ctx.model.providerModelId },
14099
+ body: JSON.stringify(body)
14100
+ });
14101
+ let audio;
14102
+ try {
14103
+ audio = new Uint8Array(await res.arrayBuffer());
14104
+ } catch (cause) {
14105
+ throw classifyThrown("fish", cause, ctx.model.id);
14106
+ }
14107
+ return { bytes: audio, mime: audioMime2(res, format) };
14108
+ }, fishRetryOptions(ctx));
14049
14109
  if (bytes.byteLength === 0)
14050
14110
  throw fishError(ctx, "provider_rejected", "Fish TTS returned no audio");
14051
14111
  return { audio: { bytes, mime }, usage: usage3(ctx) };
@@ -14121,7 +14181,7 @@ async function createVoice2(req, ctx) {
14121
14181
  const form = await cloneForm2(req, ctx);
14122
14182
  const res = await withRetry(
14123
14183
  () => onlyRateLimitRetries2(() => fishFetch(ctx, "/model", { method: "POST", body: form })),
14124
- mediaRetryOptions(ctx.call, ctx.signal)
14184
+ fishRetryOptions(ctx)
14125
14185
  );
14126
14186
  const raw = await readBody(res);
14127
14187
  const parsed = createdModelSchema.safeParse(raw);
@@ -14158,17 +14218,14 @@ async function designVoice(req, ctx) {
14158
14218
  if (req.language !== void 0) body.language = req.language;
14159
14219
  if (req.count !== void 0) body.n = req.count;
14160
14220
  if (req.seed !== void 0) body.seed = req.seed;
14161
- const raw = await withRetry(
14162
- async () => {
14163
- const res = await fishFetch(ctx, "/v1/voice-design", {
14164
- method: "POST",
14165
- headers: { "Content-Type": "application/json", model: ctx.model.providerModelId },
14166
- body: JSON.stringify(body)
14167
- });
14168
- return readBody(res);
14169
- },
14170
- mediaRetryOptions(ctx.call, ctx.signal)
14171
- );
14221
+ const raw = await withRetry(async () => {
14222
+ const res = await fishFetch(ctx, "/v1/voice-design", {
14223
+ method: "POST",
14224
+ headers: { "Content-Type": "application/json", model: ctx.model.providerModelId },
14225
+ body: JSON.stringify(body)
14226
+ });
14227
+ return readBody(res);
14228
+ }, fishRetryOptions(ctx));
14172
14229
  const parsed = designSchema.safeParse(raw);
14173
14230
  if (!parsed.success) {
14174
14231
  throw fishError(ctx, "provider_rejected", "Fish voice design returned no candidates");
@@ -14186,27 +14243,24 @@ async function deleteVoice2(req, ctx) {
14186
14243
  checkRow2(ctx, "voice-clone");
14187
14244
  const id = encodeURIComponent(checkVoiceId2(ctx, "voiceId", req.voiceId));
14188
14245
  let attempts = 0;
14189
- await withRetry(
14190
- async () => {
14191
- attempts += 1;
14192
- try {
14193
- await fishFetch(ctx, `/model/${id}`, { method: "DELETE" });
14194
- } catch (cause) {
14195
- if (!isModelKitError(cause) || cause.status !== 404) throw cause;
14196
- if (attempts > 1) return;
14197
- throw new ModelKitError({
14198
- code: "provider_rejected",
14199
- message: `Fish has no voice ${req.voiceId} under this key set; delete with the tier that created it`,
14200
- provider: "fish",
14201
- model: ctx.model.id,
14202
- status: 404,
14203
- cause,
14204
- retryable: false
14205
- });
14206
- }
14207
- },
14208
- mediaRetryOptions(ctx.call, ctx.signal)
14209
- );
14246
+ await withRetry(async () => {
14247
+ attempts += 1;
14248
+ try {
14249
+ await fishFetch(ctx, `/model/${id}`, { method: "DELETE" });
14250
+ } catch (cause) {
14251
+ if (!isModelKitError(cause) || cause.status !== 404) throw cause;
14252
+ if (attempts > 1) return;
14253
+ throw new ModelKitError({
14254
+ code: "provider_rejected",
14255
+ message: `Fish has no voice ${req.voiceId} under this key set; delete with the tier that created it`,
14256
+ provider: "fish",
14257
+ model: ctx.model.id,
14258
+ status: 404,
14259
+ cause,
14260
+ retryable: false
14261
+ });
14262
+ }
14263
+ }, fishRetryOptions(ctx));
14210
14264
  }
14211
14265
  var fishAdapter = {
14212
14266
  id: "fish",
@@ -18282,6 +18336,25 @@ function fileCatalogCache(path) {
18282
18336
  };
18283
18337
  }
18284
18338
 
18339
+ // src/catalog/input-billing.ts
18340
+ import { z as z36 } from "zod";
18341
+ var DATA_ONLY_INPUT_BILLING = /* @__PURE__ */ new Map([
18342
+ ["flux-3", "source-video-rate"]
18343
+ ]);
18344
+ var KIT_INPUT_BILLING = new Map(
18345
+ MODELS.flatMap(
18346
+ (row2) => row2.constraints.inputBilling ? [[row2.id, row2.constraints.inputBilling]] : []
18347
+ )
18348
+ );
18349
+ var ConstraintsReadView2 = z36.looseObject({
18350
+ inputBilling: InputBillingSchema.optional().catch(void 0)
18351
+ });
18352
+ function inputBillingOf(row2) {
18353
+ const view = ConstraintsReadView2.safeParse(row2.constraints);
18354
+ const own = view.success ? view.data.inputBilling : void 0;
18355
+ return own ?? KIT_INPUT_BILLING.get(row2.id) ?? (row2.adapter === "ark" ? "seedance" : void 0) ?? DATA_ONLY_INPUT_BILLING.get(row2.id) ?? null;
18356
+ }
18357
+
18285
18358
  // src/resolve-image-output.ts
18286
18359
  var BASE_FORMATS = ["png", "jpeg", "webp"];
18287
18360
  var ONE_K_FRAME_PIXELS = 288 * 512;
@@ -19733,7 +19806,7 @@ async function testProviderKey(provider, secret, opts = {}) {
19733
19806
 
19734
19807
  // src/text.ts
19735
19808
  import "ai";
19736
- import { z as z36 } from "zod";
19809
+ import { z as z37 } from "zod";
19737
19810
  function mergeTextProviderOptions(catalog, caller) {
19738
19811
  const merged = {};
19739
19812
  const catalogOptions = catalog.providerOptions ?? {};
@@ -19772,8 +19845,8 @@ function passthroughTextModel(model) {
19772
19845
  pricingKind: "token"
19773
19846
  };
19774
19847
  }
19775
- var perplexityCostSchema = z36.object({
19776
- perplexity: z36.object({ cost: z36.object({ totalCost: z36.number().finite().nonnegative() }) })
19848
+ var perplexityCostSchema = z37.object({
19849
+ perplexity: z37.object({ cost: z37.object({ totalCost: z37.number().finite().nonnegative() }) })
19777
19850
  });
19778
19851
  function reportedCostUsd(metadata) {
19779
19852
  const parsed = perplexityCostSchema.safeParse(metadata);
@@ -19851,7 +19924,7 @@ import {
19851
19924
  streamObject as aiStreamObject2,
19852
19925
  streamText as aiStreamText2
19853
19926
  } from "ai";
19854
- import { z as z37 } from "zod";
19927
+ import { z as z38 } from "zod";
19855
19928
 
19856
19929
  // src/generated-image.ts
19857
19930
  function toGeneratedImage(image) {
@@ -20270,10 +20343,10 @@ function textAbortOptions(sdk, context) {
20270
20343
  if (abortSignal) return { abortSignal };
20271
20344
  return {};
20272
20345
  }
20273
- var catalogId = z37.string();
20274
- var exactSize = z37.templateLiteral([z37.number(), "x", z37.number()]);
20275
- var sdkRatio = z37.templateLiteral([z37.number(), ":", z37.number()]);
20276
- var sizeTier = z37.enum(["512", "1K", "2K", "4K"]);
20346
+ var catalogId = z38.string();
20347
+ var exactSize = z38.templateLiteral([z38.number(), "x", z38.number()]);
20348
+ var sdkRatio = z38.templateLiteral([z38.number(), ":", z38.number()]);
20349
+ var sizeTier = z38.enum(["512", "1K", "2K", "4K"]);
20277
20350
  function isCatalogId(model) {
20278
20351
  return catalogId.safeParse(model).success;
20279
20352
  }
@@ -20995,6 +21068,7 @@ export {
20995
21068
  DEFAULT_ADAPTERS,
20996
21069
  ExposureSchema,
20997
21070
  IMAGE_INPUT_SPEC_KEYS,
21071
+ INPUT_BILLINGS,
20998
21072
  INPUT_SPEC_SUPPORTS_KEYS,
20999
21073
  InputSpecSchema,
21000
21074
  JsonObjectSchema,
@@ -21039,6 +21113,7 @@ export {
21039
21113
  hasAwsCredentials,
21040
21114
  higgsfieldAdapter,
21041
21115
  imageOutputFormats,
21116
+ inputBillingOf,
21042
21117
  isArrayInputSpecKey,
21043
21118
  isInputSpecKey,
21044
21119
  isListed,