@howells/motif-sdk 1.2.0 → 1.3.0
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/image.js +38 -31
- package/dist/index.cjs +687 -33
- package/dist/index.d.cts +191 -10
- package/dist/index.d.ts +191 -10
- package/dist/index.js +676 -32
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -171,7 +171,6 @@ interface FalPricing {
|
|
|
171
171
|
}
|
|
172
172
|
interface LeaderboardMetric {
|
|
173
173
|
elo: number;
|
|
174
|
-
pricePer1k?: number | null;
|
|
175
174
|
rank: number;
|
|
176
175
|
winRate?: number;
|
|
177
176
|
}
|
|
@@ -457,6 +456,11 @@ declare function buildGenerateBody(options: GenerateOptions): {
|
|
|
457
456
|
};
|
|
458
457
|
|
|
459
458
|
interface LeaderboardEntry {
|
|
459
|
+
/**
|
|
460
|
+
* What the model's own vendor charges to run it through their API, as Artificial Analysis
|
|
461
|
+
* quoted it. Not what fal charges us - fal resells several of these for a fraction of the
|
|
462
|
+
* price. For our cost, read `falPricing` on the model in `models.ts`.
|
|
463
|
+
*/
|
|
460
464
|
apiPricing?: string;
|
|
461
465
|
creator: string;
|
|
462
466
|
elo: number;
|
|
@@ -1727,6 +1731,14 @@ declare class FalClient {
|
|
|
1727
1731
|
readonly inputKind: "image";
|
|
1728
1732
|
readonly name: "Seedream v5 Pro Layerize";
|
|
1729
1733
|
readonly outputKeys: ["layers", "images"];
|
|
1734
|
+
readonly outputLabels: {
|
|
1735
|
+
readonly layers: {
|
|
1736
|
+
readonly fromItem: {
|
|
1737
|
+
readonly nameField: "name";
|
|
1738
|
+
readonly orderField: "z_index";
|
|
1739
|
+
};
|
|
1740
|
+
};
|
|
1741
|
+
};
|
|
1730
1742
|
readonly price: {
|
|
1731
1743
|
readonly kind: "metered";
|
|
1732
1744
|
};
|
|
@@ -1909,19 +1921,37 @@ interface FalToolConfig {
|
|
|
1909
1921
|
* files: without it a PBR set lands as images-2.png, images-3.png and the
|
|
1910
1922
|
* caller cannot tell a roughness map from a normal map.
|
|
1911
1923
|
*
|
|
1912
|
-
*
|
|
1913
|
-
*
|
|
1914
|
-
*
|
|
1915
|
-
*
|
|
1916
|
-
*
|
|
1917
|
-
*
|
|
1924
|
+
* Two rule shapes, because the names come from two different places.
|
|
1925
|
+
*
|
|
1926
|
+
* Request-driven: `fromOption` names the request option that actually
|
|
1927
|
+
* determines the order — read the resolved request body first and use its
|
|
1928
|
+
* value when present, since a caller may reorder or subset it. `fallback` is
|
|
1929
|
+
* the endpoint's schema default, used when the option is absent.
|
|
1930
|
+
*
|
|
1931
|
+
* Response-driven: `fromItem` reads the name off each element of the output
|
|
1932
|
+
* array itself, for endpoints that label what they produced (seedream's
|
|
1933
|
+
* layer stack names every layer). `nameField` holds the name and
|
|
1934
|
+
* `orderField`, when set, holds a non-negative integer that prefixes it so
|
|
1935
|
+
* the files sort in stack order. These strings come from a model, so the
|
|
1936
|
+
* consumer slugifies them into a filename and keeps positional naming when
|
|
1937
|
+
* nothing usable survives.
|
|
1918
1938
|
*
|
|
1919
|
-
*
|
|
1920
|
-
*
|
|
1939
|
+
* Whichever is used, check the label count against the URL count before
|
|
1940
|
+
* applying it: a mislabelled map is worse than a positional one, because it
|
|
1941
|
+
* reads as authoritative.
|
|
1942
|
+
*
|
|
1943
|
+
* Only set this where the order or the naming is actually determined — by a
|
|
1944
|
+
* request option, by the schema, or by the response. Leave genuinely
|
|
1945
|
+
* unordered, unnamed arrays unlabelled.
|
|
1921
1946
|
*/
|
|
1922
1947
|
outputLabels?: Record<string, {
|
|
1923
1948
|
fallback: readonly string[];
|
|
1924
1949
|
fromOption?: string;
|
|
1950
|
+
} | {
|
|
1951
|
+
fromItem: {
|
|
1952
|
+
nameField: string;
|
|
1953
|
+
orderField?: string;
|
|
1954
|
+
};
|
|
1925
1955
|
}>;
|
|
1926
1956
|
price: FalToolPrice;
|
|
1927
1957
|
pricing: string;
|
|
@@ -3062,6 +3092,14 @@ declare const FAL_TOOLS: {
|
|
|
3062
3092
|
readonly inputKind: "image";
|
|
3063
3093
|
readonly name: "Seedream v5 Pro Layerize";
|
|
3064
3094
|
readonly outputKeys: ["layers", "images"];
|
|
3095
|
+
readonly outputLabels: {
|
|
3096
|
+
readonly layers: {
|
|
3097
|
+
readonly fromItem: {
|
|
3098
|
+
readonly nameField: "name";
|
|
3099
|
+
readonly orderField: "z_index";
|
|
3100
|
+
};
|
|
3101
|
+
};
|
|
3102
|
+
};
|
|
3065
3103
|
readonly price: {
|
|
3066
3104
|
readonly kind: "metered";
|
|
3067
3105
|
};
|
|
@@ -3202,4 +3240,147 @@ type FalToolId = (typeof FAL_TOOL_IDS)[number];
|
|
|
3202
3240
|
declare function isFalToolId(tool: string): tool is FalToolId;
|
|
3203
3241
|
declare function buildFalToolRequest(options: FalToolRunOptions): FalToolRequest;
|
|
3204
3242
|
|
|
3205
|
-
|
|
3243
|
+
/**
|
|
3244
|
+
* What a tool run costs, before it happens and after.
|
|
3245
|
+
*
|
|
3246
|
+
* The registry's `price` is a rate, not a total. Turning a rate into a figure
|
|
3247
|
+
* needs something only one of the two moments has:
|
|
3248
|
+
*
|
|
3249
|
+
* - Before the call, a `call` price is the whole answer and nothing else is.
|
|
3250
|
+
* A per-megapixel rate depends on an output that does not exist yet.
|
|
3251
|
+
* - After the call, the output exists and has been measured, so a
|
|
3252
|
+
* per-megapixel rate resolves exactly. Most of the restoration suite is
|
|
3253
|
+
* priced this way, which means most of what looked unknowable at dry-run
|
|
3254
|
+
* time is knowable by the time it reaches history.
|
|
3255
|
+
*
|
|
3256
|
+
* Both functions return `null` rather than `0` where the figure is genuinely
|
|
3257
|
+
* unavailable. Zero is a claim that something was free, and every price defect
|
|
3258
|
+
* found in this registry has been a confident wrong number rather than an
|
|
3259
|
+
* absent one.
|
|
3260
|
+
*/
|
|
3261
|
+
|
|
3262
|
+
/** Pixel dimensions of one file an endpoint returned. */
|
|
3263
|
+
interface OutputDimensions {
|
|
3264
|
+
height?: number;
|
|
3265
|
+
width?: number;
|
|
3266
|
+
}
|
|
3267
|
+
/** A cost, and enough context for a caller to say why it is what it is. */
|
|
3268
|
+
interface ResolvedCost {
|
|
3269
|
+
/** USD, or null when the rate cannot be resolved against what we know. */
|
|
3270
|
+
usd: number | null;
|
|
3271
|
+
/**
|
|
3272
|
+
* Whether `usd` was measured from real output or projected from the rate
|
|
3273
|
+
* alone. Callers that display a figure should say which; an estimate and a
|
|
3274
|
+
* bill are not the same claim.
|
|
3275
|
+
*/
|
|
3276
|
+
basis: "measured" | "projected" | "unknown";
|
|
3277
|
+
}
|
|
3278
|
+
/**
|
|
3279
|
+
* The figure to show before a run, from the rate alone.
|
|
3280
|
+
*
|
|
3281
|
+
* Only a flat per-call price survives this: everything else depends on an
|
|
3282
|
+
* output that does not exist yet, and guessing its size is how a dry run comes
|
|
3283
|
+
* to promise a number the invoice contradicts.
|
|
3284
|
+
*/
|
|
3285
|
+
declare function projectedToolCost(price: FalToolPrice): ResolvedCost;
|
|
3286
|
+
/**
|
|
3287
|
+
* The figure to record after a run, from the rate and the output it produced.
|
|
3288
|
+
*
|
|
3289
|
+
* A per-megapixel rate becomes exact here, because the files have been written
|
|
3290
|
+
* and measured. Per-second rates need a duration nothing in the image path
|
|
3291
|
+
* carries, and metered endpoints publish no rate at all, so both stay unknown.
|
|
3292
|
+
*/
|
|
3293
|
+
declare function measuredToolCost(price: FalToolPrice, outputs: readonly OutputDimensions[]): ResolvedCost;
|
|
3294
|
+
/**
|
|
3295
|
+
* Render a cost for a human. `null` never becomes "$0.000" - it says what it
|
|
3296
|
+
* means, which is that nobody knows.
|
|
3297
|
+
*/
|
|
3298
|
+
declare function formatCost(usd: number | null): string;
|
|
3299
|
+
/**
|
|
3300
|
+
* Sum costs that are known, and count the ones that are not.
|
|
3301
|
+
*
|
|
3302
|
+
* A running total that silently drops unknown runs reads as complete. Callers
|
|
3303
|
+
* are expected to show both halves: "$1.23 plus 4 metered runs" is honest where
|
|
3304
|
+
* "$1.23" is not.
|
|
3305
|
+
*/
|
|
3306
|
+
declare function sumCosts(costs: readonly (number | null)[]): {
|
|
3307
|
+
known: number;
|
|
3308
|
+
unknown: number;
|
|
3309
|
+
};
|
|
3310
|
+
|
|
3311
|
+
/** One argument an endpoint accepts. */
|
|
3312
|
+
interface FalToolParameter {
|
|
3313
|
+
/** Argument name, exactly as fal expects it in the request body. */
|
|
3314
|
+
key: string;
|
|
3315
|
+
/** fal's own default when the caller sends nothing. */
|
|
3316
|
+
fallback?: boolean | number | string | readonly unknown[];
|
|
3317
|
+
/** Whether fal rejects the request without it. */
|
|
3318
|
+
required?: true;
|
|
3319
|
+
/** Compact rendering of fal's declared type, e.g. `enum(a|b)`, `list[string]`. */
|
|
3320
|
+
type: string;
|
|
3321
|
+
}
|
|
3322
|
+
declare const FAL_TOOL_PARAMETERS: Record<string, readonly FalToolParameter[]>;
|
|
3323
|
+
/** Arguments a tool accepts, including ones Motif does not surface as flags. */
|
|
3324
|
+
declare function falToolParameters(tool: string): readonly FalToolParameter[];
|
|
3325
|
+
|
|
3326
|
+
interface ModelOutputShape {
|
|
3327
|
+
/** File container the endpoint returns. */
|
|
3328
|
+
container: string;
|
|
3329
|
+
/** Whether the encoding preserves every pixel exactly. */
|
|
3330
|
+
lossless: boolean;
|
|
3331
|
+
/** Bits per channel. */
|
|
3332
|
+
bitDepth?: number;
|
|
3333
|
+
/** Whether the returned file carries an alpha channel. */
|
|
3334
|
+
hasAlpha?: boolean;
|
|
3335
|
+
/** JPEG chroma subsampling, e.g. "4:4:4" or "4:2:0". Absent for lossless containers. */
|
|
3336
|
+
subsampling?: string;
|
|
3337
|
+
}
|
|
3338
|
+
declare const MODEL_OUTPUT: Record<string, ModelOutputShape>;
|
|
3339
|
+
|
|
3340
|
+
/**
|
|
3341
|
+
* What a model returns, and whether you can get something lossless out of it.
|
|
3342
|
+
*
|
|
3343
|
+
* Two facts live in different places and neither is useful alone:
|
|
3344
|
+
*
|
|
3345
|
+
* - `MODEL_OUTPUT` (generated, measured from real bytes) says what arrives
|
|
3346
|
+
* when you ask for nothing.
|
|
3347
|
+
* - `supportsOutputFormat` on the model says whether you are allowed to ask
|
|
3348
|
+
* for something else.
|
|
3349
|
+
*
|
|
3350
|
+
* A caller who reads only the first concludes `flux2-pro` is lossy; it defaults
|
|
3351
|
+
* to JPEG but returns PNG on request. A caller who reads only the second
|
|
3352
|
+
* concludes `seedream5` is fine; the flag is false, and what that actually
|
|
3353
|
+
* means is 4:2:0 chroma - averaged over 2x2 blocks, invisible in a photograph
|
|
3354
|
+
* and destructive to anything dividing by alpha at a soft edge.
|
|
3355
|
+
*
|
|
3356
|
+
* So the answer is derived from both at read time rather than written down a
|
|
3357
|
+
* third time. Every price and output-key defect in this registry came from one
|
|
3358
|
+
* fact stored twice.
|
|
3359
|
+
*/
|
|
3360
|
+
|
|
3361
|
+
/** Whether a lossless file can be obtained, and what it costs to ask. */
|
|
3362
|
+
type LosslessAvailability =
|
|
3363
|
+
/** Lossless by default; ask for nothing. */
|
|
3364
|
+
"default"
|
|
3365
|
+
/** Lossy by default, lossless when `outputFormat` is set. */
|
|
3366
|
+
| "on-request"
|
|
3367
|
+
/** No lossless route: the endpoint returns a lossy container and rejects the argument. */
|
|
3368
|
+
| "unavailable"
|
|
3369
|
+
/** Not probed. Absence of evidence, not evidence of a limitation. */
|
|
3370
|
+
| "unknown";
|
|
3371
|
+
/** Measured shape of what a model returns by default, if it has been probed. */
|
|
3372
|
+
declare function modelOutput(model: string): ModelOutputShape | undefined;
|
|
3373
|
+
/**
|
|
3374
|
+
* Whether this model can produce a lossless file at all.
|
|
3375
|
+
*
|
|
3376
|
+
* The question a caller actually has, answered from the measured default and
|
|
3377
|
+
* the accepted arguments together.
|
|
3378
|
+
*/
|
|
3379
|
+
declare function losslessAvailability(model: string): LosslessAvailability;
|
|
3380
|
+
/**
|
|
3381
|
+
* One line a human or an agent can act on, e.g.
|
|
3382
|
+
* `"jpeg 4:2:0, no lossless route"` or `"jpeg 4:4:4, PNG on request"`.
|
|
3383
|
+
*/
|
|
3384
|
+
declare function describeModelOutput(model: string): string;
|
|
3385
|
+
|
|
3386
|
+
export { ASPECT_RATIOS, type AspectRatio, type BackgroundMode, CREATIVE_FIELDS, CREATIVE_TAXONOMY, type CreativeDirection, type CreativeField, type CreativeOption, CreativeOptionError, type CreativeOptionErrorDetails, type CreativePromptResult, type CustomImageSize, EDIT_CAPABLE_MODELS, type EnrichPromptOptions, FAL_TOOLS, FAL_TOOLS_CHECKED_AT, FAL_TOOL_IDS, FAL_TOOL_PARAMETERS, FORMAT_PRESETS, FalClient, type FalClientConfig, type FalImageSizePreset, type FalToolConfig, type FalToolId, type FalToolInputKind, type FalToolParameter, type FalToolPrice, type FalToolRequest, type FalToolRunOptions, GENERATION_MODELS, type GenerateOptions, type GenerationModelName, type GptImageSize, IDEOGRAM_STYLES, IMAGE_EDITING_TOP_20, IMAGE_TEXT_TO_IMAGE_TOP_20, type ImageOutputFormat, type ImageQuality, type ImageSize, type JobStatus, type LeaderboardEntry, type LeaderboardSnapshot, type LosslessAvailability, MODELS, MODEL_OUTPUT, type ModelConfig, type ModelOutputShape, type ModelType, type MotifEnv, MotifError, type MotifImage, type MotifResponse, type OutputDimensions, type QueuedJob, type QueuedToolJob, RECRAFT_STYLES, RESOLUTIONS, type RemoveBackgroundOptions, type Resolution, type ResolvedCost, type SizeMode, type ThinkingLevel, type ToolResponse, type ToolRunOptions, UTILITY_MODELS, type UpscaleOptions, VIDEO_IMAGE_TO_VIDEO_TOP_15, VIDEO_MODELS, VIDEO_TEXT_TO_VIDEO_TOP_15, type VideoOptions, type VideoResponse, aspectToFalImageSize, aspectToGptSize, buildFalToolRequest, buildGenerateBody, describeModelOutput, enrichPrompt, estimateCost, estimateVideoCost, falToolParameters, formatCost, getFalKeyFromEnv, isFalToolId, losslessAvailability, measuredToolCost, modelOutput, motifEnvSchema, parseMotifEnv, projectedToolCost, sanitizePrompt, sumCosts };
|
package/dist/index.d.ts
CHANGED
|
@@ -171,7 +171,6 @@ interface FalPricing {
|
|
|
171
171
|
}
|
|
172
172
|
interface LeaderboardMetric {
|
|
173
173
|
elo: number;
|
|
174
|
-
pricePer1k?: number | null;
|
|
175
174
|
rank: number;
|
|
176
175
|
winRate?: number;
|
|
177
176
|
}
|
|
@@ -457,6 +456,11 @@ declare function buildGenerateBody(options: GenerateOptions): {
|
|
|
457
456
|
};
|
|
458
457
|
|
|
459
458
|
interface LeaderboardEntry {
|
|
459
|
+
/**
|
|
460
|
+
* What the model's own vendor charges to run it through their API, as Artificial Analysis
|
|
461
|
+
* quoted it. Not what fal charges us - fal resells several of these for a fraction of the
|
|
462
|
+
* price. For our cost, read `falPricing` on the model in `models.ts`.
|
|
463
|
+
*/
|
|
460
464
|
apiPricing?: string;
|
|
461
465
|
creator: string;
|
|
462
466
|
elo: number;
|
|
@@ -1727,6 +1731,14 @@ declare class FalClient {
|
|
|
1727
1731
|
readonly inputKind: "image";
|
|
1728
1732
|
readonly name: "Seedream v5 Pro Layerize";
|
|
1729
1733
|
readonly outputKeys: ["layers", "images"];
|
|
1734
|
+
readonly outputLabels: {
|
|
1735
|
+
readonly layers: {
|
|
1736
|
+
readonly fromItem: {
|
|
1737
|
+
readonly nameField: "name";
|
|
1738
|
+
readonly orderField: "z_index";
|
|
1739
|
+
};
|
|
1740
|
+
};
|
|
1741
|
+
};
|
|
1730
1742
|
readonly price: {
|
|
1731
1743
|
readonly kind: "metered";
|
|
1732
1744
|
};
|
|
@@ -1909,19 +1921,37 @@ interface FalToolConfig {
|
|
|
1909
1921
|
* files: without it a PBR set lands as images-2.png, images-3.png and the
|
|
1910
1922
|
* caller cannot tell a roughness map from a normal map.
|
|
1911
1923
|
*
|
|
1912
|
-
*
|
|
1913
|
-
*
|
|
1914
|
-
*
|
|
1915
|
-
*
|
|
1916
|
-
*
|
|
1917
|
-
*
|
|
1924
|
+
* Two rule shapes, because the names come from two different places.
|
|
1925
|
+
*
|
|
1926
|
+
* Request-driven: `fromOption` names the request option that actually
|
|
1927
|
+
* determines the order — read the resolved request body first and use its
|
|
1928
|
+
* value when present, since a caller may reorder or subset it. `fallback` is
|
|
1929
|
+
* the endpoint's schema default, used when the option is absent.
|
|
1930
|
+
*
|
|
1931
|
+
* Response-driven: `fromItem` reads the name off each element of the output
|
|
1932
|
+
* array itself, for endpoints that label what they produced (seedream's
|
|
1933
|
+
* layer stack names every layer). `nameField` holds the name and
|
|
1934
|
+
* `orderField`, when set, holds a non-negative integer that prefixes it so
|
|
1935
|
+
* the files sort in stack order. These strings come from a model, so the
|
|
1936
|
+
* consumer slugifies them into a filename and keeps positional naming when
|
|
1937
|
+
* nothing usable survives.
|
|
1918
1938
|
*
|
|
1919
|
-
*
|
|
1920
|
-
*
|
|
1939
|
+
* Whichever is used, check the label count against the URL count before
|
|
1940
|
+
* applying it: a mislabelled map is worse than a positional one, because it
|
|
1941
|
+
* reads as authoritative.
|
|
1942
|
+
*
|
|
1943
|
+
* Only set this where the order or the naming is actually determined — by a
|
|
1944
|
+
* request option, by the schema, or by the response. Leave genuinely
|
|
1945
|
+
* unordered, unnamed arrays unlabelled.
|
|
1921
1946
|
*/
|
|
1922
1947
|
outputLabels?: Record<string, {
|
|
1923
1948
|
fallback: readonly string[];
|
|
1924
1949
|
fromOption?: string;
|
|
1950
|
+
} | {
|
|
1951
|
+
fromItem: {
|
|
1952
|
+
nameField: string;
|
|
1953
|
+
orderField?: string;
|
|
1954
|
+
};
|
|
1925
1955
|
}>;
|
|
1926
1956
|
price: FalToolPrice;
|
|
1927
1957
|
pricing: string;
|
|
@@ -3062,6 +3092,14 @@ declare const FAL_TOOLS: {
|
|
|
3062
3092
|
readonly inputKind: "image";
|
|
3063
3093
|
readonly name: "Seedream v5 Pro Layerize";
|
|
3064
3094
|
readonly outputKeys: ["layers", "images"];
|
|
3095
|
+
readonly outputLabels: {
|
|
3096
|
+
readonly layers: {
|
|
3097
|
+
readonly fromItem: {
|
|
3098
|
+
readonly nameField: "name";
|
|
3099
|
+
readonly orderField: "z_index";
|
|
3100
|
+
};
|
|
3101
|
+
};
|
|
3102
|
+
};
|
|
3065
3103
|
readonly price: {
|
|
3066
3104
|
readonly kind: "metered";
|
|
3067
3105
|
};
|
|
@@ -3202,4 +3240,147 @@ type FalToolId = (typeof FAL_TOOL_IDS)[number];
|
|
|
3202
3240
|
declare function isFalToolId(tool: string): tool is FalToolId;
|
|
3203
3241
|
declare function buildFalToolRequest(options: FalToolRunOptions): FalToolRequest;
|
|
3204
3242
|
|
|
3205
|
-
|
|
3243
|
+
/**
|
|
3244
|
+
* What a tool run costs, before it happens and after.
|
|
3245
|
+
*
|
|
3246
|
+
* The registry's `price` is a rate, not a total. Turning a rate into a figure
|
|
3247
|
+
* needs something only one of the two moments has:
|
|
3248
|
+
*
|
|
3249
|
+
* - Before the call, a `call` price is the whole answer and nothing else is.
|
|
3250
|
+
* A per-megapixel rate depends on an output that does not exist yet.
|
|
3251
|
+
* - After the call, the output exists and has been measured, so a
|
|
3252
|
+
* per-megapixel rate resolves exactly. Most of the restoration suite is
|
|
3253
|
+
* priced this way, which means most of what looked unknowable at dry-run
|
|
3254
|
+
* time is knowable by the time it reaches history.
|
|
3255
|
+
*
|
|
3256
|
+
* Both functions return `null` rather than `0` where the figure is genuinely
|
|
3257
|
+
* unavailable. Zero is a claim that something was free, and every price defect
|
|
3258
|
+
* found in this registry has been a confident wrong number rather than an
|
|
3259
|
+
* absent one.
|
|
3260
|
+
*/
|
|
3261
|
+
|
|
3262
|
+
/** Pixel dimensions of one file an endpoint returned. */
|
|
3263
|
+
interface OutputDimensions {
|
|
3264
|
+
height?: number;
|
|
3265
|
+
width?: number;
|
|
3266
|
+
}
|
|
3267
|
+
/** A cost, and enough context for a caller to say why it is what it is. */
|
|
3268
|
+
interface ResolvedCost {
|
|
3269
|
+
/** USD, or null when the rate cannot be resolved against what we know. */
|
|
3270
|
+
usd: number | null;
|
|
3271
|
+
/**
|
|
3272
|
+
* Whether `usd` was measured from real output or projected from the rate
|
|
3273
|
+
* alone. Callers that display a figure should say which; an estimate and a
|
|
3274
|
+
* bill are not the same claim.
|
|
3275
|
+
*/
|
|
3276
|
+
basis: "measured" | "projected" | "unknown";
|
|
3277
|
+
}
|
|
3278
|
+
/**
|
|
3279
|
+
* The figure to show before a run, from the rate alone.
|
|
3280
|
+
*
|
|
3281
|
+
* Only a flat per-call price survives this: everything else depends on an
|
|
3282
|
+
* output that does not exist yet, and guessing its size is how a dry run comes
|
|
3283
|
+
* to promise a number the invoice contradicts.
|
|
3284
|
+
*/
|
|
3285
|
+
declare function projectedToolCost(price: FalToolPrice): ResolvedCost;
|
|
3286
|
+
/**
|
|
3287
|
+
* The figure to record after a run, from the rate and the output it produced.
|
|
3288
|
+
*
|
|
3289
|
+
* A per-megapixel rate becomes exact here, because the files have been written
|
|
3290
|
+
* and measured. Per-second rates need a duration nothing in the image path
|
|
3291
|
+
* carries, and metered endpoints publish no rate at all, so both stay unknown.
|
|
3292
|
+
*/
|
|
3293
|
+
declare function measuredToolCost(price: FalToolPrice, outputs: readonly OutputDimensions[]): ResolvedCost;
|
|
3294
|
+
/**
|
|
3295
|
+
* Render a cost for a human. `null` never becomes "$0.000" - it says what it
|
|
3296
|
+
* means, which is that nobody knows.
|
|
3297
|
+
*/
|
|
3298
|
+
declare function formatCost(usd: number | null): string;
|
|
3299
|
+
/**
|
|
3300
|
+
* Sum costs that are known, and count the ones that are not.
|
|
3301
|
+
*
|
|
3302
|
+
* A running total that silently drops unknown runs reads as complete. Callers
|
|
3303
|
+
* are expected to show both halves: "$1.23 plus 4 metered runs" is honest where
|
|
3304
|
+
* "$1.23" is not.
|
|
3305
|
+
*/
|
|
3306
|
+
declare function sumCosts(costs: readonly (number | null)[]): {
|
|
3307
|
+
known: number;
|
|
3308
|
+
unknown: number;
|
|
3309
|
+
};
|
|
3310
|
+
|
|
3311
|
+
/** One argument an endpoint accepts. */
|
|
3312
|
+
interface FalToolParameter {
|
|
3313
|
+
/** Argument name, exactly as fal expects it in the request body. */
|
|
3314
|
+
key: string;
|
|
3315
|
+
/** fal's own default when the caller sends nothing. */
|
|
3316
|
+
fallback?: boolean | number | string | readonly unknown[];
|
|
3317
|
+
/** Whether fal rejects the request without it. */
|
|
3318
|
+
required?: true;
|
|
3319
|
+
/** Compact rendering of fal's declared type, e.g. `enum(a|b)`, `list[string]`. */
|
|
3320
|
+
type: string;
|
|
3321
|
+
}
|
|
3322
|
+
declare const FAL_TOOL_PARAMETERS: Record<string, readonly FalToolParameter[]>;
|
|
3323
|
+
/** Arguments a tool accepts, including ones Motif does not surface as flags. */
|
|
3324
|
+
declare function falToolParameters(tool: string): readonly FalToolParameter[];
|
|
3325
|
+
|
|
3326
|
+
interface ModelOutputShape {
|
|
3327
|
+
/** File container the endpoint returns. */
|
|
3328
|
+
container: string;
|
|
3329
|
+
/** Whether the encoding preserves every pixel exactly. */
|
|
3330
|
+
lossless: boolean;
|
|
3331
|
+
/** Bits per channel. */
|
|
3332
|
+
bitDepth?: number;
|
|
3333
|
+
/** Whether the returned file carries an alpha channel. */
|
|
3334
|
+
hasAlpha?: boolean;
|
|
3335
|
+
/** JPEG chroma subsampling, e.g. "4:4:4" or "4:2:0". Absent for lossless containers. */
|
|
3336
|
+
subsampling?: string;
|
|
3337
|
+
}
|
|
3338
|
+
declare const MODEL_OUTPUT: Record<string, ModelOutputShape>;
|
|
3339
|
+
|
|
3340
|
+
/**
|
|
3341
|
+
* What a model returns, and whether you can get something lossless out of it.
|
|
3342
|
+
*
|
|
3343
|
+
* Two facts live in different places and neither is useful alone:
|
|
3344
|
+
*
|
|
3345
|
+
* - `MODEL_OUTPUT` (generated, measured from real bytes) says what arrives
|
|
3346
|
+
* when you ask for nothing.
|
|
3347
|
+
* - `supportsOutputFormat` on the model says whether you are allowed to ask
|
|
3348
|
+
* for something else.
|
|
3349
|
+
*
|
|
3350
|
+
* A caller who reads only the first concludes `flux2-pro` is lossy; it defaults
|
|
3351
|
+
* to JPEG but returns PNG on request. A caller who reads only the second
|
|
3352
|
+
* concludes `seedream5` is fine; the flag is false, and what that actually
|
|
3353
|
+
* means is 4:2:0 chroma - averaged over 2x2 blocks, invisible in a photograph
|
|
3354
|
+
* and destructive to anything dividing by alpha at a soft edge.
|
|
3355
|
+
*
|
|
3356
|
+
* So the answer is derived from both at read time rather than written down a
|
|
3357
|
+
* third time. Every price and output-key defect in this registry came from one
|
|
3358
|
+
* fact stored twice.
|
|
3359
|
+
*/
|
|
3360
|
+
|
|
3361
|
+
/** Whether a lossless file can be obtained, and what it costs to ask. */
|
|
3362
|
+
type LosslessAvailability =
|
|
3363
|
+
/** Lossless by default; ask for nothing. */
|
|
3364
|
+
"default"
|
|
3365
|
+
/** Lossy by default, lossless when `outputFormat` is set. */
|
|
3366
|
+
| "on-request"
|
|
3367
|
+
/** No lossless route: the endpoint returns a lossy container and rejects the argument. */
|
|
3368
|
+
| "unavailable"
|
|
3369
|
+
/** Not probed. Absence of evidence, not evidence of a limitation. */
|
|
3370
|
+
| "unknown";
|
|
3371
|
+
/** Measured shape of what a model returns by default, if it has been probed. */
|
|
3372
|
+
declare function modelOutput(model: string): ModelOutputShape | undefined;
|
|
3373
|
+
/**
|
|
3374
|
+
* Whether this model can produce a lossless file at all.
|
|
3375
|
+
*
|
|
3376
|
+
* The question a caller actually has, answered from the measured default and
|
|
3377
|
+
* the accepted arguments together.
|
|
3378
|
+
*/
|
|
3379
|
+
declare function losslessAvailability(model: string): LosslessAvailability;
|
|
3380
|
+
/**
|
|
3381
|
+
* One line a human or an agent can act on, e.g.
|
|
3382
|
+
* `"jpeg 4:2:0, no lossless route"` or `"jpeg 4:4:4, PNG on request"`.
|
|
3383
|
+
*/
|
|
3384
|
+
declare function describeModelOutput(model: string): string;
|
|
3385
|
+
|
|
3386
|
+
export { ASPECT_RATIOS, type AspectRatio, type BackgroundMode, CREATIVE_FIELDS, CREATIVE_TAXONOMY, type CreativeDirection, type CreativeField, type CreativeOption, CreativeOptionError, type CreativeOptionErrorDetails, type CreativePromptResult, type CustomImageSize, EDIT_CAPABLE_MODELS, type EnrichPromptOptions, FAL_TOOLS, FAL_TOOLS_CHECKED_AT, FAL_TOOL_IDS, FAL_TOOL_PARAMETERS, FORMAT_PRESETS, FalClient, type FalClientConfig, type FalImageSizePreset, type FalToolConfig, type FalToolId, type FalToolInputKind, type FalToolParameter, type FalToolPrice, type FalToolRequest, type FalToolRunOptions, GENERATION_MODELS, type GenerateOptions, type GenerationModelName, type GptImageSize, IDEOGRAM_STYLES, IMAGE_EDITING_TOP_20, IMAGE_TEXT_TO_IMAGE_TOP_20, type ImageOutputFormat, type ImageQuality, type ImageSize, type JobStatus, type LeaderboardEntry, type LeaderboardSnapshot, type LosslessAvailability, MODELS, MODEL_OUTPUT, type ModelConfig, type ModelOutputShape, type ModelType, type MotifEnv, MotifError, type MotifImage, type MotifResponse, type OutputDimensions, type QueuedJob, type QueuedToolJob, RECRAFT_STYLES, RESOLUTIONS, type RemoveBackgroundOptions, type Resolution, type ResolvedCost, type SizeMode, type ThinkingLevel, type ToolResponse, type ToolRunOptions, UTILITY_MODELS, type UpscaleOptions, VIDEO_IMAGE_TO_VIDEO_TOP_15, VIDEO_MODELS, VIDEO_TEXT_TO_VIDEO_TOP_15, type VideoOptions, type VideoResponse, aspectToFalImageSize, aspectToGptSize, buildFalToolRequest, buildGenerateBody, describeModelOutput, enrichPrompt, estimateCost, estimateVideoCost, falToolParameters, formatCost, getFalKeyFromEnv, isFalToolId, losslessAvailability, measuredToolCost, modelOutput, motifEnvSchema, parseMotifEnv, projectedToolCost, sanitizePrompt, sumCosts };
|