@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.
Files changed (2) hide show
  1. package/README.md +47 -113
  2. package/package.json +18 -4
package/README.md CHANGED
@@ -1,170 +1,104 @@
1
1
  # @vargai/gateway
2
2
 
3
- typescript client for varg gateway api unified proxy over fal, elevenlabs, replicate, higgsfield.
3
+ vercel AI SDK provider for varg gateway — generate video, image, speech, and music through a unified API.
4
4
 
5
- ## installation
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 { VargClient } from "@vargai/gateway";
14
+ import { generateVideo } from "vargai/ai";
15
+ import { createVarg } from "@vargai/gateway";
15
16
 
16
- const client = new VargClient({
17
- apiKey: "varg_xxx",
18
- baseUrl: "https://api.varg.ai/v1", // optional, defaults to this
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
- // generate video
27
- const videoJob = await client.createVideo({
28
- model: "kling-v2.6",
29
- prompt: "cat jumping over fence",
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
- // poll until complete
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
- ## api
45
-
46
- ### `createVideo(params)`
31
+ ## models
47
32
 
48
- generate video. returns job reference.
33
+ ### video
49
34
 
50
35
  ```typescript
51
- const job = await client.createVideo({
52
- model: "kling-v2.6",
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
- aspect_ratio: "16:9",
56
- files: [{ url: "https://s3.varg.ai/u/..." }], // optional reference images
42
+ aspectRatio: "16:9",
57
43
  });
58
44
  ```
59
45
 
60
- ### `createImage(params)`
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
- generate image. returns job reference.
48
+ ### image
63
49
 
64
50
  ```typescript
65
- const job = await client.createImage({
66
- model: "flux-schnell",
51
+ import { generateImage } from "vargai/ai";
52
+
53
+ const result = await generateImage({
54
+ model: varg.imageModel("flux-schnell"),
67
55
  prompt: "cyberpunk cityscape",
68
- aspect_ratio: "16:9",
56
+ aspectRatio: "16:9",
69
57
  });
70
58
  ```
71
59
 
72
- ### `createSpeech(params)`
60
+ available: `flux-pro`, `flux-dev`, `flux-schnell`, `recraft-v3`, `soul`
73
61
 
74
- text-to-speech. returns job reference.
62
+ ### speech
75
63
 
76
64
  ```typescript
77
- const job = await client.createSpeech({
78
- model: "eleven_turbo_v2_5",
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
- ### `createMusic(params)`
74
+ available: `eleven_turbo_v2`, `eleven_multilingual_v2`, `turbo`
85
75
 
86
- generate music. returns job reference.
76
+ ### music
87
77
 
88
78
  ```typescript
89
- const job = await client.createMusic({
90
- model: "elevenlabs",
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
- ### `uploadFile(file, mediaType)`
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
- get job status and output.
90
+ bring your own provider keys to skip metered billing:
109
91
 
110
92
  ```typescript
111
- const job = await client.getJob("job_a1b2c3");
112
- if (job.status === "completed") {
113
- console.log(job.output?.url);
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.0",
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": ["dist", "README.md"],
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": ["varg", "ai", "video", "image", "speech", "music", "generation"],
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
  }