@ai-sdk/luma 3.0.0-beta.30 → 3.0.0-beta.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @ai-sdk/luma
2
2
 
3
+ ## 3.0.0-beta.31
4
+
5
+ ### Major Changes
6
+
7
+ - 04e9009: chore: make provider implementations code patterns more consistent, including renaming certain exported symbols
8
+
9
+ For all externally exported symbols that were renamed, the old names continue to work via deprecated aliases.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [08d2129]
14
+ - @ai-sdk/provider-utils@5.0.0-beta.30
15
+
3
16
  ## 3.0.0-beta.30
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -54,6 +54,7 @@ declare const lumaErrorSchema: z.ZodObject<{
54
54
  }, z.core.$strip>>;
55
55
  }, z.core.$strip>;
56
56
  type LumaErrorData = z.infer<typeof lumaErrorSchema>;
57
+
57
58
  /**
58
59
  * Provider options schema for Luma image generation.
59
60
  *
package/dist/index.js CHANGED
@@ -21,14 +21,68 @@ import {
21
21
  delay,
22
22
  getFromApi,
23
23
  postJsonToApi,
24
- lazySchema,
24
+ lazySchema as lazySchema2,
25
25
  parseProviderOptions,
26
- zodSchema,
26
+ zodSchema as zodSchema2,
27
27
  serializeModelOptions,
28
28
  WORKFLOW_SERIALIZE,
29
29
  WORKFLOW_DESERIALIZE
30
30
  } from "@ai-sdk/provider-utils";
31
+
32
+ // src/luma-image-model-options.ts
33
+ import {
34
+ lazySchema,
35
+ zodSchema
36
+ } from "@ai-sdk/provider-utils";
31
37
  import { z } from "zod/v4";
38
+ var lumaImageModelOptionsSchema = lazySchema(
39
+ () => zodSchema(
40
+ z.object({
41
+ /**
42
+ * The type of image reference to use when providing input images.
43
+ * - `image`: Guide generation using reference images (up to 4). Default.
44
+ * - `style`: Apply a specific style from reference image(s).
45
+ * - `character`: Create consistent characters from reference images (up to 4).
46
+ * - `modify_image`: Transform a single input image with prompt guidance.
47
+ */
48
+ referenceType: z.enum(["image", "style", "character", "modify_image"]).nullish(),
49
+ /**
50
+ * Per-image configuration array. Each entry corresponds to an image in `prompt.images`.
51
+ * Allows setting individual weights for each reference image.
52
+ */
53
+ images: z.array(
54
+ z.object({
55
+ /**
56
+ * The weight of this image's influence on the generation.
57
+ * - For `image`: Higher weight = closer to reference (default: 0.85)
58
+ * - For `style`: Higher weight = stronger style influence (default: 0.8)
59
+ * - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)
60
+ */
61
+ weight: z.number().min(0).max(1).nullish(),
62
+ /**
63
+ * The identity name for character references.
64
+ * Used with `character` to specify which identity group the image belongs to.
65
+ * Luma supports multiple identities (e.g., 'identity0', 'identity1') for generating
66
+ * images with multiple consistent characters.
67
+ * Default: 'identity0'
68
+ */
69
+ id: z.string().nullish()
70
+ })
71
+ ).nullish(),
72
+ /**
73
+ * Override the polling interval in milliseconds (default 500).
74
+ */
75
+ pollIntervalMillis: z.number().nullish(),
76
+ /**
77
+ * Override the maximum number of polling attempts (default 120).
78
+ */
79
+ maxPollAttempts: z.number().nullish()
80
+ }).passthrough()
81
+ )
82
+ );
83
+
84
+ // src/luma-image-model.ts
85
+ import { z as z2 } from "zod/v4";
32
86
  var DEFAULT_POLL_INTERVAL_MILLIS = 500;
33
87
  var DEFAULT_MAX_POLL_ATTEMPTS = 6e4 / DEFAULT_POLL_INTERVAL_MILLIS;
34
88
  var LumaImageModel = class _LumaImageModel {
@@ -286,80 +340,35 @@ var LumaImageModel = class _LumaImageModel {
286
340
  return response;
287
341
  }
288
342
  };
