@threaded/ai 1.0.13 → 1.0.15

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.js CHANGED
@@ -232,6 +232,7 @@ var generateOpenAICompatible = async (endpoint, modelName, prompt, apiKey, confi
232
232
  if (config?.outputFormat) body.output_format = config.outputFormat;
233
233
  if (config?.outputCompression != null) body.output_compression = config.outputCompression;
234
234
  if (config?.background) body.background = config.background;
235
+ if (config?.moderation) body.moderation = config.moderation;
235
236
  }
236
237
  const response = await fetch(endpoint, {
237
238
  method: "POST",
@@ -260,8 +261,11 @@ var generateGoogle = async (modelName, prompt, apiKey, config) => {
260
261
  responseModalities: ["TEXT", "IMAGE"]
261
262
  }
262
263
  };
263
- if (config?.aspectRatio) {
264
- body.generationConfig.aspectRatio = config.aspectRatio;
264
+ const imageConfig = {};
265
+ if (config?.aspectRatio) imageConfig.aspectRatio = config.aspectRatio;
266
+ if (config?.imageSize) imageConfig.imageSize = config.imageSize;
267
+ if (Object.keys(imageConfig).length > 0) {
268
+ body.generationConfig.imageGenerationConfig = imageConfig;
265
269
  }
266
270
  const response = await fetch(endpoint, {
267
271
  method: "POST",
@@ -315,6 +319,100 @@ var generateImage = async (model2, prompt, config) => {
315
319
  }
316
320
  };
317
321
 
322
+ // src/image-model-schema.ts
323
+ var IMAGE_MODEL_SCHEMA = {
324
+ openai: {
325
+ "dall-e-3": {
326
+ size: {
327
+ values: ["1024x1024", "1024x1792", "1792x1024"],
328
+ default: "1024x1024",
329
+ description: "Image dimensions"
330
+ },
331
+ quality: {
332
+ values: ["standard", "hd"],
333
+ default: "standard",
334
+ description: "Image quality level"
335
+ },
336
+ style: {
337
+ values: ["vivid", "natural"],
338
+ default: "vivid",
339
+ description: "Image style"
340
+ }
341
+ },
342
+ "gpt-image-1.5": {
343
+ size: {
344
+ values: ["1024x1024", "1536x1024", "1024x1536", "auto"],
345
+ default: "auto",
346
+ description: "Image dimensions"
347
+ },
348
+ quality: {
349
+ values: ["low", "medium", "high", "auto"],
350
+ default: "auto",
351
+ description: "Image quality level"
352
+ },
353
+ background: {
354
+ values: ["transparent", "opaque", "auto"],
355
+ default: "auto",
356
+ description: "Background type"
357
+ },
358
+ moderation: {
359
+ values: ["auto", "low"],
360
+ default: "auto",
361
+ description: "Content moderation level"
362
+ }
363
+ }
364
+ },
365
+ google: {
366
+ "gemini-2.5-flash-image": {
367
+ aspectRatio: {
368
+ values: ["1:1", "3:4", "4:3", "9:16", "16:9"],
369
+ default: "1:1",
370
+ description: "Image aspect ratio"
371
+ }
372
+ },
373
+ "gemini-3-pro-image-preview": {
374
+ aspectRatio: {
375
+ values: ["1:1", "3:4", "4:3", "9:16", "16:9"],
376
+ default: "1:1",
377
+ description: "Image aspect ratio"
378
+ },
379
+ imageSize: {
380
+ values: ["1K", "2K"],
381
+ default: "1K",
382
+ description: "Output image size"
383
+ }
384
+ },
385
+ "nano-banana-pro-preview": {
386
+ aspectRatio: {
387
+ values: ["1:1", "3:4", "4:3", "9:16", "16:9"],
388
+ default: "1:1",
389
+ description: "Image aspect ratio"
390
+ }
391
+ }
392
+ },
393
+ xai: {
394
+ "grok-2-image-1212": {
395
+ size: {
396
+ values: ["1024x1024"],
397
+ default: "1024x1024",
398
+ description: "Image dimensions"
399
+ }
400
+ }
401
+ }
402
+ };
403
+ function getModelConfig(provider, model2) {
404
+ return IMAGE_MODEL_SCHEMA[provider]?.[model2] || null;
405
+ }
406
+ function getDefaultConfig(provider, model2) {
407
+ const schema = getModelConfig(provider, model2);
408
+ if (!schema) return {};
409
+ const defaults = {};
410
+ for (const [key, option] of Object.entries(schema)) {
411
+ defaults[key] = option.default;
412
+ }
413
+ return defaults;
414
+ }
415
+
318
416
  // src/providers/openai.ts
319
417
  var getApiKey2 = (configApiKey) => {
320
418
  if (configApiKey) return configApiKey;
@@ -1642,6 +1740,7 @@ var rateLimited = (config) => (fn) => {
1642
1740
  });
1643
1741
  };
1644
1742
  export {
1743
+ IMAGE_MODEL_SCHEMA,
1645
1744
  Inherit,
1646
1745
  appendToLastRequest,
1647
1746
  compose,
@@ -1654,7 +1753,9 @@ export {
1654
1753
  everyNTokens,
1655
1754
  generateApprovalToken,
1656
1755
  generateImage,
1756
+ getDefaultConfig,
1657
1757
  getKey,
1758
+ getModelConfig,
1658
1759
  getOrCreateThread,
1659
1760
  isStandardSchema,
1660
1761
  maxCalls,