@coreviz/sdk 1.0.12 → 1.0.14
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 +55 -3
- package/dist/coreviz.d.ts +7 -0
- package/dist/coreviz.js +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,39 @@
|
|
|
1
|
+
[](https://coreviz.io)
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<h1>CoreViz</h1>
|
|
5
|
+
<a href="https://coreviz.io/">Home</a>
|
|
6
|
+
<span> • </span>
|
|
7
|
+
<a href="https://lab.coreviz.io/">Studio</a>
|
|
8
|
+
<span> • </span>
|
|
9
|
+
<a href="https://github.com/coreviz/cli">CLI</a>
|
|
10
|
+
<span> • </span>
|
|
11
|
+
<a href="https://github.com/coreviz/sdk">SDK</a>
|
|
12
|
+
<span> • </span>
|
|
13
|
+
<a href="https://docs.coreviz.io/">Docs</a>
|
|
14
|
+
<span> • </span>
|
|
15
|
+
<a href="https://x.com/withcoreviz">X</a>
|
|
16
|
+
<span> • </span>
|
|
17
|
+
<a href="https://www.linkedin.com/company/coreviz/">LinkedIn</a>
|
|
18
|
+
<span> • </span>
|
|
19
|
+
<a href="mailto:team@coreviz.io">Contact</a>
|
|
20
|
+
<br />
|
|
21
|
+
<br />
|
|
22
|
+
|
|
23
|
+
CoreViz is a Vision AI platform for teams and individuals working with thousands of visual assets.
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<a href="https://coreviz.io"><img alt="CoreViz" src="./demo/demo.gif"></a>
|
|
27
|
+
</p>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
|
|
1
31
|
# @coreviz/sdk
|
|
2
32
|
|
|
3
33
|
Easily integrate powerful image analysis and manipulation features into your applications with CoreViz (https://coreviz.io/) 's Vision SDK.
|
|
4
34
|
|
|
5
35
|
## Introduction
|
|
6
36
|
|
|
7
|
-
[](https://coreviz.io/)
|
|
8
|
-
|
|
9
37
|
The CoreViz SDK powers the [coreviz.io](https://coreviz.io/) platform and the [CoreViz CLI](https://github.com/coreviz/cli), providing fast, consistent AI image analysis and manipulation capabilities across environments.
|
|
10
38
|
|
|
11
39
|
You can try out the live demos and tools built with this SDK at [coreviz.io/tools](https://coreviz.io/tools), including:
|
|
@@ -105,6 +133,30 @@ const editedImage = await coreviz.edit('https://example.com/photo.jpg', {
|
|
|
105
133
|
});
|
|
106
134
|
```
|
|
107
135
|
|
|
136
|
+
### `coreviz.batchGenerate(prompt, options)`
|
|
137
|
+
|
|
138
|
+
Generates multiple images based on a text prompt, optionally using reference images for style/structure guidance.
|
|
139
|
+
|
|
140
|
+
**Parameters:**
|
|
141
|
+
- `prompt` (string): The text description of the image(s) to generate.
|
|
142
|
+
- `options` (object, optional):
|
|
143
|
+
- `referenceImages` (string[], optional): Array of reference images (URL/base64) to guide generation.
|
|
144
|
+
- `count` (number, optional): Number of images to generate (default: 1).
|
|
145
|
+
- `aspectRatio` (string, optional): Target aspect ratio (e.g., `'1:1'`, `'16:9'`, `'4:3'`).
|
|
146
|
+
- `model` (string, optional): The model to use (default: `'google/nano-banana-pro'`).
|
|
147
|
+
|
|
148
|
+
**Returns:**
|
|
149
|
+
- `Promise<string[]>`: An array of generated images as URLs.
|
|
150
|
+
|
|
151
|
+
**Example:**
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
const images = await coreviz.batchGenerate("A futuristic city skyline", {
|
|
155
|
+
count: 4,
|
|
156
|
+
aspectRatio: "16:9"
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
108
160
|
### `coreviz.embed(input, options?)`
|
|
109
161
|
|
|
110
162
|
Generates embeddings for image or text inputs, enabling semantic search and similarity comparison. Use with `coreviz.similarity(embeddingA, embeddingB)` to compare two images or an image and a text.
|
|
@@ -159,4 +211,4 @@ Utility function to resize images client-side or server-side before processing.
|
|
|
159
211
|
```typescript
|
|
160
212
|
const resized = await coreviz.resize(myFileObject, 800, 600);
|
|
161
213
|
// or import { resize } from '@coreviz/sdk';
|
|
162
|
-
```
|
|
214
|
+
```
|
package/dist/coreviz.d.ts
CHANGED
|
@@ -27,6 +27,12 @@ export interface EmbedOptions {
|
|
|
27
27
|
export interface EmbedResponse {
|
|
28
28
|
embedding: number[];
|
|
29
29
|
}
|
|
30
|
+
export interface BatchGenerateOptions {
|
|
31
|
+
referenceImages?: string[];
|
|
32
|
+
count?: number;
|
|
33
|
+
aspectRatio?: '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9';
|
|
34
|
+
model?: 'google/nano-banana' | 'google/nano-banana-pro';
|
|
35
|
+
}
|
|
30
36
|
export declare class CoreViz {
|
|
31
37
|
private apiKey?;
|
|
32
38
|
private token?;
|
|
@@ -35,6 +41,7 @@ export declare class CoreViz {
|
|
|
35
41
|
private handleResponse;
|
|
36
42
|
describe(image: string, options?: DescribeOptions): Promise<string>;
|
|
37
43
|
edit(image: string, options: EditOptions): Promise<string>;
|
|
44
|
+
batchGenerate(prompt: string, options?: BatchGenerateOptions): Promise<string[]>;
|
|
38
45
|
tag(image: string, options: TagOptions): Promise<TagResponse>;
|
|
39
46
|
private tagLocal;
|
|
40
47
|
embed(input: string, options?: EmbedOptions): Promise<EmbedResponse>;
|
package/dist/coreviz.js
CHANGED
|
@@ -103,6 +103,31 @@ class CoreViz {
|
|
|
103
103
|
throw err instanceof Error ? err : new Error("An unexpected error occurred.");
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
+
async batchGenerate(prompt, options = {}) {
|
|
107
|
+
try {
|
|
108
|
+
const headers = this.getHeaders();
|
|
109
|
+
let resizedImages = [];
|
|
110
|
+
if (options.referenceImages && options.referenceImages.length > 0) {
|
|
111
|
+
resizedImages = await Promise.all(options.referenceImages.map(img => (0, resize_1.resize)(img, 1024, 1024)));
|
|
112
|
+
}
|
|
113
|
+
const response = await fetch(`https://lab.coreviz.io/api/ai/batch-generate`, {
|
|
114
|
+
method: 'POST',
|
|
115
|
+
headers,
|
|
116
|
+
body: JSON.stringify({
|
|
117
|
+
prompt,
|
|
118
|
+
image: resizedImages.length > 0 ? resizedImages : undefined,
|
|
119
|
+
count: options.count || 1,
|
|
120
|
+
aspectRatio: options.aspectRatio,
|
|
121
|
+
model: options.model || 'google/nano-banana-pro',
|
|
122
|
+
}),
|
|
123
|
+
});
|
|
124
|
+
const data = await this.handleResponse(response);
|
|
125
|
+
return data.results || [];
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
throw err instanceof Error ? err : new Error("An unexpected error occurred.");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
106
131
|
async tag(image, options) {
|
|
107
132
|
const mode = options?.mode || 'api';
|
|
108
133
|
if (mode === 'local') {
|