289
- var lumaGenerationResponseSchema = lazySchema(
290
- () => zodSchema(
291
- z.object({
292
- id: z.string(),
293
- state: z.enum(["queued", "dreaming", "completed", "failed"]),
294
- failure_reason: z.string().nullish(),
295
- assets: z.object({
296
- image: z.string()
343
+ var lumaGenerationResponseSchema = lazySchema2(
344
+ () => zodSchema2(
345
+ z2.object({
346
+ id: z2.string(),
347
+ state: z2.enum(["queued", "dreaming", "completed", "failed"]),
348
+ failure_reason: z2.string().nullish(),
349
+ assets: z2.object({
350
+ image: z2.string()
297
351
  // URL of the generated image
298
352
  }).nullish()
299
353
  })
300
354
  )
301
355
  );
302
- var lumaErrorSchema = z.object({
303
- detail: z.array(
304
- z.object({
305
- type: z.string(),
306
- loc: z.array(z.string()),
307
- msg: z.string(),
308
- input: z.string(),
309
- ctx: z.object({
310
- expected: z.string()
356
+ var lumaErrorSchema = z2.object({
357
+ detail: z2.array(
358
+ z2.object({
359
+ type: z2.string(),
360
+ loc: z2.array(z2.string()),
361
+ msg: z2.string(),
362
+ input: z2.string(),
363
+ ctx: z2.object({
364
+ expected: z2.string()
311
365
  }).nullish()
312
366
  })
313
367
  )
314
368
  });
315
- var lumaImageModelOptionsSchema = lazySchema(
316
- () => zodSchema(
317
- z.object({
318
- /**
319
- * The type of image reference to use when providing input images.
320
- * - `image`: Guide generation using reference images (up to 4). Default.
321
- * - `style`: Apply a specific style from reference image(s).
322
- * - `character`: Create consistent characters from reference images (up to 4).
323
- * - `modify_image`: Transform a single input image with prompt guidance.
324
- */
325
- referenceType: z.enum(["image", "style", "character", "modify_image"]).nullish(),
326
- /**
327
- * Per-image configuration array. Each entry corresponds to an image in `prompt.images`.
328
- * Allows setting individual weights for each reference image.
329
- */
330
- images: z.array(
331
- z.object({
332
- /**
333
- * The weight of this image's influence on the generation.
334
- * - For `image`: Higher weight = closer to reference (default: 0.85)
335
- * - For `style`: Higher weight = stronger style influence (default: 0.8)
336
- * - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)
337
- */
338
- weight: z.number().min(0).max(1).nullish(),
339
- /**
340
- * The identity name for character references.
341
- * Used with `character` to specify which identity group the image belongs to.
342
- * Luma supports multiple identities (e.g., 'identity0', 'identity1') for generating
343
- * images with multiple consistent characters.
344
- * Default: 'identity0'
345
- */
346
- id: z.string().nullish()
347
- })
348
- ).nullish(),
349
- /**
350
- * Override the polling interval in milliseconds (default 500).
351
- */
352
- pollIntervalMillis: z.number().nullish(),
353
- /**
354
- * Override the maximum number of polling attempts (default 120).
355
- */
356
- maxPollAttempts: z.number().nullish()
357
- }).passthrough()
358
- )
359
- );
360
369
 
361
370
  // src/version.ts
362
- var VERSION = true ? "3.0.0-beta.30" : "0.0.0-test";
371
+ var VERSION = true ? "3.0.0-beta.31" : "0.0.0-test";
363
372
 
364
373
  // src/luma-provider.ts
365
374
  var defaultBaseURL = "https://api.lumalabs.ai";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/luma-provider.ts","../src/luma-image-model.ts","../src/version.ts"],"sourcesContent":["import {\n NoSuchModelError,\n type ImageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { LumaImageModel } from './luma-image-model';\nimport type { LumaImageModelId } from './luma-image-settings';\nimport { VERSION } from './version';\n\nexport interface LumaProviderSettings {\n /**\n * Luma API key. Default value is taken from the `LUMA_API_KEY` environment\n * variable.\n */\n apiKey?: string;\n /**\n * Base URL for the API calls.\n */\n baseURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface LumaProvider extends ProviderV4 {\n /**\n * Creates a model for image generation.\n */\n image(modelId: LumaImageModelId): ImageModelV4;\n\n /**\n * Creates a model for image generation.\n */\n imageModel(modelId: LumaImageModelId): ImageModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nconst defaultBaseURL = 'https://api.lumalabs.ai';\n\nexport function createLuma(options: LumaProviderSettings = {}): LumaProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'LUMA_API_KEY',\n description: 'Luma',\n })}`,\n ...options.headers,\n },\n `ai-sdk/luma/${VERSION}`,\n );\n\n const createImageModel = (modelId: LumaImageModelId) =>\n new LumaImageModel(modelId, {\n provider: 'luma.image',\n baseURL: baseURL ?? defaultBaseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n };\n\n return {\n specificationVersion: 'v4' as const,\n image: createImageModel,\n imageModel: createImageModel,\n languageModel: (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'languageModel',\n });\n },\n embeddingModel,\n textEmbeddingModel: embeddingModel,\n };\n}\n\nexport const luma = createLuma();\n","import {\n InvalidResponseDataError,\n type ImageModelV4,\n type ImageModelV4File,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createBinaryResponseHandler,\n createJsonResponseHandler,\n createJsonErrorResponseHandler,\n createStatusCodeErrorResponseHandler,\n delay,\n getFromApi,\n postJsonToApi,\n lazySchema,\n parseProviderOptions,\n zodSchema,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n type FetchFunction,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport type { LumaReferenceType } from './luma-image-settings';\nimport { z } from 'zod/v4';\n\nconst DEFAULT_POLL_INTERVAL_MILLIS = 500;\nconst DEFAULT_MAX_POLL_ATTEMPTS = 60000 / DEFAULT_POLL_INTERVAL_MILLIS;\n\ninterface LumaImageModelConfig {\n provider: string;\n baseURL: string;\n headers?: () => Record<string, string>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class LumaImageModel implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly maxImagesPerCall = 1;\n readonly pollIntervalMillis = DEFAULT_POLL_INTERVAL_MILLIS;\n readonly maxPollAttempts = DEFAULT_MAX_POLL_ATTEMPTS;\n\n get provider(): string {\n return this.config.provider;\n }\n\n static [WORKFLOW_SERIALIZE](model: LumaImageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: string;\n config: LumaImageModelConfig;\n }) {\n return new LumaImageModel(options.modelId, options.config);\n }\n\n constructor(\n readonly modelId: string,\n private readonly config: LumaImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n files,\n mask,\n }: Parameters<ImageModelV4['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV4['doGenerate']>>\n > {\n const warnings: Array<SharedV4Warning> = [];\n\n if (seed != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'seed',\n details: 'This model does not support the `seed` option.',\n });\n }\n\n if (size != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'size',\n details:\n 'This model does not support the `size` option. Use `aspectRatio` instead.',\n });\n }\n\n // Parse and validate provider options\n const lumaOptions = await parseProviderOptions({\n provider: 'luma',\n providerOptions,\n schema: lumaImageModelOptionsSchema,\n });\n\n // Extract non-request options\n const {\n pollIntervalMillis,\n maxPollAttempts,\n referenceType,\n images: imageConfigs,\n ...providerRequestOptions\n } = lumaOptions ?? {};\n\n // Handle image editing via files with reference type support\n const editingOptions = this.getEditingOptions(\n files,\n mask,\n referenceType ?? undefined,\n imageConfigs ?? [],\n );\n\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const fullHeaders = combineHeaders(this.config.headers?.(), headers);\n const { value: generationResponse, responseHeaders } = await postJsonToApi({\n url: this.getLumaGenerationsUrl(),\n headers: fullHeaders,\n body: {\n prompt,\n ...(aspectRatio ? { aspect_ratio: aspectRatio } : {}),\n model: this.modelId,\n ...editingOptions,\n ...providerRequestOptions,\n },\n abortSignal,\n fetch: this.config.fetch,\n failedResponseHandler: this.createLumaErrorHandler(),\n successfulResponseHandler: createJsonResponseHandler(\n lumaGenerationResponseSchema,\n ),\n });\n\n const imageUrl = await this.pollForImageUrl(\n generationResponse.id,\n fullHeaders,\n abortSignal,\n {\n pollIntervalMillis: pollIntervalMillis ?? undefined,\n maxPollAttempts: maxPollAttempts ?? undefined,\n },\n );\n\n const downloadedImage = await this.downloadImage(imageUrl, abortSignal);\n\n return {\n images: [downloadedImage],\n warnings,\n response: {\n modelId: this.modelId,\n timestamp: currentDate,\n headers: responseHeaders,\n },\n };\n }\n\n private async pollForImageUrl(\n generationId: string,\n headers: Record<string, string | undefined>,\n abortSignal: AbortSignal | undefined,\n pollSettings?: { pollIntervalMillis?: number; maxPollAttempts?: number },\n ): Promise<string> {\n const url = this.getLumaGenerationsUrl(generationId);\n const maxPollAttempts =\n pollSettings?.maxPollAttempts ?? this.maxPollAttempts;\n const pollIntervalMillis =\n pollSettings?.pollIntervalMillis ?? this.pollIntervalMillis;\n\n for (let i = 0; i < maxPollAttempts; i++) {\n const { value: statusResponse } = await getFromApi({\n url,\n headers,\n abortSignal,\n fetch: this.config.fetch,\n failedResponseHandler: this.createLumaErrorHandler(),\n successfulResponseHandler: createJsonResponseHandler(\n lumaGenerationResponseSchema,\n ),\n });\n\n switch (statusResponse.state) {\n case 'completed':\n if (!statusResponse.assets?.image) {\n throw new InvalidResponseDataError({\n data: statusResponse,\n message: `Image generation completed but no image was found.`,\n });\n }\n return statusResponse.assets.image;\n case 'failed':\n throw new InvalidResponseDataError({\n data: statusResponse,\n message: `Image generation failed.`,\n });\n }\n await delay(pollIntervalMillis);\n }\n\n throw new Error(\n `Image generation timed out after ${this.maxPollAttempts} attempts.`,\n );\n }\n\n private createLumaErrorHandler() {\n return createJsonErrorResponseHandler({\n errorSchema: lumaErrorSchema,\n errorToMessage: (error: LumaErrorData) =>\n error.detail[0].msg ?? 'Unknown error',\n });\n }\n\n private getEditingOptions(\n files: ImageModelV4File[] | undefined,\n mask: ImageModelV4File | undefined,\n referenceType: LumaReferenceType = 'image',\n imageConfigs: Array<{ weight?: number | null; id?: string | null }> = [],\n ): Record<string, unknown> {\n const options: Record<string, unknown> = {};\n\n // Luma does not support mask-based inpainting\n if (mask != null) {\n throw new Error(\n 'Luma AI does not support mask-based image editing. ' +\n 'Use the prompt to describe the changes you want to make, along with ' +\n '`prompt.images` containing the source image URL.',\n );\n }\n\n if (files == null || files.length === 0) {\n return options;\n }\n\n // Validate all files are URL-based\n for (const file of files) {\n if (file.type !== 'url') {\n throw new Error(\n 'Luma AI only supports URL-based images. ' +\n 'Please provide image URLs using `prompt.images` with publicly accessible URLs. ' +\n 'Base64 and Uint8Array data are not supported.',\n );\n }\n }\n\n // Default weights per reference type\n const defaultWeights: Record<LumaReferenceType, number> = {\n image: 0.85,\n style: 0.8,\n character: 1.0, // Not used, but defined for completeness\n modify_image: 1.0,\n };\n\n switch (referenceType) {\n case 'image': {\n // Supports up to 4 images\n if (files.length > 4) {\n throw new Error(\n 'Luma AI image supports up to 4 reference images. ' +\n `You provided ${files.length} images.`,\n );\n }\n options.image = files.map((file, index) => ({\n url: (file as { type: 'url'; url: string }).url,\n weight: imageConfigs[index]?.weight ?? defaultWeights.image,\n }));\n break;\n }\n\n case 'style': {\n // Style ref accepts an array but typically uses one style image\n options.style = files.map((file, index) => ({\n url: (file as { type: 'url'; url: string }).url,\n weight: imageConfigs[index]?.weight ?? defaultWeights.style,\n }));\n break;\n }\n\n case 'character': {\n // Group images by identity id\n const identities: Record<string, string[]> = {};\n for (let i = 0; i < files.length; i++) {\n const file = files[i] as { type: 'url'; url: string };\n const identityId = imageConfigs[i]?.id ?? 'identity0';\n if (!identities[identityId]) {\n identities[identityId] = [];\n }\n identities[identityId].push(file.url);\n }\n\n // Validate each identity has at most 4 images\n for (const [identityId, images] of Object.entries(identities)) {\n if (images.length > 4) {\n throw new Error(\n `Luma AI character supports up to 4 images per identity. ` +\n `Identity '${identityId}' has ${images.length} images.`,\n );\n }\n }\n\n options.character = Object.fromEntries(\n Object.entries(identities).map(([id, images]) => [id, { images }]),\n );\n break;\n }\n\n case 'modify_image': {\n // Only supports a single image\n if (files.length > 1) {\n throw new Error(\n 'Luma AI modify_image only supports a single input image. ' +\n `You provided ${files.length} images.`,\n );\n }\n options.modify_image = {\n url: (files[0] as { type: 'url'; url: string }).url,\n weight: imageConfigs[0]?.weight ?? defaultWeights.modify_image,\n };\n break;\n }\n }\n\n return options;\n }\n\n private getLumaGenerationsUrl(generationId?: string) {\n return `${this.config.baseURL}/dream-machine/v1/generations/${\n generationId ?? 'image'\n }`;\n }\n\n private async downloadImage(\n url: string,\n abortSignal: AbortSignal | undefined,\n ): Promise<Uint8Array> {\n const { value: response } = await getFromApi({\n url,\n // No specific headers should be needed for this request as it's a\n // generated image provided by Luma.\n abortSignal,\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createBinaryResponseHandler(),\n fetch: this.config.fetch,\n });\n return response;\n }\n}\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst lumaGenerationResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string(),\n state: z.enum(['queued', 'dreaming', 'completed', 'failed']),\n failure_reason: z.string().nullish(),\n assets: z\n .object({\n image: z.string(), // URL of the generated image\n })\n .nullish(),\n }),\n ),\n);\n\nconst lumaErrorSchema = z.object({\n detail: z.array(\n z.object({\n type: z.string(),\n loc: z.array(z.string()),\n msg: z.string(),\n input: z.string(),\n ctx: z\n .object({\n expected: z.string(),\n })\n .nullish(),\n }),\n ),\n});\n\nexport type LumaErrorData = z.infer<typeof lumaErrorSchema>;\n\n/**\n * Provider options schema for Luma image generation.\n *\n * @see https://docs.lumalabs.ai/docs/image-generation\n */\nexport const lumaImageModelOptionsSchema = lazySchema(() =>\n zodSchema(\n z\n .object({\n /**\n * The type of image reference to use when providing input images.\n * - `image`: Guide generation using reference images (up to 4). Default.\n * - `style`: Apply a specific style from reference image(s).\n * - `character`: Create consistent characters from reference images (up to 4).\n * - `modify_image`: Transform a single input image with prompt guidance.\n */\n referenceType: z\n .enum(['image', 'style', 'character', 'modify_image'])\n .nullish(),\n\n /**\n * Per-image configuration array. Each entry corresponds to an image in `prompt.images`.\n * Allows setting individual weights for each reference image.\n */\n images: z\n .array(\n z.object({\n /**\n * The weight of this image's influence on the generation.\n * - For `image`: Higher weight = closer to reference (default: 0.85)\n * - For `style`: Higher weight = stronger style influence (default: 0.8)\n * - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)\n */\n weight: z.number().min(0).max(1).nullish(),\n\n /**\n * The identity name for character references.\n * Used with `character` to specify which identity group the image belongs to.\n * Luma supports multiple identities (e.g., 'identity0', 'identity1') for generating\n * images with multiple consistent characters.\n * Default: 'identity0'\n */\n id: z.string().nullish(),\n }),\n )\n .nullish(),\n\n /**\n * Override the polling interval in milliseconds (default 500).\n */\n pollIntervalMillis: z.number().nullish(),\n\n /**\n * Override the maximum number of polling attempts (default 120).\n */\n maxPollAttempts: z.number().nullish(),\n })\n .passthrough(),\n ),\n);\n\nexport type LumaImageModelOptions = InferSchema<\n typeof lumaImageModelOptionsSchema\n>;\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACVP;AAAA,EACE;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,SAAS;AAElB,IAAM,+BAA+B;AACrC,IAAM,4BAA4B,MAAQ;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AmB,CAAC,YACxB,IAAI,eAAe,SAAS;AAAA,IAC1B,UAAU;AAAA,IACV,SAAS,4BAAW;AAAA,IACpB,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB,CAAC;AAEH,QAAM,iBAAiB,CAAC,YAAoB;AAC1C,UAAM,IAAI,iBAAiB;AAAA,MACzB;AAAA,MACA,WAAW;AAAA,IACb,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,sBAAsB;AAAA,IACtB,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,eAAe,CAAC,YAAoB;AAClC,YAAM,IAAI,iBAAiB;AAAA,QACzB;AAAA,QACA,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAAA,IACA;AAAA,IACA,oBAAoB;AAAA,EACtB;AACF;AAEO,IAAM,OAAO,WAAW;","names":["_a","_b"]}
1
+ {"version":3,"sources":["../src/luma-provider.ts","../src/luma-image-model.ts","../src/luma-image-model-options.ts","../src/version.ts"],"sourcesContent":["import {\n NoSuchModelError,\n type ImageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { LumaImageModel } from './luma-image-model';\nimport type { LumaImageModelId } from './luma-image-settings';\nimport { VERSION } from './version';\n\nexport interface LumaProviderSettings {\n /**\n * Luma API key. Default value is taken from the `LUMA_API_KEY` environment\n * variable.\n */\n apiKey?: string;\n /**\n * Base URL for the API calls.\n */\n baseURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface LumaProvider extends ProviderV4 {\n /**\n * Creates a model for image generation.\n */\n image(modelId: LumaImageModelId): ImageModelV4;\n\n /**\n * Creates a model for image generation.\n */\n imageModel(modelId: LumaImageModelId): ImageModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nconst defaultBaseURL = 'https://api.lumalabs.ai';\n\nexport function createLuma(options: LumaProviderSettings = {}): LumaProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'LUMA_API_KEY',\n description: 'Luma',\n })}`,\n ...options.headers,\n },\n `ai-sdk/luma/${VERSION}`,\n );\n\n const createImageModel = (modelId: LumaImageModelId) =>\n new LumaImageModel(modelId, {\n provider: 'luma.image',\n baseURL: baseURL ?? defaultBaseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n };\n\n return {\n specificationVersion: 'v4' as const,\n image: createImageModel,\n imageModel: createImageModel,\n languageModel: (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'languageModel',\n });\n },\n embeddingModel,\n textEmbeddingModel: embeddingModel,\n };\n}\n\nexport const luma = createLuma();\n","import {\n InvalidResponseDataError,\n type ImageModelV4,\n type ImageModelV4File,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createBinaryResponseHandler,\n createJsonResponseHandler,\n createJsonErrorResponseHandler,\n createStatusCodeErrorResponseHandler,\n delay,\n getFromApi,\n postJsonToApi,\n lazySchema,\n parseProviderOptions,\n zodSchema,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { lumaImageModelOptionsSchema } from './luma-image-model-options';\nimport type { LumaReferenceType } from './luma-image-settings';\nimport { z } from 'zod/v4';\n\nconst DEFAULT_POLL_INTERVAL_MILLIS = 500;\nconst DEFAULT_MAX_POLL_ATTEMPTS = 60000 / DEFAULT_POLL_INTERVAL_MILLIS;\n\ninterface LumaImageModelConfig {\n provider: string;\n baseURL: string;\n headers?: () => Record<string, string>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class LumaImageModel implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly maxImagesPerCall = 1;\n readonly pollIntervalMillis = DEFAULT_POLL_INTERVAL_MILLIS;\n readonly maxPollAttempts = DEFAULT_MAX_POLL_ATTEMPTS;\n\n get provider(): string {\n return this.config.provider;\n }\n\n static [WORKFLOW_SERIALIZE](model: LumaImageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: string;\n config: LumaImageModelConfig;\n }) {\n return new LumaImageModel(options.modelId, options.config);\n }\n\n constructor(\n readonly modelId: string,\n private readonly config: LumaImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n files,\n mask,\n }: Parameters<ImageModelV4['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV4['doGenerate']>>\n > {\n const warnings: Array<SharedV4Warning> = [];\n\n if (seed != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'seed',\n details: 'This model does not support the `seed` option.',\n });\n }\n\n if (size != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'size',\n details:\n 'This model does not support the `size` option. Use `aspectRatio` instead.',\n });\n }\n\n // Parse and validate provider options\n const lumaOptions = await parseProviderOptions({\n provider: 'luma',\n providerOptions,\n schema: lumaImageModelOptionsSchema,\n });\n\n // Extract non-request options\n const {\n pollIntervalMillis,\n maxPollAttempts,\n referenceType,\n images: imageConfigs,\n ...providerRequestOptions\n } = lumaOptions ?? {};\n\n // Handle image editing via files with reference type support\n const editingOptions = this.getEditingOptions(\n files,\n mask,\n referenceType ?? undefined,\n imageConfigs ?? [],\n );\n\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const fullHeaders = combineHeaders(this.config.headers?.(), headers);\n const { value: generationResponse, responseHeaders } = await postJsonToApi({\n url: this.getLumaGenerationsUrl(),\n headers: fullHeaders,\n body: {\n prompt,\n ...(aspectRatio ? { aspect_ratio: aspectRatio } : {}),\n model: this.modelId,\n ...editingOptions,\n ...providerRequestOptions,\n },\n abortSignal,\n fetch: this.config.fetch,\n failedResponseHandler: this.createLumaErrorHandler(),\n successfulResponseHandler: createJsonResponseHandler(\n lumaGenerationResponseSchema,\n ),\n });\n\n const imageUrl = await this.pollForImageUrl(\n generationResponse.id,\n fullHeaders,\n abortSignal,\n {\n pollIntervalMillis: pollIntervalMillis ?? undefined,\n maxPollAttempts: maxPollAttempts ?? undefined,\n },\n );\n\n const downloadedImage = await this.downloadImage(imageUrl, abortSignal);\n\n return {\n images: [downloadedImage],\n warnings,\n response: {\n modelId: this.modelId,\n timestamp: currentDate,\n headers: responseHeaders,\n },\n };\n }\n\n private async pollForImageUrl(\n generationId: string,\n headers: Record<string, string | undefined>,\n abortSignal: AbortSignal | undefined,\n pollSettings?: { pollIntervalMillis?: number; maxPollAttempts?: number },\n ): Promise<string> {\n const url = this.getLumaGenerationsUrl(generationId);\n const maxPollAttempts =\n pollSettings?.maxPollAttempts ?? this.maxPollAttempts;\n const pollIntervalMillis =\n pollSettings?.pollIntervalMillis ?? this.pollIntervalMillis;\n\n for (let i = 0; i < maxPollAttempts; i++) {\n const { value: statusResponse } = await getFromApi({\n url,\n headers,\n abortSignal,\n fetch: this.config.fetch,\n failedResponseHandler: this.createLumaErrorHandler(),\n successfulResponseHandler: createJsonResponseHandler(\n lumaGenerationResponseSchema,\n ),\n });\n\n switch (statusResponse.state) {\n case 'completed':\n if (!statusResponse.assets?.image) {\n throw new InvalidResponseDataError({\n data: statusResponse,\n message: `Image generation completed but no image was found.`,\n });\n }\n return statusResponse.assets.image;\n case 'failed':\n throw new InvalidResponseDataError({\n data: statusResponse,\n message: `Image generation failed.`,\n });\n }\n await delay(pollIntervalMillis);\n }\n\n throw new Error(\n `Image generation timed out after ${this.maxPollAttempts} attempts.`,\n );\n }\n\n private createLumaErrorHandler() {\n return createJsonErrorResponseHandler({\n errorSchema: lumaErrorSchema,\n errorToMessage: (error: LumaErrorData) =>\n error.detail[0].msg ?? 'Unknown error',\n });\n }\n\n private getEditingOptions(\n files: ImageModelV4File[] | undefined,\n mask: ImageModelV4File | undefined,\n referenceType: LumaReferenceType = 'image',\n imageConfigs: Array<{ weight?: number | null; id?: string | null }> = [],\n ): Record<string, unknown> {\n const options: Record<string, unknown> = {};\n\n // Luma does not support mask-based inpainting\n if (mask != null) {\n throw new Error(\n 'Luma AI does not support mask-based image editing. ' +\n 'Use the prompt to describe the changes you want to make, along with ' +\n '`prompt.images` containing the source image URL.',\n );\n }\n\n if (files == null || files.length === 0) {\n return options;\n }\n\n // Validate all files are URL-based\n for (const file of files) {\n if (file.type !== 'url') {\n throw new Error(\n 'Luma AI only supports URL-based images. ' +\n 'Please provide image URLs using `prompt.images` with publicly accessible URLs. ' +\n 'Base64 and Uint8Array data are not supported.',\n );\n }\n }\n\n // Default weights per reference type\n const defaultWeights: Record<LumaReferenceType, number> = {\n image: 0.85,\n style: 0.8,\n character: 1.0, // Not used, but defined for completeness\n modify_image: 1.0,\n };\n\n switch (referenceType) {\n case 'image': {\n // Supports up to 4 images\n if (files.length > 4) {\n throw new Error(\n 'Luma AI image supports up to 4 reference images. ' +\n `You provided ${files.length} images.`,\n );\n }\n options.image = files.map((file, index) => ({\n url: (file as { type: 'url'; url: string }).url,\n weight: imageConfigs[index]?.weight ?? defaultWeights.image,\n }));\n break;\n }\n\n case 'style': {\n // Style ref accepts an array but typically uses one style image\n options.style = files.map((file, index) => ({\n url: (file as { type: 'url'; url: string }).url,\n weight: imageConfigs[index]?.weight ?? defaultWeights.style,\n }));\n break;\n }\n\n case 'character': {\n // Group images by identity id\n const identities: Record<string, string[]> = {};\n for (let i = 0; i < files.length; i++) {\n const file = files[i] as { type: 'url'; url: string };\n const identityId = imageConfigs[i]?.id ?? 'identity0';\n if (!identities[identityId]) {\n identities[identityId] = [];\n }\n identities[identityId].push(file.url);\n }\n\n // Validate each identity has at most 4 images\n for (const [identityId, images] of Object.entries(identities)) {\n if (images.length > 4) {\n throw new Error(\n `Luma AI character supports up to 4 images per identity. ` +\n `Identity '${identityId}' has ${images.length} images.`,\n );\n }\n }\n\n options.character = Object.fromEntries(\n Object.entries(identities).map(([id, images]) => [id, { images }]),\n );\n break;\n }\n\n case 'modify_image': {\n // Only supports a single image\n if (files.length > 1) {\n throw new Error(\n 'Luma AI modify_image only supports a single input image. ' +\n `You provided ${files.length} images.`,\n );\n }\n options.modify_image = {\n url: (files[0] as { type: 'url'; url: string }).url,\n weight: imageConfigs[0]?.weight ?? defaultWeights.modify_image,\n };\n break;\n }\n }\n\n return options;\n }\n\n private getLumaGenerationsUrl(generationId?: string) {\n return `${this.config.baseURL}/dream-machine/v1/generations/${\n generationId ?? 'image'\n }`;\n }\n\n private async downloadImage(\n url: string,\n abortSignal: AbortSignal | undefined,\n ): Promise<Uint8Array> {\n const { value: response } = await getFromApi({\n url,\n // No specific headers should be needed for this request as it's a\n // generated image provided by Luma.\n abortSignal,\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createBinaryResponseHandler(),\n fetch: this.config.fetch,\n });\n return response;\n }\n}\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst lumaGenerationResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string(),\n state: z.enum(['queued', 'dreaming', 'completed', 'failed']),\n failure_reason: z.string().nullish(),\n assets: z\n .object({\n image: z.string(), // URL of the generated image\n })\n .nullish(),\n }),\n ),\n);\n\nconst lumaErrorSchema = z.object({\n detail: z.array(\n z.object({\n type: z.string(),\n loc: z.array(z.string()),\n msg: z.string(),\n input: z.string(),\n ctx: z\n .object({\n expected: z.string(),\n })\n .nullish(),\n }),\n ),\n});\n\nexport type LumaErrorData = z.infer<typeof lumaErrorSchema>;\n\n/**\n * Provider options schema for Luma image generation.\n *\n * @see https://docs.lumalabs.ai/docs/image-generation\n */\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n/**\n * Provider options schema for Luma image generation.\n *\n * @see https://docs.lumalabs.ai/docs/image-generation\n */\nexport const lumaImageModelOptionsSchema = lazySchema(() =>\n zodSchema(\n z\n .object({\n /**\n * The type of image reference to use when providing input images.\n * - `image`: Guide generation using reference images (up to 4). Default.\n * - `style`: Apply a specific style from reference image(s).\n * - `character`: Create consistent characters from reference images (up to 4).\n * - `modify_image`: Transform a single input image with prompt guidance.\n */\n referenceType: z\n .enum(['image', 'style', 'character', 'modify_image'])\n .nullish(),\n\n /**\n * Per-image configuration array. Each entry corresponds to an image in `prompt.images`.\n * Allows setting individual weights for each reference image.\n */\n images: z\n .array(\n z.object({\n /**\n * The weight of this image's influence on the generation.\n * - For `image`: Higher weight = closer to reference (default: 0.85)\n * - For `style`: Higher weight = stronger style influence (default: 0.8)\n * - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)\n */\n weight: z.number().min(0).max(1).nullish(),\n\n /**\n * The identity name for character references.\n * Used with `character` to specify which identity group the image belongs to.\n * Luma supports multiple identities (e.g., 'identity0', 'identity1') for generating\n * images with multiple consistent characters.\n * Default: 'identity0'\n */\n id: z.string().nullish(),\n }),\n )\n .nullish(),\n\n /**\n * Override the polling interval in milliseconds (default 500).\n */\n pollIntervalMillis: z.number().nullish(),\n\n /**\n * Override the maximum number of polling attempts (default 120).\n */\n maxPollAttempts: z.number().nullish(),\n })\n .passthrough(),\n ),\n);\n\nexport type LumaImageModelOptions = InferSchema<\n typeof lumaImageModelOptionsSchema\n>;\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.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E,OAAO;AAAA,MACrB,CAAC,EACA,QAAQ;AAAA,IACb,CAAC;AAAA,EACH;AACF,CAAC;;;AEnYM,IAAM,UACX,OACI,kBACA;;;AHgDN,IAAM,iBAAiB;AAEhB,SAAS,WAAW,UAAgC,CAAC,GAAiB;AAvD7E;AAwDE,QAAM,UAAU,sBAAqB,aAAQ,YAAR,YAAmB,cAAc;AACtE,QAAM,aAAa,MACjB;AAAA,IACE;AAAA,MACE,eAAe,UAAU,WAAW;AAAA,QAClC,QAAQ,QAAQ;AAAA,QAChB,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC,CAAC;AAAA,MACF,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,eAAe,OAAO;AAAA,EACxB;AAEF,QAAM,mBAAmB,CAAC,YACxB,IAAI,eAAe,SAAS;AAAA,IAC1B,UAAU;AAAA,IACV,SAAS,4BAAW;AAAA,IACpB,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB,CAAC;AAEH,QAAM,iBAAiB,CAAC,YAAoB;AAC1C,UAAM,IAAI,iBAAiB;AAAA,MACzB;AAAA,MACA,WAAW;AAAA,IACb,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,sBAAsB;AAAA,IACtB,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,eAAe,CAAC,YAAoB;AAClC,YAAM,IAAI,iBAAiB;AAAA,QACzB;AAAA,QACA,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAAA,IACA;AAAA,IACA,oBAAoB;AAAA,EACtB;AACF;AAEO,IAAM,OAAO,WAAW;","names":["lazySchema","zodSchema","z","_a","_b","lazySchema","zodSchema"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/luma",
3
- "version": "3.0.0-beta.30",
3
+ "version": "3.0.0-beta.31",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -29,8 +29,8 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@ai-sdk/provider": "4.0.0-beta.14",
33
- "@ai-sdk/provider-utils": "5.0.0-beta.29"
32
+ "@ai-sdk/provider-utils": "5.0.0-beta.30",
33
+ "@ai-sdk/provider": "4.0.0-beta.14"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "20.17.24",
package/src/index.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  export { createLuma, luma } from './luma-provider';
2
2
  export type { LumaProvider, LumaProviderSettings } from './luma-provider';
3
+ export type { LumaErrorData } from './luma-image-model';
3
4
  export type {
4
- LumaErrorData,
5
5
  LumaImageModelOptions,
6
6
  /** @deprecated Use `LumaImageModelOptions` instead. */
7
7
  LumaImageModelOptions as LumaImageProviderOptions,
8
- } from './luma-image-model';
8
+ } from './luma-image-model-options';
9
9
  export { VERSION } from './version';
@@ -0,0 +1,71 @@
1
+ import {
2
+ lazySchema,
3
+ zodSchema,
4
+ type InferSchema,
5
+ } from '@ai-sdk/provider-utils';
6
+ import { z } from 'zod/v4';
7
+
8
+ /**
9
+ * Provider options schema for Luma image generation.
10
+ *
11
+ * @see https://docs.lumalabs.ai/docs/image-generation
12
+ */
13
+ export const lumaImageModelOptionsSchema = lazySchema(() =>
14
+ zodSchema(
15
+ z
16
+ .object({
17
+ /**
18
+ * The type of image reference to use when providing input images.
19
+ * - `image`: Guide generation using reference images (up to 4). Default.
20
+ * - `style`: Apply a specific style from reference image(s).
21
+ * - `character`: Create consistent characters from reference images (up to 4).
22
+ * - `modify_image`: Transform a single input image with prompt guidance.
23
+ */
24
+ referenceType: z
25
+ .enum(['image', 'style', 'character', 'modify_image'])
26
+ .nullish(),
27
+
28
+ /**
29
+ * Per-image configuration array. Each entry corresponds to an image in `prompt.images`.
30
+ * Allows setting individual weights for each reference image.
31
+ */
32
+ images: z
33
+ .array(
34
+ z.object({
35
+ /**
36
+ * The weight of this image's influence on the generation.
37
+ * - For `image`: Higher weight = closer to reference (default: 0.85)
38
+ * - For `style`: Higher weight = stronger style influence (default: 0.8)
39
+ * - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)
40
+ */
41
+ weight: z.number().min(0).max(1).nullish(),
42
+
43
+ /**
44
+ * The identity name for character references.
45
+ * Used with `character` to specify which identity group the image belongs to.
46
+ * Luma supports multiple identities (e.g., 'identity0', 'identity1') for generating
47
+ * images with multiple consistent characters.
48
+ * Default: 'identity0'
49
+ */
50
+ id: z.string().nullish(),
51
+ }),
52
+ )
53
+ .nullish(),
54
+
55
+ /**
56
+ * Override the polling interval in milliseconds (default 500).
57
+ */
58
+ pollIntervalMillis: z.number().nullish(),
59
+
60
+ /**
61
+ * Override the maximum number of polling attempts (default 120).
62
+ */
63
+ maxPollAttempts: z.number().nullish(),
64
+ })
65
+ .passthrough(),
66
+ ),
67
+ );
68
+
69
+ export type LumaImageModelOptions = InferSchema<
70
+ typeof lumaImageModelOptionsSchema
71
+ >;
@@ -20,8 +20,8 @@ import {
20
20
  WORKFLOW_SERIALIZE,
21
21
  WORKFLOW_DESERIALIZE,
22
22
  type FetchFunction,
23
- type InferSchema,
24
23
  } from '@ai-sdk/provider-utils';
24
+ import { lumaImageModelOptionsSchema } from './luma-image-model-options';
25
25
  import type { LumaReferenceType } from './luma-image-settings';
26
26
  import { z } from 'zod/v4';
27
27
 
@@ -396,62 +396,3 @@ export type LumaErrorData = z.infer<typeof lumaErrorSchema>;
396
396
  *
397
397
  * @see https://docs.lumalabs.ai/docs/image-generation
398
398
  */
399
- export const lumaImageModelOptionsSchema = lazySchema(() =>
400
- zodSchema(
401
- z
402
- .object({
403
- /**
404
- * The type of image reference to use when providing input images.
405
- * - `image`: Guide generation using reference images (up to 4). Default.
406
- * - `style`: Apply a specific style from reference image(s).
407
- * - `character`: Create consistent characters from reference images (up to 4).
408
- * - `modify_image`: Transform a single input image with prompt guidance.
409
- */
410
- referenceType: z
411
- .enum(['image', 'style', 'character', 'modify_image'])
412
- .nullish(),
413
-
414
- /**
415
- * Per-image configuration array. Each entry corresponds to an image in `prompt.images`.
416
- * Allows setting individual weights for each reference image.
417
- */
418
- images: z
419
- .array(
420
- z.object({
421
- /**
422
- * The weight of this image's influence on the generation.
423
- * - For `image`: Higher weight = closer to reference (default: 0.85)
424
- * - For `style`: Higher weight = stronger style influence (default: 0.8)
425
- * - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)
426
- */
427
- weight: z.number().min(0).max(1).nullish(),
428
-
429
- /**
430
- * The identity name for character references.
431
- * Used with `character` to specify which identity group the image belongs to.
432
- * Luma supports multiple identities (e.g., 'identity0', 'identity1') for generating
433
- * images with multiple consistent characters.
434
- * Default: 'identity0'
435
- */
436
- id: z.string().nullish(),
437
- }),
438
- )
439
- .nullish(),
440
-
441
- /**
442
- * Override the polling interval in milliseconds (default 500).
443
- */
444
- pollIntervalMillis: z.number().nullish(),
445
-
446
- /**
447
- * Override the maximum number of polling attempts (default 120).
448
- */
449
- maxPollAttempts: z.number().nullish(),
450
- })
451
- .passthrough(),
452
- ),
453
- );
454
-
455
- export type LumaImageModelOptions = InferSchema<
456
- typeof lumaImageModelOptionsSchema
457
- >;