@howells/motif-sdk 0.11.0 → 1.0.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/README.md CHANGED
@@ -10,10 +10,14 @@ npm install @howells/motif-sdk
10
10
 
11
11
  ## Generate Images
12
12
 
13
+ The primary image API is `createMotifImage` (`@howells/motif-sdk/image`) — provider-agnostic generate/edit across google, openai, replicate, and fal. See [Image Layer](#image-layer-howellsmotif-sdkimage) below.
14
+
15
+ The examples in this section use the low-level `FalClient`, the fal-native client for fal-specific capabilities (queue, upload, upscale, background removal, video, and utility tools).
16
+
13
17
  ```ts
14
- import { MotifServer } from "@howells/motif-sdk";
18
+ import { FalClient } from "@howells/motif-sdk";
15
19
 
16
- const motif = new MotifServer({
20
+ const motif = new FalClient({
17
21
  apiKey: process.env.FAL_KEY!,
18
22
  retries: 3,
19
23
  timeout: 120_000,
@@ -103,7 +107,8 @@ const videoJob = await motif.submitVideo({
103
107
 
104
108
  ## Main Exports
105
109
 
106
- - `MotifServer` - Result-returning fal client for generation, queue jobs, upload, utility tools, and payload deletion.
110
+ - `createMotifImage` (`@howells/motif-sdk/image`) - the primary image API: provider-agnostic generate/edit/best-of-N across google, openai, replicate, and fal.
111
+ - `FalClient` - low-level fal-native client for generation, queue jobs, upload, utility tools, and payload deletion.
107
112
  - `buildGenerateBody` - Pure fal request normalization for dry runs and tests.
108
113
  - `MODELS`, `GENERATION_MODELS`, `UTILITY_MODELS`, `VIDEO_MODELS` - Motif model aliases, fal endpoints, capabilities, pricing, and benchmarks.
109
114
  - `FAL_TOOLS`, `FAL_TOOL_IDS`, `buildFalToolRequest`, `isFalToolId` - Normalized fal utility endpoints such as SAM, depth, upscaling, moderation, and background removal.
@@ -119,13 +124,13 @@ The package exports public types for generation, processing, queue, metadata, an
119
124
 
120
125
  - `GenerateOptions`, `MotifResponse`, `MotifImage`
121
126
  - `UpscaleOptions`, `RemoveBackgroundOptions`, `VideoOptions`, `VideoResponse`
122
- - `QueuedJob`, `JobStatus`, `MotifServerConfig`
127
+ - `QueuedJob`, `JobStatus`, `FalClientConfig`
123
128
  - `ModelConfig`, `AspectRatio`, `Resolution`, `ImageSize`, `ImageQuality`, `BackgroundMode`, `ThinkingLevel`
124
129
  - `FalToolConfig`, `FalToolId`, `FalToolRequest`, `FalToolRunOptions`
125
130
 
126
131
  ## Image Layer (`@howells/motif-sdk/image`)
127
132
 
128
- A provider-agnostic image generation + editing layer, additive to the fal-specific `MotifServer` surface above. It is an ESM-only subpath export, built on the Vercel AI SDK image interface (`ai`'s `generateImage`).
133
+ The primary, provider-agnostic image generation + editing layer — the recommended way to generate and edit images. The fal-specific `FalClient` surface above stays for fal-native extras. It is an ESM-only subpath export, built on the Vercel AI SDK image interface (`ai`'s `generateImage`).
129
134
 
130
135
  ```bash
131
136
  npm install @howells/motif-sdk
package/dist/image.d.ts CHANGED
@@ -14,7 +14,7 @@ declare class MotifError extends Error {
14
14
  * Public types for the provider-agnostic image generation + editing layer
15
15
  * (`@howells/motif-sdk/image`).
16
16
  *
17
- * This layer is additive: it sits alongside the fal-specific `MotifServer`
17
+ * This layer is additive: it sits alongside the fal-specific `FalClient`
18
18
  * surface and reuses the SDK's Result convention (`Result<T, MotifError>` — no
19
19
  * thrown exceptions). See docs/design/provider-agnostic-image-layer.md.
20
20
  */
@@ -364,7 +364,7 @@ declare const REPLICATE_API_KEY_ENV = "REPLICATE_API_TOKEN";
364
364
  * Builds a Vercel AI SDK `ImageModel` from `@ai-sdk/fal`. Building a model
365
365
  * performs no network I/O — the request only happens when `generateImage`
366
366
  * invokes `model.doGenerate`. This is the lightweight fal *image* adapter; the
367
- * richer `MotifServer` fal client (queue, upload, upscale, rmbg, video, tools)
367
+ * richer `FalClient` fal client (queue, upload, upscale, rmbg, video, tools)
368
368
  * is a separate, later fold (design doc §8, phase 1d).
369
369
  *
370
370
  * ENDPOINT QUIRK (Phase 0): fal's gpt-image endpoint wants `image_size` as a
@@ -416,7 +416,7 @@ declare function costForImages(provider: ImageProviderId, modelId: string, provi
416
416
  * `@howells/motif-sdk/image` — provider-agnostic image generation + editing.
417
417
  *
418
418
  * ESM-only subpath export, built on the Vercel AI SDK image interface
419
- * (`generateImage`, `@ai-sdk/*`). Additive to the fal-specific `MotifServer`
419
+ * (`generateImage`, `@ai-sdk/*`). Additive to the fal-specific `FalClient`
420
420
  * surface; reuses the SDK's Result convention (`Result<T, MotifError>` — no
421
421
  * thrown exceptions). Google (Gemini) is the only provider in Phase 1a.
422
422
  *
package/dist/index.cjs CHANGED
@@ -29,13 +29,13 @@ __export(src_exports, {
29
29
  FAL_TOOLS_CHECKED_AT: () => FAL_TOOLS_CHECKED_AT,
30
30
  FAL_TOOL_IDS: () => FAL_TOOL_IDS,
31
31
  FORMAT_PRESETS: () => FORMAT_PRESETS,
32
+ FalClient: () => FalClient,
32
33
  GENERATION_MODELS: () => GENERATION_MODELS,
33
34
  IDEOGRAM_STYLES: () => IDEOGRAM_STYLES,
34
35
  IMAGE_EDITING_TOP_20: () => IMAGE_EDITING_TOP_20,
35
36
  IMAGE_TEXT_TO_IMAGE_TOP_20: () => IMAGE_TEXT_TO_IMAGE_TOP_20,
36
37
  MODELS: () => MODELS,
37
38
  MotifError: () => MotifError,
38
- MotifServer: () => MotifServer,
39
39
  RECRAFT_STYLES: () => RECRAFT_STYLES,
40
40
  RESOLUTIONS: () => RESOLUTIONS,
41
41
  UTILITY_MODELS: () => UTILITY_MODELS,
@@ -2714,7 +2714,7 @@ var FAL_BASE_URL = "https://fal.run";
2714
2714
  var FAL_QUEUE_URL = "https://queue.fal.run";
2715
2715
  var FAL_API_URL = "https://api.fal.ai";
2716
2716
  var FAL_REST_URL = "https://rest.alpha.fal.ai";
2717
- var MotifServer = class {
2717
+ var FalClient = class {
2718
2718
  apiKey;
2719
2719
  timeout;
2720
2720
  retries;
@@ -3269,13 +3269,13 @@ function toMotifError(error) {
3269
3269
  FAL_TOOLS_CHECKED_AT,
3270
3270
  FAL_TOOL_IDS,
3271
3271
  FORMAT_PRESETS,
3272
+ FalClient,
3272
3273
  GENERATION_MODELS,
3273
3274
  IDEOGRAM_STYLES,
3274
3275
  IMAGE_EDITING_TOP_20,
3275
3276
  IMAGE_TEXT_TO_IMAGE_TOP_20,
3276
3277
  MODELS,
3277
3278
  MotifError,
3278
- MotifServer,
3279
3279
  RECRAFT_STYLES,
3280
3280
  RESOLUTIONS,
3281
3281
  UTILITY_MODELS,
package/dist/index.d.cts CHANGED
@@ -388,7 +388,7 @@ interface JobStatus {
388
388
  status: "queued" | "processing" | "completed" | "failed";
389
389
  }
390
390
  /** ─── Configuration ──────────────────────────────────────────── */
391
- interface MotifServerConfig {
391
+ interface FalClientConfig {
392
392
  apiKey: string;
393
393
  /** Max retry attempts for 429/5xx errors (default 3, set 0 to disable) */
394
394
  retries?: number;
@@ -475,16 +475,20 @@ declare const RECRAFT_STYLES: readonly ["realistic_image", "realistic_image/b_an
475
475
  declare const IDEOGRAM_STYLES: readonly ["AUTO", "GENERAL", "REALISTIC", "DESIGN"];
476
476
 
477
477
  /**
478
- * Motif Server SDK
478
+ * FalClient — the fal-native client.
479
+ *
480
+ * The low-level, fal-specific client for AI image generation and fal utilities
481
+ * (queue, upload, upscale, rmbg, video, tools, generate). Pairs with the
482
+ * provider-agnostic `createMotifImage` (`@howells/motif-sdk/image`) as the
483
+ * fal-native entry point.
479
484
  *
480
- * Server-side SDK for AI image generation via fal.ai.
481
485
  * All async methods return `Result<T, MotifError>` — no thrown exceptions.
482
486
  *
483
487
  * @example
484
488
  * ```typescript
485
- * import { MotifServer } from "./fal";
489
+ * import { FalClient } from "./fal";
486
490
  *
487
- * const motif = new MotifServer(process.env.FAL_KEY!);
491
+ * const motif = new FalClient(process.env.FAL_KEY!);
488
492
  * const result = await motif.generate({ prompt: "a red balloon", model: "banana" });
489
493
  *
490
494
  * if (result.isOk()) {
@@ -494,11 +498,11 @@ declare const IDEOGRAM_STYLES: readonly ["AUTO", "GENERAL", "REALISTIC", "DESIGN
494
498
  * }
495
499
  * ```
496
500
  */
497
- declare class MotifServer {
501
+ declare class FalClient {
498
502
  private readonly apiKey;
499
503
  private readonly timeout;
500
504
  private readonly retries;
501
- constructor(config: MotifServerConfig | string);
505
+ constructor(config: FalClientConfig | string);
502
506
  /** ─── Synchronous Generation ──────────────────────────────── */
503
507
  /** Generate images synchronously (blocks until fal.ai returns). */
504
508
  generate(options: GenerateOptions): Promise<Result<MotifResponse, MotifError>>;
@@ -1320,4 +1324,4 @@ type FalToolId = (typeof FAL_TOOL_IDS)[number];
1320
1324
  declare function isFalToolId(tool: string): tool is FalToolId;
1321
1325
  declare function buildFalToolRequest(options: FalToolRunOptions): FalToolRequest;
1322
1326
 
1323
- 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, FORMAT_PRESETS, type FalImageSizePreset, type FalToolConfig, type FalToolId, type FalToolInputKind, 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, MODELS, type ModelConfig, type ModelType, type MotifEnv, MotifError, type MotifImage, type MotifResponse, MotifServer, type MotifServerConfig, type QueuedJob, RECRAFT_STYLES, RESOLUTIONS, type RemoveBackgroundOptions, type Resolution, 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, enrichPrompt, estimateCost, estimateVideoCost, getFalKeyFromEnv, isFalToolId, motifEnvSchema, parseMotifEnv, sanitizePrompt };
1327
+ 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, FORMAT_PRESETS, FalClient, type FalClientConfig, type FalImageSizePreset, type FalToolConfig, type FalToolId, type FalToolInputKind, 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, MODELS, type ModelConfig, type ModelType, type MotifEnv, MotifError, type MotifImage, type MotifResponse, type QueuedJob, RECRAFT_STYLES, RESOLUTIONS, type RemoveBackgroundOptions, type Resolution, 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, enrichPrompt, estimateCost, estimateVideoCost, getFalKeyFromEnv, isFalToolId, motifEnvSchema, parseMotifEnv, sanitizePrompt };
package/dist/index.d.ts CHANGED
@@ -388,7 +388,7 @@ interface JobStatus {
388
388
  status: "queued" | "processing" | "completed" | "failed";
389
389
  }
390
390
  /** ─── Configuration ──────────────────────────────────────────── */
391
- interface MotifServerConfig {
391
+ interface FalClientConfig {
392
392
  apiKey: string;
393
393
  /** Max retry attempts for 429/5xx errors (default 3, set 0 to disable) */
394
394
  retries?: number;
@@ -475,16 +475,20 @@ declare const RECRAFT_STYLES: readonly ["realistic_image", "realistic_image/b_an
475
475
  declare const IDEOGRAM_STYLES: readonly ["AUTO", "GENERAL", "REALISTIC", "DESIGN"];
476
476
 
477
477
  /**
478
- * Motif Server SDK
478
+ * FalClient — the fal-native client.
479
+ *
480
+ * The low-level, fal-specific client for AI image generation and fal utilities
481
+ * (queue, upload, upscale, rmbg, video, tools, generate). Pairs with the
482
+ * provider-agnostic `createMotifImage` (`@howells/motif-sdk/image`) as the
483
+ * fal-native entry point.
479
484
  *
480
- * Server-side SDK for AI image generation via fal.ai.
481
485
  * All async methods return `Result<T, MotifError>` — no thrown exceptions.
482
486
  *
483
487
  * @example
484
488
  * ```typescript
485
- * import { MotifServer } from "./fal";
489
+ * import { FalClient } from "./fal";
486
490
  *
487
- * const motif = new MotifServer(process.env.FAL_KEY!);
491
+ * const motif = new FalClient(process.env.FAL_KEY!);
488
492
  * const result = await motif.generate({ prompt: "a red balloon", model: "banana" });
489
493
  *
490
494
  * if (result.isOk()) {
@@ -494,11 +498,11 @@ declare const IDEOGRAM_STYLES: readonly ["AUTO", "GENERAL", "REALISTIC", "DESIGN
494
498
  * }
495
499
  * ```
496
500
  */
497
- declare class MotifServer {
501
+ declare class FalClient {
498
502
  private readonly apiKey;
499
503
  private readonly timeout;
500
504
  private readonly retries;
501
- constructor(config: MotifServerConfig | string);
505
+ constructor(config: FalClientConfig | string);
502
506
  /** ─── Synchronous Generation ──────────────────────────────── */
503
507
  /** Generate images synchronously (blocks until fal.ai returns). */
504
508
  generate(options: GenerateOptions): Promise<Result<MotifResponse, MotifError>>;
@@ -1320,4 +1324,4 @@ type FalToolId = (typeof FAL_TOOL_IDS)[number];
1320
1324
  declare function isFalToolId(tool: string): tool is FalToolId;
1321
1325
  declare function buildFalToolRequest(options: FalToolRunOptions): FalToolRequest;
1322
1326
 
1323
- 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, FORMAT_PRESETS, type FalImageSizePreset, type FalToolConfig, type FalToolId, type FalToolInputKind, 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, MODELS, type ModelConfig, type ModelType, type MotifEnv, MotifError, type MotifImage, type MotifResponse, MotifServer, type MotifServerConfig, type QueuedJob, RECRAFT_STYLES, RESOLUTIONS, type RemoveBackgroundOptions, type Resolution, 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, enrichPrompt, estimateCost, estimateVideoCost, getFalKeyFromEnv, isFalToolId, motifEnvSchema, parseMotifEnv, sanitizePrompt };
1327
+ 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, FORMAT_PRESETS, FalClient, type FalClientConfig, type FalImageSizePreset, type FalToolConfig, type FalToolId, type FalToolInputKind, 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, MODELS, type ModelConfig, type ModelType, type MotifEnv, MotifError, type MotifImage, type MotifResponse, type QueuedJob, RECRAFT_STYLES, RESOLUTIONS, type RemoveBackgroundOptions, type Resolution, 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, enrichPrompt, estimateCost, estimateVideoCost, getFalKeyFromEnv, isFalToolId, motifEnvSchema, parseMotifEnv, sanitizePrompt };
package/dist/index.js CHANGED
@@ -2655,7 +2655,7 @@ var FAL_BASE_URL = "https://fal.run";
2655
2655
  var FAL_QUEUE_URL = "https://queue.fal.run";
2656
2656
  var FAL_API_URL = "https://api.fal.ai";
2657
2657
  var FAL_REST_URL = "https://rest.alpha.fal.ai";
2658
- var MotifServer = class {
2658
+ var FalClient = class {
2659
2659
  apiKey;
2660
2660
  timeout;
2661
2661
  retries;
@@ -3209,13 +3209,13 @@ export {
3209
3209
  FAL_TOOLS_CHECKED_AT,
3210
3210
  FAL_TOOL_IDS,
3211
3211
  FORMAT_PRESETS,
3212
+ FalClient,
3212
3213
  GENERATION_MODELS,
3213
3214
  IDEOGRAM_STYLES,
3214
3215
  IMAGE_EDITING_TOP_20,
3215
3216
  IMAGE_TEXT_TO_IMAGE_TOP_20,
3216
3217
  MODELS,
3217
3218
  MotifError,
3218
- MotifServer,
3219
3219
  RECRAFT_STYLES,
3220
3220
  RESOLUTIONS,
3221
3221
  UTILITY_MODELS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@howells/motif-sdk",
3
- "version": "0.11.0",
3
+ "version": "1.0.0",
4
4
  "description": "Public Node SDK for Motif fal.ai generation, editing, utility tools, and model metadata.",
5
5
  "keywords": [
6
6
  "fal",