@vargai/gateway 0.1.0 → 0.1.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 +47 -113
- package/package.json +18 -4
package/README.md
CHANGED
|
@@ -1,170 +1,104 @@
|
|
|
1
1
|
# @vargai/gateway
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
vercel AI SDK provider for varg gateway — generate video, image, speech, and music through a unified API.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
bun add @vargai/gateway
|
|
8
|
+
bun add @vargai/gateway vargai
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## usage
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import {
|
|
14
|
+
import { generateVideo } from "vargai/ai";
|
|
15
|
+
import { createVarg } from "@vargai/gateway";
|
|
15
16
|
|
|
16
|
-
const
|
|
17
|
-
apiKey:
|
|
18
|
-
baseUrl: "https://api.
|
|
19
|
-
providerKeys: {
|
|
20
|
-
// optional BYOK
|
|
21
|
-
fal: "fal_xxx",
|
|
22
|
-
elevenlabs: "el_xxx",
|
|
23
|
-
},
|
|
17
|
+
const varg = createVarg({
|
|
18
|
+
apiKey: process.env.VARG_API_KEY!,
|
|
19
|
+
baseUrl: "https://varg-api.fly.dev/v1", // optional
|
|
24
20
|
});
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
duration: 5,
|
|
22
|
+
const result = await generateVideo({
|
|
23
|
+
model: varg.videoModel("kling-v2.6"),
|
|
24
|
+
prompt: "dancing cats in a neon disco, anime style",
|
|
25
|
+
aspectRatio: "16:9",
|
|
31
26
|
});
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
const result = await client.waitForJob(videoJob.job_id);
|
|
35
|
-
console.log(result.output?.url);
|
|
36
|
-
|
|
37
|
-
// or check manually
|
|
38
|
-
const job = await client.getJob(videoJob.job_id);
|
|
39
|
-
if (job.status === "completed") {
|
|
40
|
-
console.log(job.output?.url);
|
|
41
|
-
}
|
|
28
|
+
await Bun.write("output.mp4", result.video.uint8Array);
|
|
42
29
|
```
|
|
43
30
|
|
|
44
|
-
##
|
|
45
|
-
|
|
46
|
-
### `createVideo(params)`
|
|
31
|
+
## models
|
|
47
32
|
|
|
48
|
-
|
|
33
|
+
### video
|
|
49
34
|
|
|
50
35
|
```typescript
|
|
51
|
-
|
|
52
|
-
|
|
36
|
+
import { generateVideo } from "vargai/ai";
|
|
37
|
+
|
|
38
|
+
const result = await generateVideo({
|
|
39
|
+
model: varg.videoModel("kling-v2.6"),
|
|
53
40
|
prompt: "warrior princess on cliff",
|
|
54
41
|
duration: 5,
|
|
55
|
-
|
|
56
|
-
files: [{ url: "https://s3.varg.ai/u/..." }], // optional reference images
|
|
42
|
+
aspectRatio: "16:9",
|
|
57
43
|
});
|
|
58
44
|
```
|
|
59
45
|
|
|
60
|
-
|
|
46
|
+
available: `kling-v2.6`, `kling-v2.5`, `kling-v2.1`, `kling-v2`, `wan-2.5`, `minimax`, `ltx-2-19b-distilled`, `grok-imagine`
|
|
61
47
|
|
|
62
|
-
|
|
48
|
+
### image
|
|
63
49
|
|
|
64
50
|
```typescript
|
|
65
|
-
|
|
66
|
-
|
|
51
|
+
import { generateImage } from "vargai/ai";
|
|
52
|
+
|
|
53
|
+
const result = await generateImage({
|
|
54
|
+
model: varg.imageModel("flux-schnell"),
|
|
67
55
|
prompt: "cyberpunk cityscape",
|
|
68
|
-
|
|
56
|
+
aspectRatio: "16:9",
|
|
69
57
|
});
|
|
70
58
|
```
|
|
71
59
|
|
|
72
|
-
|
|
60
|
+
available: `flux-pro`, `flux-dev`, `flux-schnell`, `recraft-v3`, `soul`
|
|
73
61
|
|
|
74
|
-
|
|
62
|
+
### speech
|
|
75
63
|
|
|
76
64
|
```typescript
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
import { generateSpeech } from "vargai/ai";
|
|
66
|
+
|
|
67
|
+
const result = await generateSpeech({
|
|
68
|
+
model: varg.speechModel("eleven_turbo_v2"),
|
|
79
69
|
text: "hello world",
|
|
80
70
|
voice: "rachel",
|
|
81
71
|
});
|
|
82
72
|
```
|
|
83
73
|
|
|
84
|
-
|
|
74
|
+
available: `eleven_turbo_v2`, `eleven_multilingual_v2`, `turbo`
|
|
85
75
|
|
|
86
|
-
|
|
76
|
+
### music
|
|
87
77
|
|
|
88
78
|
```typescript
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
import { generateMusic } from "vargai/ai";
|
|
80
|
+
|
|
81
|
+
const result = await generateMusic({
|
|
82
|
+
model: varg.musicModel("music_v1"),
|
|
91
83
|
prompt: "epic orchestral theme",
|
|
92
84
|
duration: 30,
|
|
93
85
|
});
|
|
94
86
|
```
|
|
95
87
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
upload file (image, video, audio). returns file reference.
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
const file = Bun.file("./hero.png");
|
|
102
|
-
const upload = await client.uploadFile(file, "image/png");
|
|
103
|
-
console.log(upload.url); // use in files array
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### `getJob(id)`
|
|
88
|
+
## BYOK
|
|
107
89
|
|
|
108
|
-
|
|
90
|
+
bring your own provider keys to skip metered billing:
|
|
109
91
|
|
|
110
92
|
```typescript
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
### `waitForJob(id, opts?)`
|
|
118
|
-
|
|
119
|
-
poll until job completes. returns final job.
|
|
120
|
-
|
|
121
|
-
```typescript
|
|
122
|
-
const job = await client.waitForJob("job_a1b2c3", {
|
|
123
|
-
pollIntervalMs: 2000, // default
|
|
124
|
-
maxAttempts: 150, // default (5 minutes)
|
|
93
|
+
const varg = createVarg({
|
|
94
|
+
apiKey: process.env.VARG_API_KEY!,
|
|
95
|
+
providerKeys: {
|
|
96
|
+
fal: "fal_xxx",
|
|
97
|
+
elevenlabs: "el_xxx",
|
|
98
|
+
},
|
|
125
99
|
});
|
|
126
100
|
```
|
|
127
101
|
|
|
128
|
-
### `cancelJob(id)`
|
|
129
|
-
|
|
130
|
-
cancel a running job.
|
|
131
|
-
|
|
132
|
-
```typescript
|
|
133
|
-
await client.cancelJob("job_a1b2c3");
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
## schemas
|
|
137
|
-
|
|
138
|
-
all schemas are exported for validation:
|
|
139
|
-
|
|
140
|
-
```typescript
|
|
141
|
-
import {
|
|
142
|
-
VideoRequestSchema,
|
|
143
|
-
ImageRequestSchema,
|
|
144
|
-
SpeechRequestSchema,
|
|
145
|
-
MusicRequestSchema,
|
|
146
|
-
JobResponseSchema,
|
|
147
|
-
FileUploadResponseSchema,
|
|
148
|
-
} from "@vargai/gateway";
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
## errors
|
|
152
|
-
|
|
153
|
-
```typescript
|
|
154
|
-
import { VargGatewayError } from "@vargai/gateway";
|
|
155
|
-
|
|
156
|
-
try {
|
|
157
|
-
await client.createVideo({ model: "invalid", prompt: "test" });
|
|
158
|
-
} catch (error) {
|
|
159
|
-
if (error instanceof VargGatewayError) {
|
|
160
|
-
console.log(error.message);
|
|
161
|
-
console.log(error.statusCode); // 400, 401, 404, 502, etc.
|
|
162
|
-
console.log(error.field); // validation error field
|
|
163
|
-
console.log(error.provider); // provider that failed
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
102
|
## license
|
|
169
103
|
|
|
170
104
|
mit
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vargai/gateway",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "typescript client for varg gateway api",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,15 +16,29 @@
|
|
|
16
16
|
"types": "./src/provider.ts"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
-
"files": [
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
20
23
|
"scripts": {
|
|
21
24
|
"build": "bun build src/index.ts --outdir dist --target bun --format esm && bun run build:types",
|
|
22
25
|
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist",
|
|
23
26
|
"prepublishOnly": "bun run build"
|
|
24
27
|
},
|
|
25
|
-
"keywords": [
|
|
28
|
+
"keywords": [
|
|
29
|
+
"varg",
|
|
30
|
+
"ai",
|
|
31
|
+
"video",
|
|
32
|
+
"image",
|
|
33
|
+
"speech",
|
|
34
|
+
"music",
|
|
35
|
+
"generation"
|
|
36
|
+
],
|
|
26
37
|
"author": "varg",
|
|
27
38
|
"license": "MIT",
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
28
42
|
"repository": {
|
|
29
43
|
"type": "git",
|
|
30
44
|
"url": "https://github.com/varghq/gateway.git",
|
|
@@ -32,6 +46,7 @@
|
|
|
32
46
|
},
|
|
33
47
|
"devDependencies": {
|
|
34
48
|
"@types/bun": "latest",
|
|
49
|
+
"@vargai/schemas": "0.1.0",
|
|
35
50
|
"typescript": "^5",
|
|
36
51
|
"vargai": "^0.4.0-alpha49"
|
|
37
52
|
},
|
|
@@ -40,7 +55,6 @@
|
|
|
40
55
|
},
|
|
41
56
|
"dependencies": {
|
|
42
57
|
"@ai-sdk/provider": "^3.0.7",
|
|
43
|
-
"@vargai/schemas": "workspace:*",
|
|
44
58
|
"ai": "^6.0.73",
|
|
45
59
|
"zod": "^4.3.6"
|
|
46
60
|
}
|