@blinkdotnew/sdk 0.14.13 → 0.17.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
@@ -353,12 +353,27 @@ const { object: todoList } = await blink.ai.generateObject({
353
353
  // })
354
354
  // Error: "schema must be a JSON Schema of 'type: \"object\"', got 'type: \"array\"'"
355
355
 
356
- // Image generation
356
+ // Generate and modify images with AI
357
+
358
+ // Basic image generation - returns public URLs directly
357
359
  const { data } = await blink.ai.generateImage({
358
- prompt: 'A serene landscape',
360
+ prompt: 'A serene landscape with mountains and a lake at sunset',
359
361
  size: '1024x1024',
360
- quality: 'hd'
362
+ quality: 'hd',
363
+ n: 2
364
+ })
365
+ console.log('Image URL:', data[0].url)
366
+
367
+ // Image editing - transform existing images with prompts
368
+ const { data: headshots } = await blink.ai.modifyImage({
369
+ images: ['https://storage.example.com/user-photo.jpg'], // ... up to 16 images maximum!
370
+ prompt: 'Generate professional business headshot with studio lighting for this person.',
371
+ quality: 'hd',
372
+ n: 4
361
373
  })
374
+ // Options: size ('1024x1024', '1536x1024'), quality ('standard'|'hd'),
375
+ // background ('auto'|'transparent'|'opaque'), n (1-10 images)
376
+
362
377
 
363
378
  // Speech synthesis
364
379
  const { url } = await blink.ai.generateSpeech({
@@ -690,12 +705,20 @@ try {
690
705
  // Upload files (returns public URL directly)
691
706
  const { publicUrl } = await blink.storage.upload(
692
707
  file,
693
- 'path/to/file.jpg',
708
+ 'path/to/file',
694
709
  {
695
710
  upsert: true,
696
711
  onProgress: (percent) => console.log(`${percent}%`)
697
712
  }
698
713
  )
714
+ // If file is PNG, final path will be: path/to/file.png
715
+
716
+ // 💡 Pro tip: Use the actual filename (file.name) in your path to avoid confusion
717
+ const { publicUrl } = await blink.storage.upload(
718
+ file,
719
+ `uploads/${file.name}`, // Uses actual filename with correct extension
720
+ { upsert: true }
721
+ )
699
722
 
700
723
  // Remove files
701
724
  await blink.storage.remove('file1.jpg', 'file2.jpg')
package/dist/index.d.mts CHANGED
@@ -119,8 +119,17 @@ interface FileObject {
119
119
  }
120
120
  interface BlinkStorage {
121
121
  upload(file: File | Blob | Buffer, path: string, options?: StorageUploadOptions): Promise<StorageUploadResponse>;
122
+ download(path: string, options?: {
123
+ filename?: string;
124
+ }): Promise<StorageDownloadResponse>;
122
125
  remove(...paths: string[]): Promise<void>;
123
126
  }
127
+ interface StorageDownloadResponse {
128
+ downloadUrl: string;
129
+ filename: string;
130
+ contentType?: string;
131
+ size?: number;
132
+ }
124
133
  interface TokenUsage {
125
134
  promptTokens: number;
126
135
  completionTokens: number;
@@ -211,10 +220,15 @@ interface ObjectGenerationResponse {
211
220
  interface ImageGenerationRequest {
212
221
  model?: string;
213
222
  prompt: string;
223
+ images?: string[];
214
224
  size?: string;
215
225
  quality?: 'standard' | 'hd';
226
+ background?: 'auto' | 'transparent' | 'opaque';
216
227
  n?: number;
217
228
  response_format?: 'url' | 'b64_json';
229
+ output_format?: 'png' | 'jpeg' | 'webp';
230
+ output_compression?: number;
231
+ moderation?: 'auto' | 'low';
218
232
  signal?: AbortSignal;
219
233
  }
220
234
  interface ImageGenerationResponse {
@@ -273,6 +287,15 @@ interface BlinkAI {
273
287
  generateObject(options: ObjectGenerationRequest): Promise<ObjectGenerationResponse>;
274
288
  streamObject(options: ObjectGenerationRequest, onPartial: (partial: any) => void): Promise<ObjectGenerationResponse>;
275
289
  generateImage(options: ImageGenerationRequest): Promise<ImageGenerationResponse>;
290
+ modifyImage(options: {
291
+ images: string[];
292
+ prompt: string;
293
+ size?: string;
294
+ quality?: "standard" | "hd";
295
+ n?: number;
296
+ background?: "auto" | "transparent" | "opaque";
297
+ signal?: AbortSignal;
298
+ }): Promise<ImageGenerationResponse>;
276
299
  generateSpeech(options: SpeechGenerationRequest): Promise<SpeechGenerationResponse>;
277
300
  transcribeAudio(options: TranscriptionRequest): Promise<TranscriptionResponse>;
278
301
  }
@@ -660,10 +683,15 @@ declare class HttpClient {
660
683
  } | undefined, onPartial: (partial: any) => void): Promise<any>;
661
684
  aiImage(prompt: string, options?: {
662
685
  model?: string;
686
+ images?: string[];
663
687
  size?: string;
664
688
  quality?: 'standard' | 'hd';
689
+ background?: 'auto' | 'transparent' | 'opaque';
665
690
  n?: number;
666
691
  response_format?: 'url' | 'b64_json';
692
+ output_format?: 'png' | 'jpeg' | 'webp';
693
+ output_compression?: number;
694
+ moderation?: 'auto' | 'low';
667
695
  signal?: AbortSignal;
668
696
  }): Promise<BlinkResponse<any>>;
669
697
  aiSpeech(text: string, options?: {
@@ -1022,6 +1050,7 @@ interface BlinkAnalytics {
1022
1050
  setUserId(userId: string | null): void;
1023
1051
  setUserEmail(email: string | null): void;
1024
1052
  clearAttribution(): void;
1053
+ destroy(): void;
1025
1054
  }
1026
1055
  declare class BlinkAnalyticsImpl implements BlinkAnalytics {
1027
1056
  private httpClient;
@@ -1043,6 +1072,10 @@ declare class BlinkAnalyticsImpl implements BlinkAnalytics {
1043
1072
  * Disable analytics tracking
1044
1073
  */
1045
1074
  disable(): void;
1075
+ /**
1076
+ * Cleanup analytics instance (remove from global tracking)
1077
+ */
1078
+ destroy(): void;
1046
1079
  /**
1047
1080
  * Enable analytics tracking
1048
1081
  */
@@ -1113,23 +1146,74 @@ declare class BlinkStorageImpl implements BlinkStorage {
1113
1146
  * Upload a file to project storage
1114
1147
  *
1115
1148
  * @param file - File, Blob, or Buffer to upload
1116
- * @param path - Destination path within project storage
1149
+ * @param path - Destination path within project storage (extension will be auto-corrected to match file type)
1117
1150
  * @param options - Upload options including upsert and progress callback
1118
1151
  * @returns Promise resolving to upload response with public URL
1119
1152
  *
1120
1153
  * @example
1121
1154
  * ```ts
1155
+ * // Extension automatically corrected to match actual file type
1122
1156
  * const { publicUrl } = await blink.storage.upload(
1123
- * fileInput.files[0],
1124
- * `avatars/${user.id}.png`,
1125
- * {
1126
- * upsert: true,
1127
- * onProgress: pct => console.log(`${pct}%`)
1128
- * }
1157
+ * pngFile,
1158
+ * `avatars/${user.id}`, // No extension needed!
1159
+ * { upsert: true }
1160
+ * );
1161
+ * // If file is PNG, final path will be: avatars/user123.png
1162
+ *
1163
+ * // Or with extension (will be corrected if wrong)
1164
+ * const { publicUrl } = await blink.storage.upload(
1165
+ * pngFile,
1166
+ * `avatars/${user.id}.jpg`, // Wrong extension
1167
+ * { upsert: true }
1129
1168
  * );
1169
+ * // Final path will be: avatars/user123.png (auto-corrected!)
1130
1170
  * ```
1131
1171
  */
1132
1172
  upload(file: File | Blob | Buffer, path: string, options?: StorageUploadOptions): Promise<StorageUploadResponse>;
1173
+ /**
1174
+ * Detect file type from actual file content and correct path extension
1175
+ * This ensures the path extension always matches the actual file type
1176
+ */
1177
+ private detectFileTypeAndCorrectPath;
1178
+ /**
1179
+ * Get the first few bytes of a file to analyze its signature
1180
+ */
1181
+ private getFileSignature;
1182
+ /**
1183
+ * Detect file type from file signature (magic numbers)
1184
+ * This is the most reliable way to detect actual file type
1185
+ */
1186
+ private detectFileTypeFromSignature;
1187
+ /**
1188
+ * Get file extension from MIME type as fallback
1189
+ */
1190
+ private getExtensionFromMimeType;
1191
+ /**
1192
+ * Get a download URL for a file that triggers browser download
1193
+ *
1194
+ * @param path - Path to the file in project storage
1195
+ * @param options - Download options including custom filename
1196
+ * @returns Promise resolving to download response with download URL
1197
+ *
1198
+ * @example
1199
+ * ```ts
1200
+ * // Download with original filename
1201
+ * const { downloadUrl, filename } = await blink.storage.download('images/photo.jpg');
1202
+ * window.open(downloadUrl, '_blank');
1203
+ *
1204
+ * // Download with custom filename
1205
+ * const { downloadUrl } = await blink.storage.download(
1206
+ * 'images/photo.jpg',
1207
+ * { filename: 'my-photo.jpg' }
1208
+ * );
1209
+ *
1210
+ * // Create download link in React
1211
+ * <a href={downloadUrl} download={filename}>Download Image</a>
1212
+ * ```
1213
+ */
1214
+ download(path: string, options?: {
1215
+ filename?: string;
1216
+ }): Promise<StorageDownloadResponse>;
1133
1217
  /**
1134
1218
  * Remove one or more files from project storage
1135
1219
  *
@@ -1362,15 +1446,15 @@ declare class BlinkAIImpl implements BlinkAI {
1362
1446
  */
1363
1447
  streamObject(options: ObjectGenerationRequest, onPartial: (partial: any) => void): Promise<ObjectGenerationResponse>;
1364
1448
  /**
1365
- * Generates images from text descriptions using AI image models.
1449
+ * Generates images from text descriptions using AI.
1366
1450
  *
1367
1451
  * @param options - Object containing:
1368
- * - `prompt`: Text description of the image to generate (required)
1369
- * - `size`: Image dimensions (e.g., "1024x1024", "512x512") - varies by model
1370
- * - `quality`: Image quality ("standard" or "hd")
1452
+ * - `prompt`: Text description of the desired image (required)
1453
+ * - `size`: Image dimensions (default: "1024x1024")
1454
+ * - `quality`: Image quality ("standard" or "hd", default: "standard")
1371
1455
  * - `n`: Number of images to generate (default: 1)
1372
- * - `response_format`: Output format ("url" or "b64_json")
1373
- * - Plus optional model, signal parameters
1456
+ * - `background`: Background handling ("auto", "transparent", "opaque", default: "auto")
1457
+ * - Plus optional signal parameter
1374
1458
  *
1375
1459
  * @example
1376
1460
  * ```ts
@@ -1383,31 +1467,103 @@ declare class BlinkAIImpl implements BlinkAI {
1383
1467
  * // High-quality image with specific size
1384
1468
  * const { data } = await blink.ai.generateImage({
1385
1469
  * prompt: "A futuristic city skyline with flying cars",
1386
- * size: "1792x1024",
1470
+ * size: "1536x1024",
1387
1471
  * quality: "hd",
1388
- * model: "dall-e-3"
1472
+ * background: "transparent"
1389
1473
  * });
1390
1474
  *
1391
1475
  * // Multiple images
1392
1476
  * const { data } = await blink.ai.generateImage({
1393
1477
  * prompt: "A cute robot mascot for a tech company",
1394
1478
  * n: 3,
1395
- * size: "1024x1024"
1479
+ * size: "1024x1024",
1480
+ * quality: "hd"
1396
1481
  * });
1397
1482
  * data.forEach((img, i) => console.log(`Image ${i+1}:`, img.url));
1483
+ * ```
1398
1484
  *
1399
- * // Base64 format for direct embedding
1400
- * const { data } = await blink.ai.generateImage({
1401
- * prompt: "A minimalist logo design",
1402
- * response_format: "b64_json"
1485
+ * @returns Promise<ImageGenerationResponse> - Object containing:
1486
+ * - `data`: Array of generated images with URLs
1487
+ * - `created`: Timestamp of generation
1488
+ * - `usage`: Token usage information
1489
+ */
1490
+ generateImage(options: {
1491
+ prompt: string;
1492
+ size?: string;
1493
+ quality?: "standard" | "hd";
1494
+ n?: number;
1495
+ background?: "auto" | "transparent" | "opaque";
1496
+ signal?: AbortSignal;
1497
+ }): Promise<ImageGenerationResponse>;
1498
+ /**
1499
+ * Modifies existing images using AI with text prompts for image-to-image editing.
1500
+ *
1501
+ * @param options - Object containing:
1502
+ * - `images`: Array of public image URLs to modify (required, up to 16 images)
1503
+ * - `prompt`: Text description of desired modifications (required)
1504
+ * - `size`: Output image dimensions (default: "auto")
1505
+ * - `quality`: Image quality ("standard" or "hd", default: "standard")
1506
+ * - `n`: Number of output images to generate (default: 1)
1507
+ * - `background`: Background handling ("auto", "transparent", "opaque", default: "auto")
1508
+ * - Plus optional signal parameter
1509
+ *
1510
+ * @example
1511
+ * ```ts
1512
+ * // Professional headshots from casual photos
1513
+ * const { data } = await blink.ai.modifyImage({
1514
+ * images: [
1515
+ * "https://storage.example.com/user-photo-1.jpg",
1516
+ * "https://storage.example.com/user-photo-2.jpg"
1517
+ * ],
1518
+ * prompt: "Transform into professional business headshots with studio lighting",
1519
+ * quality: "hd",
1520
+ * n: 4
1521
+ * });
1522
+ * data.forEach((img, i) => console.log(`Headshot ${i+1}:`, img.url));
1523
+ *
1524
+ * // Artistic style transformation
1525
+ * const { data } = await blink.ai.modifyImage({
1526
+ * images: ["https://storage.example.com/portrait.jpg"],
1527
+ * prompt: "Transform into oil painting style with dramatic lighting",
1528
+ * quality: "hd",
1529
+ * size: "1024x1024"
1530
+ * });
1531
+ *
1532
+ * // Background replacement
1533
+ * const { data } = await blink.ai.modifyImage({
1534
+ * images: ["https://storage.example.com/product.jpg"],
1535
+ * prompt: "Remove background and place on clean white studio background",
1536
+ * background: "transparent",
1537
+ * n: 2
1538
+ * });
1539
+ *
1540
+ * // Batch processing multiple photos
1541
+ * const userPhotos = [
1542
+ * "https://storage.example.com/photo1.jpg",
1543
+ * "https://storage.example.com/photo2.jpg",
1544
+ * "https://storage.example.com/photo3.jpg"
1545
+ * ];
1546
+ * const { data } = await blink.ai.modifyImage({
1547
+ * images: userPhotos,
1548
+ * prompt: "Convert to black and white vintage style photographs",
1549
+ * quality: "hd"
1403
1550
  * });
1404
- * console.log("Base64 data:", data[0].b64_json);
1405
1551
  * ```
1406
1552
  *
1407
1553
  * @returns Promise<ImageGenerationResponse> - Object containing:
1408
- * - `data`: Array of generated images with url or b64_json
1554
+ * - `data`: Array of modified images with URLs
1555
+ * - `created`: Timestamp of generation
1556
+ * - `usage`: Token usage information
1409
1557
  */
1410
- generateImage(options: ImageGenerationRequest): Promise<ImageGenerationResponse>;
1558
+ modifyImage(options: {
1559
+ images: string[];
1560
+ prompt: string;
1561
+ size?: string;
1562
+ quality?: "standard" | "hd";
1563
+ n?: number;
1564
+ background?: "auto" | "transparent" | "opaque";
1565
+ signal?: AbortSignal;
1566
+ }): Promise<ImageGenerationResponse>;
1411
1567
  /**
1412
1568
  * Converts text to speech using AI voice synthesis models.
1413
1569
  *
package/dist/index.d.ts CHANGED
@@ -119,8 +119,17 @@ interface FileObject {
119
119
  }
120
120
  interface BlinkStorage {
121
121
  upload(file: File | Blob | Buffer, path: string, options?: StorageUploadOptions): Promise<StorageUploadResponse>;
122
+ download(path: string, options?: {
123
+ filename?: string;
124
+ }): Promise<StorageDownloadResponse>;
122
125
  remove(...paths: string[]): Promise<void>;
123
126
  }
127
+ interface StorageDownloadResponse {
128
+ downloadUrl: string;
129
+ filename: string;
130
+ contentType?: string;
131
+ size?: number;
132
+ }
124
133
  interface TokenUsage {
125
134
  promptTokens: number;
126
135
  completionTokens: number;
@@ -211,10 +220,15 @@ interface ObjectGenerationResponse {
211
220
  interface ImageGenerationRequest {
212
221
  model?: string;
213
222
  prompt: string;
223
+ images?: string[];
214
224
  size?: string;
215
225
  quality?: 'standard' | 'hd';
226
+ background?: 'auto' | 'transparent' | 'opaque';
216
227
  n?: number;
217
228
  response_format?: 'url' | 'b64_json';
229
+ output_format?: 'png' | 'jpeg' | 'webp';
230
+ output_compression?: number;
231
+ moderation?: 'auto' | 'low';
218
232
  signal?: AbortSignal;
219
233
  }
220
234
  interface ImageGenerationResponse {
@@ -273,6 +287,15 @@ interface BlinkAI {
273
287
  generateObject(options: ObjectGenerationRequest): Promise<ObjectGenerationResponse>;
274
288
  streamObject(options: ObjectGenerationRequest, onPartial: (partial: any) => void): Promise<ObjectGenerationResponse>;
275
289
  generateImage(options: ImageGenerationRequest): Promise<ImageGenerationResponse>;
290
+ modifyImage(options: {
291
+ images: string[];
292
+ prompt: string;
293
+ size?: string;
294
+ quality?: "standard" | "hd";
295
+ n?: number;
296
+ background?: "auto" | "transparent" | "opaque";
297
+ signal?: AbortSignal;
298
+ }): Promise<ImageGenerationResponse>;
276
299
  generateSpeech(options: SpeechGenerationRequest): Promise<SpeechGenerationResponse>;
277
300
  transcribeAudio(options: TranscriptionRequest): Promise<TranscriptionResponse>;
278
301
  }
@@ -660,10 +683,15 @@ declare class HttpClient {
660
683
  } | undefined, onPartial: (partial: any) => void): Promise<any>;
661
684
  aiImage(prompt: string, options?: {
662
685
  model?: string;
686
+ images?: string[];
663
687
  size?: string;
664
688
  quality?: 'standard' | 'hd';
689
+ background?: 'auto' | 'transparent' | 'opaque';
665
690
  n?: number;
666
691
  response_format?: 'url' | 'b64_json';
692
+ output_format?: 'png' | 'jpeg' | 'webp';
693
+ output_compression?: number;
694
+ moderation?: 'auto' | 'low';
667
695
  signal?: AbortSignal;
668
696
  }): Promise<BlinkResponse<any>>;
669
697
  aiSpeech(text: string, options?: {
@@ -1022,6 +1050,7 @@ interface BlinkAnalytics {
1022
1050
  setUserId(userId: string | null): void;
1023
1051
  setUserEmail(email: string | null): void;
1024
1052
  clearAttribution(): void;
1053
+ destroy(): void;
1025
1054
  }
1026
1055
  declare class BlinkAnalyticsImpl implements BlinkAnalytics {
1027
1056
  private httpClient;
@@ -1043,6 +1072,10 @@ declare class BlinkAnalyticsImpl implements BlinkAnalytics {
1043
1072
  * Disable analytics tracking
1044
1073
  */
1045
1074
  disable(): void;
1075
+ /**
1076
+ * Cleanup analytics instance (remove from global tracking)
1077
+ */
1078
+ destroy(): void;
1046
1079
  /**
1047
1080
  * Enable analytics tracking
1048
1081
  */
@@ -1113,23 +1146,74 @@ declare class BlinkStorageImpl implements BlinkStorage {
1113
1146
  * Upload a file to project storage
1114
1147
  *
1115
1148
  * @param file - File, Blob, or Buffer to upload
1116
- * @param path - Destination path within project storage
1149
+ * @param path - Destination path within project storage (extension will be auto-corrected to match file type)
1117
1150
  * @param options - Upload options including upsert and progress callback
1118
1151
  * @returns Promise resolving to upload response with public URL
1119
1152
  *
1120
1153
  * @example
1121
1154
  * ```ts
1155
+ * // Extension automatically corrected to match actual file type
1122
1156
  * const { publicUrl } = await blink.storage.upload(
1123
- * fileInput.files[0],
1124
- * `avatars/${user.id}.png`,
1125
- * {
1126
- * upsert: true,
1127
- * onProgress: pct => console.log(`${pct}%`)
1128
- * }
1157
+ * pngFile,
1158
+ * `avatars/${user.id}`, // No extension needed!
1159
+ * { upsert: true }
1160
+ * );
1161
+ * // If file is PNG, final path will be: avatars/user123.png
1162
+ *
1163
+ * // Or with extension (will be corrected if wrong)
1164
+ * const { publicUrl } = await blink.storage.upload(
1165
+ * pngFile,
1166
+ * `avatars/${user.id}.jpg`, // Wrong extension
1167
+ * { upsert: true }
1129
1168
  * );
1169
+ * // Final path will be: avatars/user123.png (auto-corrected!)
1130
1170
  * ```
1131
1171
  */
1132
1172
  upload(file: File | Blob | Buffer, path: string, options?: StorageUploadOptions): Promise<StorageUploadResponse>;
1173
+ /**
1174
+ * Detect file type from actual file content and correct path extension
1175
+ * This ensures the path extension always matches the actual file type
1176
+ */
1177
+ private detectFileTypeAndCorrectPath;
1178
+ /**
1179
+ * Get the first few bytes of a file to analyze its signature
1180
+ */
1181
+ private getFileSignature;
1182
+ /**
1183
+ * Detect file type from file signature (magic numbers)
1184
+ * This is the most reliable way to detect actual file type
1185
+ */
1186
+ private detectFileTypeFromSignature;
1187
+ /**
1188
+ * Get file extension from MIME type as fallback
1189
+ */
1190
+ private getExtensionFromMimeType;
1191
+ /**
1192
+ * Get a download URL for a file that triggers browser download
1193
+ *
1194
+ * @param path - Path to the file in project storage
1195
+ * @param options - Download options including custom filename
1196
+ * @returns Promise resolving to download response with download URL
1197
+ *
1198
+ * @example
1199
+ * ```ts
1200
+ * // Download with original filename
1201
+ * const { downloadUrl, filename } = await blink.storage.download('images/photo.jpg');
1202
+ * window.open(downloadUrl, '_blank');
1203
+ *
1204
+ * // Download with custom filename
1205
+ * const { downloadUrl } = await blink.storage.download(
1206
+ * 'images/photo.jpg',
1207
+ * { filename: 'my-photo.jpg' }
1208
+ * );
1209
+ *
1210
+ * // Create download link in React
1211
+ * <a href={downloadUrl} download={filename}>Download Image</a>
1212
+ * ```
1213
+ */
1214
+ download(path: string, options?: {
1215
+ filename?: string;
1216
+ }): Promise<StorageDownloadResponse>;
1133
1217
  /**
1134
1218
  * Remove one or more files from project storage
1135
1219
  *
@@ -1362,15 +1446,15 @@ declare class BlinkAIImpl implements BlinkAI {
1362
1446
  */
1363
1447
  streamObject(options: ObjectGenerationRequest, onPartial: (partial: any) => void): Promise<ObjectGenerationResponse>;
1364
1448
  /**
1365
- * Generates images from text descriptions using AI image models.
1449
+ * Generates images from text descriptions using AI.
1366
1450
  *
1367
1451
  * @param options - Object containing:
1368
- * - `prompt`: Text description of the image to generate (required)
1369
- * - `size`: Image dimensions (e.g., "1024x1024", "512x512") - varies by model
1370
- * - `quality`: Image quality ("standard" or "hd")
1452
+ * - `prompt`: Text description of the desired image (required)
1453
+ * - `size`: Image dimensions (default: "1024x1024")
1454
+ * - `quality`: Image quality ("standard" or "hd", default: "standard")
1371
1455
  * - `n`: Number of images to generate (default: 1)
1372
- * - `response_format`: Output format ("url" or "b64_json")
1373
- * - Plus optional model, signal parameters
1456
+ * - `background`: Background handling ("auto", "transparent", "opaque", default: "auto")
1457
+ * - Plus optional signal parameter
1374
1458
  *
1375
1459
  * @example
1376
1460
  * ```ts
@@ -1383,31 +1467,103 @@ declare class BlinkAIImpl implements BlinkAI {
1383
1467
  * // High-quality image with specific size
1384
1468
  * const { data } = await blink.ai.generateImage({
1385
1469
  * prompt: "A futuristic city skyline with flying cars",
1386
- * size: "1792x1024",
1470
+ * size: "1536x1024",
1387
1471
  * quality: "hd",
1388
- * model: "dall-e-3"
1472
+ * background: "transparent"
1389
1473
  * });
1390
1474
  *
1391
1475
  * // Multiple images
1392
1476
  * const { data } = await blink.ai.generateImage({
1393
1477
  * prompt: "A cute robot mascot for a tech company",
1394
1478
  * n: 3,
1395
- * size: "1024x1024"
1479
+ * size: "1024x1024",
1480
+ * quality: "hd"
1396
1481
  * });
1397
1482
  * data.forEach((img, i) => console.log(`Image ${i+1}:`, img.url));
1483
+ * ```
1398
1484
  *
1399
- * // Base64 format for direct embedding
1400
- * const { data } = await blink.ai.generateImage({
1401
- * prompt: "A minimalist logo design",
1402
- * response_format: "b64_json"
1485
+ * @returns Promise<ImageGenerationResponse> - Object containing:
1486
+ * - `data`: Array of generated images with URLs
1487
+ * - `created`: Timestamp of generation
1488
+ * - `usage`: Token usage information
1489
+ */
1490
+ generateImage(options: {
1491
+ prompt: string;
1492
+ size?: string;
1493
+ quality?: "standard" | "hd";
1494
+ n?: number;
1495
+ background?: "auto" | "transparent" | "opaque";
1496
+ signal?: AbortSignal;
1497
+ }): Promise<ImageGenerationResponse>;
1498
+ /**
1499
+ * Modifies existing images using AI with text prompts for image-to-image editing.
1500
+ *
1501
+ * @param options - Object containing:
1502
+ * - `images`: Array of public image URLs to modify (required, up to 16 images)
1503
+ * - `prompt`: Text description of desired modifications (required)
1504
+ * - `size`: Output image dimensions (default: "auto")
1505
+ * - `quality`: Image quality ("standard" or "hd", default: "standard")
1506
+ * - `n`: Number of output images to generate (default: 1)
1507
+ * - `background`: Background handling ("auto", "transparent", "opaque", default: "auto")
1508
+ * - Plus optional signal parameter
1509
+ *
1510
+ * @example
1511
+ * ```ts
1512
+ * // Professional headshots from casual photos
1513
+ * const { data } = await blink.ai.modifyImage({
1514
+ * images: [
1515
+ * "https://storage.example.com/user-photo-1.jpg",
1516
+ * "https://storage.example.com/user-photo-2.jpg"
1517
+ * ],
1518
+ * prompt: "Transform into professional business headshots with studio lighting",
1519
+ * quality: "hd",
1520
+ * n: 4
1521
+ * });
1522
+ * data.forEach((img, i) => console.log(`Headshot ${i+1}:`, img.url));
1523
+ *
1524
+ * // Artistic style transformation
1525
+ * const { data } = await blink.ai.modifyImage({
1526
+ * images: ["https://storage.example.com/portrait.jpg"],
1527
+ * prompt: "Transform into oil painting style with dramatic lighting",
1528
+ * quality: "hd",
1529
+ * size: "1024x1024"
1530
+ * });
1531
+ *
1532
+ * // Background replacement
1533
+ * const { data } = await blink.ai.modifyImage({
1534
+ * images: ["https://storage.example.com/product.jpg"],
1535
+ * prompt: "Remove background and place on clean white studio background",
1536
+ * background: "transparent",
1537
+ * n: 2
1538
+ * });
1539
+ *
1540
+ * // Batch processing multiple photos
1541
+ * const userPhotos = [
1542
+ * "https://storage.example.com/photo1.jpg",
1543
+ * "https://storage.example.com/photo2.jpg",
1544
+ * "https://storage.example.com/photo3.jpg"
1545
+ * ];
1546
+ * const { data } = await blink.ai.modifyImage({
1547
+ * images: userPhotos,
1548
+ * prompt: "Convert to black and white vintage style photographs",
1549
+ * quality: "hd"
1403
1550
  * });
1404
- * console.log("Base64 data:", data[0].b64_json);
1405
1551
  * ```
1406
1552
  *
1407
1553
  * @returns Promise<ImageGenerationResponse> - Object containing:
1408
- * - `data`: Array of generated images with url or b64_json
1554
+ * - `data`: Array of modified images with URLs
1555
+ * - `created`: Timestamp of generation
1556
+ * - `usage`: Token usage information
1409
1557
  */
1410
- generateImage(options: ImageGenerationRequest): Promise<ImageGenerationResponse>;
1558
+ modifyImage(options: {
1559
+ images: string[];
1560
+ prompt: string;
1561
+ size?: string;
1562
+ quality?: "standard" | "hd";
1563
+ n?: number;
1564
+ background?: "auto" | "transparent" | "opaque";
1565
+ signal?: AbortSignal;
1566
+ }): Promise<ImageGenerationResponse>;
1411
1567
  /**
1412
1568
  * Converts text to speech using AI voice synthesis models.
1413
1569
  *