@blinkdotnew/sdk 0.17.0 → 0.17.2
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 +3 -3
- package/dist/index.d.mts +34 -33
- package/dist/index.d.ts +34 -33
- package/dist/index.js +106 -103
- package/dist/index.mjs +106 -103
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -359,7 +359,7 @@ const { object: todoList } = await blink.ai.generateObject({
|
|
|
359
359
|
const { data } = await blink.ai.generateImage({
|
|
360
360
|
prompt: 'A serene landscape with mountains and a lake at sunset',
|
|
361
361
|
size: '1024x1024',
|
|
362
|
-
quality: '
|
|
362
|
+
quality: 'high',
|
|
363
363
|
n: 2
|
|
364
364
|
})
|
|
365
365
|
console.log('Image URL:', data[0].url)
|
|
@@ -368,10 +368,10 @@ console.log('Image URL:', data[0].url)
|
|
|
368
368
|
const { data: headshots } = await blink.ai.modifyImage({
|
|
369
369
|
images: ['https://storage.example.com/user-photo.jpg'], // ... up to 16 images maximum!
|
|
370
370
|
prompt: 'Generate professional business headshot with studio lighting for this person.',
|
|
371
|
-
quality: '
|
|
371
|
+
quality: 'high',
|
|
372
372
|
n: 4
|
|
373
373
|
})
|
|
374
|
-
// Options: size ('1024x1024', '1536x1024'), quality ('
|
|
374
|
+
// Options: size ('1024x1024', '1536x1024'), quality ('auto'|'low'|'medium'|'high'),
|
|
375
375
|
// background ('auto'|'transparent'|'opaque'), n (1-10 images)
|
|
376
376
|
|
|
377
377
|
|
package/dist/index.d.mts
CHANGED
|
@@ -222,7 +222,7 @@ interface ImageGenerationRequest {
|
|
|
222
222
|
prompt: string;
|
|
223
223
|
images?: string[];
|
|
224
224
|
size?: string;
|
|
225
|
-
quality?: '
|
|
225
|
+
quality?: 'auto' | 'low' | 'medium' | 'high';
|
|
226
226
|
background?: 'auto' | 'transparent' | 'opaque';
|
|
227
227
|
n?: number;
|
|
228
228
|
response_format?: 'url' | 'b64_json';
|
|
@@ -291,7 +291,7 @@ interface BlinkAI {
|
|
|
291
291
|
images: string[];
|
|
292
292
|
prompt: string;
|
|
293
293
|
size?: string;
|
|
294
|
-
quality?: "
|
|
294
|
+
quality?: "auto" | "low" | "medium" | "high";
|
|
295
295
|
n?: number;
|
|
296
296
|
background?: "auto" | "transparent" | "opaque";
|
|
297
297
|
signal?: AbortSignal;
|
|
@@ -625,6 +625,7 @@ declare class HttpClient {
|
|
|
625
625
|
uploadFile(path: string, file: File | Blob | Buffer, filePath: string, options?: {
|
|
626
626
|
upsert?: boolean;
|
|
627
627
|
onProgress?: (percent: number) => void;
|
|
628
|
+
contentType?: string;
|
|
628
629
|
}): Promise<BlinkResponse<any>>;
|
|
629
630
|
/**
|
|
630
631
|
* Upload with progress tracking using XMLHttpRequest
|
|
@@ -685,7 +686,7 @@ declare class HttpClient {
|
|
|
685
686
|
model?: string;
|
|
686
687
|
images?: string[];
|
|
687
688
|
size?: string;
|
|
688
|
-
quality?: '
|
|
689
|
+
quality?: 'auto' | 'low' | 'medium' | 'high';
|
|
689
690
|
background?: 'auto' | 'transparent' | 'opaque';
|
|
690
691
|
n?: number;
|
|
691
692
|
response_format?: 'url' | 'b64_json';
|
|
@@ -1451,7 +1452,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1451
1452
|
* @param options - Object containing:
|
|
1452
1453
|
* - `prompt`: Text description of the desired image (required)
|
|
1453
1454
|
* - `size`: Image dimensions (default: "1024x1024")
|
|
1454
|
-
* - `quality`: Image quality ("
|
|
1455
|
+
* - `quality`: Image quality ("auto", "low", "medium", or "high", default: "auto")
|
|
1455
1456
|
* - `n`: Number of images to generate (default: 1)
|
|
1456
1457
|
* - `background`: Background handling ("auto", "transparent", "opaque", default: "auto")
|
|
1457
1458
|
* - Plus optional signal parameter
|
|
@@ -1464,21 +1465,21 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1464
1465
|
* });
|
|
1465
1466
|
* console.log("Image URL:", data[0].url);
|
|
1466
1467
|
*
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1468
|
+
* // High-quality image with specific size
|
|
1469
|
+
* const { data } = await blink.ai.generateImage({
|
|
1470
|
+
* prompt: "A futuristic city skyline with flying cars",
|
|
1471
|
+
* size: "1536x1024",
|
|
1472
|
+
* quality: "high",
|
|
1473
|
+
* background: "transparent"
|
|
1474
|
+
* });
|
|
1474
1475
|
*
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1476
|
+
* // Multiple images
|
|
1477
|
+
* const { data } = await blink.ai.generateImage({
|
|
1478
|
+
* prompt: "A cute robot mascot for a tech company",
|
|
1479
|
+
* n: 3,
|
|
1480
|
+
* size: "1024x1024",
|
|
1481
|
+
* quality: "high"
|
|
1482
|
+
* });
|
|
1482
1483
|
* data.forEach((img, i) => console.log(`Image ${i+1}:`, img.url));
|
|
1483
1484
|
* ```
|
|
1484
1485
|
*
|
|
@@ -1490,7 +1491,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1490
1491
|
generateImage(options: {
|
|
1491
1492
|
prompt: string;
|
|
1492
1493
|
size?: string;
|
|
1493
|
-
quality?: "
|
|
1494
|
+
quality?: "auto" | "low" | "medium" | "high";
|
|
1494
1495
|
n?: number;
|
|
1495
1496
|
background?: "auto" | "transparent" | "opaque";
|
|
1496
1497
|
signal?: AbortSignal;
|
|
@@ -1502,7 +1503,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1502
1503
|
* - `images`: Array of public image URLs to modify (required, up to 16 images)
|
|
1503
1504
|
* - `prompt`: Text description of desired modifications (required)
|
|
1504
1505
|
* - `size`: Output image dimensions (default: "auto")
|
|
1505
|
-
* - `quality`: Image quality ("
|
|
1506
|
+
* - `quality`: Image quality ("auto", "low", "medium", or "high", default: "auto")
|
|
1506
1507
|
* - `n`: Number of output images to generate (default: 1)
|
|
1507
1508
|
* - `background`: Background handling ("auto", "transparent", "opaque", default: "auto")
|
|
1508
1509
|
* - Plus optional signal parameter
|
|
@@ -1515,19 +1516,19 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1515
1516
|
* "https://storage.example.com/user-photo-1.jpg",
|
|
1516
1517
|
* "https://storage.example.com/user-photo-2.jpg"
|
|
1517
1518
|
* ],
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1519
|
+
* prompt: "Transform into professional business headshots with studio lighting",
|
|
1520
|
+
* quality: "high",
|
|
1521
|
+
* n: 4
|
|
1521
1522
|
* });
|
|
1522
1523
|
* data.forEach((img, i) => console.log(`Headshot ${i+1}:`, img.url));
|
|
1523
1524
|
*
|
|
1524
1525
|
* // Artistic style transformation
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1526
|
+
* const { data } = await blink.ai.modifyImage({
|
|
1527
|
+
* images: ["https://storage.example.com/portrait.jpg"],
|
|
1528
|
+
* prompt: "Transform into oil painting style with dramatic lighting",
|
|
1529
|
+
* quality: "high",
|
|
1530
|
+
* size: "1024x1024"
|
|
1531
|
+
* });
|
|
1531
1532
|
*
|
|
1532
1533
|
* // Background replacement
|
|
1533
1534
|
* const { data } = await blink.ai.modifyImage({
|
|
@@ -1544,9 +1545,9 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1544
1545
|
* "https://storage.example.com/photo3.jpg"
|
|
1545
1546
|
* ];
|
|
1546
1547
|
* const { data } = await blink.ai.modifyImage({
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1548
|
+
* images: userPhotos,
|
|
1549
|
+
* prompt: "Convert to black and white vintage style photographs",
|
|
1550
|
+
* quality: "high"
|
|
1550
1551
|
* });
|
|
1551
1552
|
* ```
|
|
1552
1553
|
*
|
|
@@ -1559,7 +1560,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1559
1560
|
images: string[];
|
|
1560
1561
|
prompt: string;
|
|
1561
1562
|
size?: string;
|
|
1562
|
-
quality?: "
|
|
1563
|
+
quality?: "auto" | "low" | "medium" | "high";
|
|
1563
1564
|
n?: number;
|
|
1564
1565
|
background?: "auto" | "transparent" | "opaque";
|
|
1565
1566
|
signal?: AbortSignal;
|
package/dist/index.d.ts
CHANGED
|
@@ -222,7 +222,7 @@ interface ImageGenerationRequest {
|
|
|
222
222
|
prompt: string;
|
|
223
223
|
images?: string[];
|
|
224
224
|
size?: string;
|
|
225
|
-
quality?: '
|
|
225
|
+
quality?: 'auto' | 'low' | 'medium' | 'high';
|
|
226
226
|
background?: 'auto' | 'transparent' | 'opaque';
|
|
227
227
|
n?: number;
|
|
228
228
|
response_format?: 'url' | 'b64_json';
|
|
@@ -291,7 +291,7 @@ interface BlinkAI {
|
|
|
291
291
|
images: string[];
|
|
292
292
|
prompt: string;
|
|
293
293
|
size?: string;
|
|
294
|
-
quality?: "
|
|
294
|
+
quality?: "auto" | "low" | "medium" | "high";
|
|
295
295
|
n?: number;
|
|
296
296
|
background?: "auto" | "transparent" | "opaque";
|
|
297
297
|
signal?: AbortSignal;
|
|
@@ -625,6 +625,7 @@ declare class HttpClient {
|
|
|
625
625
|
uploadFile(path: string, file: File | Blob | Buffer, filePath: string, options?: {
|
|
626
626
|
upsert?: boolean;
|
|
627
627
|
onProgress?: (percent: number) => void;
|
|
628
|
+
contentType?: string;
|
|
628
629
|
}): Promise<BlinkResponse<any>>;
|
|
629
630
|
/**
|
|
630
631
|
* Upload with progress tracking using XMLHttpRequest
|
|
@@ -685,7 +686,7 @@ declare class HttpClient {
|
|
|
685
686
|
model?: string;
|
|
686
687
|
images?: string[];
|
|
687
688
|
size?: string;
|
|
688
|
-
quality?: '
|
|
689
|
+
quality?: 'auto' | 'low' | 'medium' | 'high';
|
|
689
690
|
background?: 'auto' | 'transparent' | 'opaque';
|
|
690
691
|
n?: number;
|
|
691
692
|
response_format?: 'url' | 'b64_json';
|
|
@@ -1451,7 +1452,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1451
1452
|
* @param options - Object containing:
|
|
1452
1453
|
* - `prompt`: Text description of the desired image (required)
|
|
1453
1454
|
* - `size`: Image dimensions (default: "1024x1024")
|
|
1454
|
-
* - `quality`: Image quality ("
|
|
1455
|
+
* - `quality`: Image quality ("auto", "low", "medium", or "high", default: "auto")
|
|
1455
1456
|
* - `n`: Number of images to generate (default: 1)
|
|
1456
1457
|
* - `background`: Background handling ("auto", "transparent", "opaque", default: "auto")
|
|
1457
1458
|
* - Plus optional signal parameter
|
|
@@ -1464,21 +1465,21 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1464
1465
|
* });
|
|
1465
1466
|
* console.log("Image URL:", data[0].url);
|
|
1466
1467
|
*
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1468
|
+
* // High-quality image with specific size
|
|
1469
|
+
* const { data } = await blink.ai.generateImage({
|
|
1470
|
+
* prompt: "A futuristic city skyline with flying cars",
|
|
1471
|
+
* size: "1536x1024",
|
|
1472
|
+
* quality: "high",
|
|
1473
|
+
* background: "transparent"
|
|
1474
|
+
* });
|
|
1474
1475
|
*
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1476
|
+
* // Multiple images
|
|
1477
|
+
* const { data } = await blink.ai.generateImage({
|
|
1478
|
+
* prompt: "A cute robot mascot for a tech company",
|
|
1479
|
+
* n: 3,
|
|
1480
|
+
* size: "1024x1024",
|
|
1481
|
+
* quality: "high"
|
|
1482
|
+
* });
|
|
1482
1483
|
* data.forEach((img, i) => console.log(`Image ${i+1}:`, img.url));
|
|
1483
1484
|
* ```
|
|
1484
1485
|
*
|
|
@@ -1490,7 +1491,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1490
1491
|
generateImage(options: {
|
|
1491
1492
|
prompt: string;
|
|
1492
1493
|
size?: string;
|
|
1493
|
-
quality?: "
|
|
1494
|
+
quality?: "auto" | "low" | "medium" | "high";
|
|
1494
1495
|
n?: number;
|
|
1495
1496
|
background?: "auto" | "transparent" | "opaque";
|
|
1496
1497
|
signal?: AbortSignal;
|
|
@@ -1502,7 +1503,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1502
1503
|
* - `images`: Array of public image URLs to modify (required, up to 16 images)
|
|
1503
1504
|
* - `prompt`: Text description of desired modifications (required)
|
|
1504
1505
|
* - `size`: Output image dimensions (default: "auto")
|
|
1505
|
-
* - `quality`: Image quality ("
|
|
1506
|
+
* - `quality`: Image quality ("auto", "low", "medium", or "high", default: "auto")
|
|
1506
1507
|
* - `n`: Number of output images to generate (default: 1)
|
|
1507
1508
|
* - `background`: Background handling ("auto", "transparent", "opaque", default: "auto")
|
|
1508
1509
|
* - Plus optional signal parameter
|
|
@@ -1515,19 +1516,19 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1515
1516
|
* "https://storage.example.com/user-photo-1.jpg",
|
|
1516
1517
|
* "https://storage.example.com/user-photo-2.jpg"
|
|
1517
1518
|
* ],
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1519
|
+
* prompt: "Transform into professional business headshots with studio lighting",
|
|
1520
|
+
* quality: "high",
|
|
1521
|
+
* n: 4
|
|
1521
1522
|
* });
|
|
1522
1523
|
* data.forEach((img, i) => console.log(`Headshot ${i+1}:`, img.url));
|
|
1523
1524
|
*
|
|
1524
1525
|
* // Artistic style transformation
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1526
|
+
* const { data } = await blink.ai.modifyImage({
|
|
1527
|
+
* images: ["https://storage.example.com/portrait.jpg"],
|
|
1528
|
+
* prompt: "Transform into oil painting style with dramatic lighting",
|
|
1529
|
+
* quality: "high",
|
|
1530
|
+
* size: "1024x1024"
|
|
1531
|
+
* });
|
|
1531
1532
|
*
|
|
1532
1533
|
* // Background replacement
|
|
1533
1534
|
* const { data } = await blink.ai.modifyImage({
|
|
@@ -1544,9 +1545,9 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1544
1545
|
* "https://storage.example.com/photo3.jpg"
|
|
1545
1546
|
* ];
|
|
1546
1547
|
* const { data } = await blink.ai.modifyImage({
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1548
|
+
* images: userPhotos,
|
|
1549
|
+
* prompt: "Convert to black and white vintage style photographs",
|
|
1550
|
+
* quality: "high"
|
|
1550
1551
|
* });
|
|
1551
1552
|
* ```
|
|
1552
1553
|
*
|
|
@@ -1559,7 +1560,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1559
1560
|
images: string[];
|
|
1560
1561
|
prompt: string;
|
|
1561
1562
|
size?: string;
|
|
1562
|
-
quality?: "
|
|
1563
|
+
quality?: "auto" | "low" | "medium" | "high";
|
|
1563
1564
|
n?: number;
|
|
1564
1565
|
background?: "auto" | "transparent" | "opaque";
|
|
1565
1566
|
signal?: AbortSignal;
|
package/dist/index.js
CHANGED
|
@@ -403,9 +403,10 @@ var HttpClient = class {
|
|
|
403
403
|
if (file instanceof File) {
|
|
404
404
|
formData.append("file", file);
|
|
405
405
|
} else if (file instanceof Blob) {
|
|
406
|
-
|
|
406
|
+
const blobWithType = options.contentType ? new Blob([file], { type: options.contentType }) : file;
|
|
407
|
+
formData.append("file", blobWithType);
|
|
407
408
|
} else if (typeof Buffer !== "undefined" && file instanceof Buffer) {
|
|
408
|
-
const blob = new Blob([file]);
|
|
409
|
+
const blob = new Blob([file], { type: options.contentType || "application/octet-stream" });
|
|
409
410
|
formData.append("file", blob);
|
|
410
411
|
} else {
|
|
411
412
|
throw new BlinkValidationError("Unsupported file type");
|
|
@@ -1866,7 +1867,9 @@ var BlinkStorageImpl = class {
|
|
|
1866
1867
|
// Use corrected path with proper extension
|
|
1867
1868
|
{
|
|
1868
1869
|
upsert: options.upsert,
|
|
1869
|
-
onProgress: options.onProgress
|
|
1870
|
+
onProgress: options.onProgress,
|
|
1871
|
+
contentType: detectedContentType
|
|
1872
|
+
// Pass detected content type
|
|
1870
1873
|
}
|
|
1871
1874
|
);
|
|
1872
1875
|
if (response.data?.data?.publicUrl) {
|
|
@@ -2557,47 +2560,47 @@ var BlinkAIImpl = class {
|
|
|
2557
2560
|
}
|
|
2558
2561
|
}
|
|
2559
2562
|
/**
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2563
|
+
* Generates images from text descriptions using AI.
|
|
2564
|
+
*
|
|
2565
|
+
* @param options - Object containing:
|
|
2566
|
+
* - `prompt`: Text description of the desired image (required)
|
|
2567
|
+
* - `size`: Image dimensions (default: "1024x1024")
|
|
2568
|
+
* - `quality`: Image quality ("auto", "low", "medium", or "high", default: "auto")
|
|
2569
|
+
* - `n`: Number of images to generate (default: 1)
|
|
2570
|
+
* - `background`: Background handling ("auto", "transparent", "opaque", default: "auto")
|
|
2571
|
+
* - Plus optional signal parameter
|
|
2572
|
+
*
|
|
2573
|
+
* @example
|
|
2574
|
+
* ```ts
|
|
2575
|
+
* // Basic image generation
|
|
2576
|
+
* const { data } = await blink.ai.generateImage({
|
|
2577
|
+
* prompt: "A serene landscape with mountains and a lake at sunset"
|
|
2578
|
+
* });
|
|
2579
|
+
* console.log("Image URL:", data[0].url);
|
|
2580
|
+
*
|
|
2581
|
+
* // High-quality image with specific size
|
|
2582
|
+
* const { data } = await blink.ai.generateImage({
|
|
2583
|
+
* prompt: "A futuristic city skyline with flying cars",
|
|
2584
|
+
* size: "1536x1024",
|
|
2585
|
+
* quality: "high",
|
|
2586
|
+
* background: "transparent"
|
|
2587
|
+
* });
|
|
2588
|
+
*
|
|
2589
|
+
* // Multiple images
|
|
2590
|
+
* const { data } = await blink.ai.generateImage({
|
|
2591
|
+
* prompt: "A cute robot mascot for a tech company",
|
|
2592
|
+
* n: 3,
|
|
2593
|
+
* size: "1024x1024",
|
|
2594
|
+
* quality: "high"
|
|
2595
|
+
* });
|
|
2596
|
+
* data.forEach((img, i) => console.log(`Image ${i+1}:`, img.url));
|
|
2597
|
+
* ```
|
|
2598
|
+
*
|
|
2599
|
+
* @returns Promise<ImageGenerationResponse> - Object containing:
|
|
2600
|
+
* - `data`: Array of generated images with URLs
|
|
2601
|
+
* - `created`: Timestamp of generation
|
|
2602
|
+
* - `usage`: Token usage information
|
|
2603
|
+
*/
|
|
2601
2604
|
async generateImage(options) {
|
|
2602
2605
|
try {
|
|
2603
2606
|
if (!options.prompt) {
|
|
@@ -2648,65 +2651,65 @@ var BlinkAIImpl = class {
|
|
|
2648
2651
|
}
|
|
2649
2652
|
}
|
|
2650
2653
|
/**
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2654
|
+
* Modifies existing images using AI with text prompts for image-to-image editing.
|
|
2655
|
+
*
|
|
2656
|
+
* @param options - Object containing:
|
|
2657
|
+
* - `images`: Array of public image URLs to modify (required, up to 16 images)
|
|
2658
|
+
* - `prompt`: Text description of desired modifications (required)
|
|
2659
|
+
* - `size`: Output image dimensions (default: "auto")
|
|
2660
|
+
* - `quality`: Image quality ("auto", "low", "medium", or "high", default: "auto")
|
|
2661
|
+
* - `n`: Number of output images to generate (default: 1)
|
|
2662
|
+
* - `background`: Background handling ("auto", "transparent", "opaque", default: "auto")
|
|
2663
|
+
* - Plus optional signal parameter
|
|
2664
|
+
*
|
|
2665
|
+
* @example
|
|
2666
|
+
* ```ts
|
|
2667
|
+
* // Professional headshots from casual photos
|
|
2668
|
+
* const { data } = await blink.ai.modifyImage({
|
|
2669
|
+
* images: [
|
|
2670
|
+
* "https://storage.example.com/user-photo-1.jpg",
|
|
2671
|
+
* "https://storage.example.com/user-photo-2.jpg"
|
|
2672
|
+
* ],
|
|
2673
|
+
* prompt: "Transform into professional business headshots with studio lighting",
|
|
2674
|
+
* quality: "high",
|
|
2675
|
+
* n: 4
|
|
2676
|
+
* });
|
|
2677
|
+
* data.forEach((img, i) => console.log(`Headshot ${i+1}:`, img.url));
|
|
2678
|
+
*
|
|
2679
|
+
* // Artistic style transformation
|
|
2680
|
+
* const { data } = await blink.ai.modifyImage({
|
|
2681
|
+
* images: ["https://storage.example.com/portrait.jpg"],
|
|
2682
|
+
* prompt: "Transform into oil painting style with dramatic lighting",
|
|
2683
|
+
* quality: "high",
|
|
2684
|
+
* size: "1024x1024"
|
|
2685
|
+
* });
|
|
2686
|
+
*
|
|
2687
|
+
* // Background replacement
|
|
2688
|
+
* const { data } = await blink.ai.modifyImage({
|
|
2689
|
+
* images: ["https://storage.example.com/product.jpg"],
|
|
2690
|
+
* prompt: "Remove background and place on clean white studio background",
|
|
2691
|
+
* background: "transparent",
|
|
2692
|
+
* n: 2
|
|
2693
|
+
* });
|
|
2694
|
+
*
|
|
2695
|
+
* // Batch processing multiple photos
|
|
2696
|
+
* const userPhotos = [
|
|
2697
|
+
* "https://storage.example.com/photo1.jpg",
|
|
2698
|
+
* "https://storage.example.com/photo2.jpg",
|
|
2699
|
+
* "https://storage.example.com/photo3.jpg"
|
|
2700
|
+
* ];
|
|
2701
|
+
* const { data } = await blink.ai.modifyImage({
|
|
2702
|
+
* images: userPhotos,
|
|
2703
|
+
* prompt: "Convert to black and white vintage style photographs",
|
|
2704
|
+
* quality: "high"
|
|
2705
|
+
* });
|
|
2706
|
+
* ```
|
|
2707
|
+
*
|
|
2708
|
+
* @returns Promise<ImageGenerationResponse> - Object containing:
|
|
2709
|
+
* - `data`: Array of modified images with URLs
|
|
2710
|
+
* - `created`: Timestamp of generation
|
|
2711
|
+
* - `usage`: Token usage information
|
|
2712
|
+
*/
|
|
2710
2713
|
async modifyImage(options) {
|
|
2711
2714
|
try {
|
|
2712
2715
|
if (!options.prompt) {
|
package/dist/index.mjs
CHANGED
|
@@ -401,9 +401,10 @@ var HttpClient = class {
|
|
|
401
401
|
if (file instanceof File) {
|
|
402
402
|
formData.append("file", file);
|
|
403
403
|
} else if (file instanceof Blob) {
|
|
404
|
-
|
|
404
|
+
const blobWithType = options.contentType ? new Blob([file], { type: options.contentType }) : file;
|
|
405
|
+
formData.append("file", blobWithType);
|
|
405
406
|
} else if (typeof Buffer !== "undefined" && file instanceof Buffer) {
|
|
406
|
-
const blob = new Blob([file]);
|
|
407
|
+
const blob = new Blob([file], { type: options.contentType || "application/octet-stream" });
|
|
407
408
|
formData.append("file", blob);
|
|
408
409
|
} else {
|
|
409
410
|
throw new BlinkValidationError("Unsupported file type");
|
|
@@ -1864,7 +1865,9 @@ var BlinkStorageImpl = class {
|
|
|
1864
1865
|
// Use corrected path with proper extension
|
|
1865
1866
|
{
|
|
1866
1867
|
upsert: options.upsert,
|
|
1867
|
-
onProgress: options.onProgress
|
|
1868
|
+
onProgress: options.onProgress,
|
|
1869
|
+
contentType: detectedContentType
|
|
1870
|
+
// Pass detected content type
|
|
1868
1871
|
}
|
|
1869
1872
|
);
|
|
1870
1873
|
if (response.data?.data?.publicUrl) {
|
|
@@ -2555,47 +2558,47 @@ var BlinkAIImpl = class {
|
|
|
2555
2558
|
}
|
|
2556
2559
|
}
|
|
2557
2560
|
/**
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2561
|
+
* Generates images from text descriptions using AI.
|
|
2562
|
+
*
|
|
2563
|
+
* @param options - Object containing:
|
|
2564
|
+
* - `prompt`: Text description of the desired image (required)
|
|
2565
|
+
* - `size`: Image dimensions (default: "1024x1024")
|
|
2566
|
+
* - `quality`: Image quality ("auto", "low", "medium", or "high", default: "auto")
|
|
2567
|
+
* - `n`: Number of images to generate (default: 1)
|
|
2568
|
+
* - `background`: Background handling ("auto", "transparent", "opaque", default: "auto")
|
|
2569
|
+
* - Plus optional signal parameter
|
|
2570
|
+
*
|
|
2571
|
+
* @example
|
|
2572
|
+
* ```ts
|
|
2573
|
+
* // Basic image generation
|
|
2574
|
+
* const { data } = await blink.ai.generateImage({
|
|
2575
|
+
* prompt: "A serene landscape with mountains and a lake at sunset"
|
|
2576
|
+
* });
|
|
2577
|
+
* console.log("Image URL:", data[0].url);
|
|
2578
|
+
*
|
|
2579
|
+
* // High-quality image with specific size
|
|
2580
|
+
* const { data } = await blink.ai.generateImage({
|
|
2581
|
+
* prompt: "A futuristic city skyline with flying cars",
|
|
2582
|
+
* size: "1536x1024",
|
|
2583
|
+
* quality: "high",
|
|
2584
|
+
* background: "transparent"
|
|
2585
|
+
* });
|
|
2586
|
+
*
|
|
2587
|
+
* // Multiple images
|
|
2588
|
+
* const { data } = await blink.ai.generateImage({
|
|
2589
|
+
* prompt: "A cute robot mascot for a tech company",
|
|
2590
|
+
* n: 3,
|
|
2591
|
+
* size: "1024x1024",
|
|
2592
|
+
* quality: "high"
|
|
2593
|
+
* });
|
|
2594
|
+
* data.forEach((img, i) => console.log(`Image ${i+1}:`, img.url));
|
|
2595
|
+
* ```
|
|
2596
|
+
*
|
|
2597
|
+
* @returns Promise<ImageGenerationResponse> - Object containing:
|
|
2598
|
+
* - `data`: Array of generated images with URLs
|
|
2599
|
+
* - `created`: Timestamp of generation
|
|
2600
|
+
* - `usage`: Token usage information
|
|
2601
|
+
*/
|
|
2599
2602
|
async generateImage(options) {
|
|
2600
2603
|
try {
|
|
2601
2604
|
if (!options.prompt) {
|
|
@@ -2646,65 +2649,65 @@ var BlinkAIImpl = class {
|
|
|
2646
2649
|
}
|
|
2647
2650
|
}
|
|
2648
2651
|
/**
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2652
|
+
* Modifies existing images using AI with text prompts for image-to-image editing.
|
|
2653
|
+
*
|
|
2654
|
+
* @param options - Object containing:
|
|
2655
|
+
* - `images`: Array of public image URLs to modify (required, up to 16 images)
|
|
2656
|
+
* - `prompt`: Text description of desired modifications (required)
|
|
2657
|
+
* - `size`: Output image dimensions (default: "auto")
|
|
2658
|
+
* - `quality`: Image quality ("auto", "low", "medium", or "high", default: "auto")
|
|
2659
|
+
* - `n`: Number of output images to generate (default: 1)
|
|
2660
|
+
* - `background`: Background handling ("auto", "transparent", "opaque", default: "auto")
|
|
2661
|
+
* - Plus optional signal parameter
|
|
2662
|
+
*
|
|
2663
|
+
* @example
|
|
2664
|
+
* ```ts
|
|
2665
|
+
* // Professional headshots from casual photos
|
|
2666
|
+
* const { data } = await blink.ai.modifyImage({
|
|
2667
|
+
* images: [
|
|
2668
|
+
* "https://storage.example.com/user-photo-1.jpg",
|
|
2669
|
+
* "https://storage.example.com/user-photo-2.jpg"
|
|
2670
|
+
* ],
|
|
2671
|
+
* prompt: "Transform into professional business headshots with studio lighting",
|
|
2672
|
+
* quality: "high",
|
|
2673
|
+
* n: 4
|
|
2674
|
+
* });
|
|
2675
|
+
* data.forEach((img, i) => console.log(`Headshot ${i+1}:`, img.url));
|
|
2676
|
+
*
|
|
2677
|
+
* // Artistic style transformation
|
|
2678
|
+
* const { data } = await blink.ai.modifyImage({
|
|
2679
|
+
* images: ["https://storage.example.com/portrait.jpg"],
|
|
2680
|
+
* prompt: "Transform into oil painting style with dramatic lighting",
|
|
2681
|
+
* quality: "high",
|
|
2682
|
+
* size: "1024x1024"
|
|
2683
|
+
* });
|
|
2684
|
+
*
|
|
2685
|
+
* // Background replacement
|
|
2686
|
+
* const { data } = await blink.ai.modifyImage({
|
|
2687
|
+
* images: ["https://storage.example.com/product.jpg"],
|
|
2688
|
+
* prompt: "Remove background and place on clean white studio background",
|
|
2689
|
+
* background: "transparent",
|
|
2690
|
+
* n: 2
|
|
2691
|
+
* });
|
|
2692
|
+
*
|
|
2693
|
+
* // Batch processing multiple photos
|
|
2694
|
+
* const userPhotos = [
|
|
2695
|
+
* "https://storage.example.com/photo1.jpg",
|
|
2696
|
+
* "https://storage.example.com/photo2.jpg",
|
|
2697
|
+
* "https://storage.example.com/photo3.jpg"
|
|
2698
|
+
* ];
|
|
2699
|
+
* const { data } = await blink.ai.modifyImage({
|
|
2700
|
+
* images: userPhotos,
|
|
2701
|
+
* prompt: "Convert to black and white vintage style photographs",
|
|
2702
|
+
* quality: "high"
|
|
2703
|
+
* });
|
|
2704
|
+
* ```
|
|
2705
|
+
*
|
|
2706
|
+
* @returns Promise<ImageGenerationResponse> - Object containing:
|
|
2707
|
+
* - `data`: Array of modified images with URLs
|
|
2708
|
+
* - `created`: Timestamp of generation
|
|
2709
|
+
* - `usage`: Token usage information
|
|
2710
|
+
*/
|
|
2708
2711
|
async modifyImage(options) {
|
|
2709
2712
|
try {
|
|
2710
2713
|
if (!options.prompt) {
|
package/package.json
CHANGED