muapi-js 1.0.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/LICENSE +21 -0
- package/README.md +219 -0
- package/package.json +28 -0
- package/src/account.js +17 -0
- package/src/audio.js +19 -0
- package/src/client.js +84 -0
- package/src/errors.js +9 -0
- package/src/images.js +63 -0
- package/src/index.js +33 -0
- package/src/model.js +92 -0
- package/src/modelRegistry.js +200 -0
- package/src/predictions.js +29 -0
- package/src/uploads.js +31 -0
- package/src/videos.js +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SamurAIGPT
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
<<<<<<< HEAD
|
|
2
|
+
# MuAPI JavaScript SDK
|
|
3
|
+
|
|
4
|
+
Official JavaScript SDK for MuAPI.
|
|
5
|
+
|
|
6
|
+
Generate images, videos, audio, edit media, upload files, track predictions, and access MuAPI models directly from Node.js applications.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install muapi-js
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Authentication
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
import { MuAPI } from "muapi-js";
|
|
22
|
+
|
|
23
|
+
const client = new MuAPI("YOUR_API_KEY");
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# Quick Start
|
|
29
|
+
|
|
30
|
+
## Generate an Image
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
import { MuAPI } from "muapi-js";
|
|
34
|
+
|
|
35
|
+
const client = new MuAPI("YOUR_API_KEY");
|
|
36
|
+
|
|
37
|
+
const result = await client.images.generate({
|
|
38
|
+
prompt: "A futuristic city at sunset",
|
|
39
|
+
model: "flux-dev",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
console.log(result);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Edit an Image
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
const result = await client.images.edit({
|
|
51
|
+
prompt: "Turn this image into anime style",
|
|
52
|
+
image: "https://example.com/image.jpg",
|
|
53
|
+
model: "flux-kontext-dev",
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
console.log(result);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Generate a Video
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
const result = await client.videos.generate({
|
|
65
|
+
prompt: "A cinematic drone shot over mountains",
|
|
66
|
+
model: "kling-master",
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
console.log(result);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Image to Video
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
const result = await client.videos.fromImage({
|
|
78
|
+
prompt: "The subject smiles and waves",
|
|
79
|
+
image: "https://example.com/image.jpg",
|
|
80
|
+
model: "kling-master",
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
console.log(result);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Generate Audio
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
const result = await client.audio.fromText({
|
|
92
|
+
prompt: "Relaxing ocean waves",
|
|
93
|
+
duration: 10,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
console.log(result);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Upload Files
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
const upload = await client.uploads.upload(
|
|
105
|
+
"./image.jpg"
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
console.log(upload);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Track Predictions
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
const image = await client.images.generate({
|
|
117
|
+
prompt: "A futuristic city",
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const result = await client.predictions.wait(
|
|
121
|
+
image.request_id || image.id
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
console.log(result);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Models API
|
|
130
|
+
|
|
131
|
+
### List Categories
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
console.log(
|
|
135
|
+
client.models.categories()
|
|
136
|
+
);
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Get Model Details
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
console.log(
|
|
143
|
+
client.models.get("flux-dev")
|
|
144
|
+
);
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Account API
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
const balance =
|
|
153
|
+
await client.account.balance();
|
|
154
|
+
|
|
155
|
+
console.log(balance);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Error Handling
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
import {
|
|
164
|
+
MuAPI,
|
|
165
|
+
MuAPIError
|
|
166
|
+
} from "muapi-js";
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
await client.images.generate({
|
|
170
|
+
prompt: "test"
|
|
171
|
+
});
|
|
172
|
+
} catch (error) {
|
|
173
|
+
if (error instanceof MuAPIError) {
|
|
174
|
+
console.log(error.status);
|
|
175
|
+
console.log(error.message);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Examples
|
|
183
|
+
|
|
184
|
+
```text
|
|
185
|
+
examples/
|
|
186
|
+
├── image-generate.js
|
|
187
|
+
├── image-edit.js
|
|
188
|
+
├── video-generate.js
|
|
189
|
+
├── image-to-video.js
|
|
190
|
+
├── audio-generate.js
|
|
191
|
+
├── upload-file.js
|
|
192
|
+
├── prediction-test.js
|
|
193
|
+
├── models-list.js
|
|
194
|
+
└── account-balance.js
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Features
|
|
200
|
+
|
|
201
|
+
* Image Generation
|
|
202
|
+
* Image Editing
|
|
203
|
+
* Video Generation
|
|
204
|
+
* Image-to-Video
|
|
205
|
+
* Audio Generation
|
|
206
|
+
* File Uploads
|
|
207
|
+
* Prediction Polling
|
|
208
|
+
* Model Discovery
|
|
209
|
+
* Account Management
|
|
210
|
+
* Custom Error Handling
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## License
|
|
215
|
+
|
|
216
|
+
MIT
|
|
217
|
+
=======
|
|
218
|
+
# muapi-javascript
|
|
219
|
+
Javascript sdk for Muapi
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "muapi-js",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Official JavaScript SDK for MuAPI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"muapi",
|
|
17
|
+
"ai",
|
|
18
|
+
"image-generation",
|
|
19
|
+
"video-generation",
|
|
20
|
+
"audio-generation"
|
|
21
|
+
],
|
|
22
|
+
"author": "MuAPI",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"axios": "^1.10.0",
|
|
26
|
+
"form-data": "^4.0.4"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/account.js
ADDED
package/src/audio.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class AudioAPI {
|
|
2
|
+
constructor(client) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
async fromText({
|
|
7
|
+
prompt,
|
|
8
|
+
duration = 10,
|
|
9
|
+
model = "mmaudio"
|
|
10
|
+
}) {
|
|
11
|
+
return this.client.post(
|
|
12
|
+
"mmaudio-v2/text-to-audio",
|
|
13
|
+
{
|
|
14
|
+
prompt,
|
|
15
|
+
duration
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/client.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { MuAPIError } from "./errors.js";
|
|
3
|
+
|
|
4
|
+
const BASE_URL = "https://api.muapi.ai/api/v1";
|
|
5
|
+
|
|
6
|
+
export class MuAPIClient {
|
|
7
|
+
constructor(apiKey) {
|
|
8
|
+
if (!apiKey) {
|
|
9
|
+
throw new MuAPIError(
|
|
10
|
+
"API key is required. Pass your MuAPI API key when creating the client."
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
this.apiKey = apiKey;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
headers() {
|
|
18
|
+
return {
|
|
19
|
+
"x-api-key": this.apiKey,
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async post(endpoint, payload) {
|
|
25
|
+
try {
|
|
26
|
+
const response = await axios.post(
|
|
27
|
+
`${BASE_URL}/${endpoint}`,
|
|
28
|
+
payload,
|
|
29
|
+
{
|
|
30
|
+
headers: this.headers(),
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return response.data;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
throw new MuAPIError(
|
|
37
|
+
error.response?.data?.detail ||
|
|
38
|
+
error.message,
|
|
39
|
+
error.response?.status,
|
|
40
|
+
error.response?.data
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async get(endpoint) {
|
|
46
|
+
try {
|
|
47
|
+
const response = await axios.get(
|
|
48
|
+
`${BASE_URL}/${endpoint}`,
|
|
49
|
+
{
|
|
50
|
+
headers: this.headers(),
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return response.data;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
throw new MuAPIError(
|
|
57
|
+
error.response?.data?.detail ||
|
|
58
|
+
error.message,
|
|
59
|
+
error.response?.status,
|
|
60
|
+
error.response?.data
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async getPrediction(id) {
|
|
66
|
+
try {
|
|
67
|
+
const response = await axios.get(
|
|
68
|
+
`${BASE_URL}/predictions/${id}/result`,
|
|
69
|
+
{
|
|
70
|
+
headers: this.headers(),
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return response.data;
|
|
75
|
+
} catch (error) {
|
|
76
|
+
throw new MuAPIError(
|
|
77
|
+
error.response?.data?.detail ||
|
|
78
|
+
error.message,
|
|
79
|
+
error.response?.status,
|
|
80
|
+
error.response?.data
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
package/src/errors.js
ADDED
package/src/images.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
T2I_MODELS,
|
|
3
|
+
I2I_MODELS
|
|
4
|
+
} from "./modelRegistry.js";
|
|
5
|
+
|
|
6
|
+
export class ImagesAPI {
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async generate({
|
|
12
|
+
prompt,
|
|
13
|
+
model = "flux-dev",
|
|
14
|
+
numImages = 1,
|
|
15
|
+
width = 1024,
|
|
16
|
+
height = 1024,
|
|
17
|
+
}) {
|
|
18
|
+
const endpoint = T2I_MODELS[model];
|
|
19
|
+
|
|
20
|
+
if (!endpoint) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`Unknown model: ${model}`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return this.client.post(endpoint, {
|
|
27
|
+
prompt,
|
|
28
|
+
num_images: numImages,
|
|
29
|
+
width,
|
|
30
|
+
height,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async edit({
|
|
35
|
+
prompt,
|
|
36
|
+
image,
|
|
37
|
+
model = "flux-kontext-dev",
|
|
38
|
+
aspectRatio = "1:1",
|
|
39
|
+
numImages = 1,
|
|
40
|
+
}) {
|
|
41
|
+
const endpoint = I2I_MODELS[model];
|
|
42
|
+
|
|
43
|
+
if (!endpoint) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`Unknown model: ${model}`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return this.client.post(endpoint, {
|
|
50
|
+
prompt,
|
|
51
|
+
image_url: image,
|
|
52
|
+
aspect_ratio: aspectRatio,
|
|
53
|
+
num_images: numImages,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
models() {
|
|
58
|
+
return {
|
|
59
|
+
textToImage: Object.keys(T2I_MODELS),
|
|
60
|
+
imageToImage: Object.keys(I2I_MODELS),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MuAPIClient } from "./client.js";
|
|
2
|
+
import { ImagesAPI } from "./images.js";
|
|
3
|
+
import { VideosAPI } from "./videos.js";
|
|
4
|
+
import { AudioAPI } from "./audio.js";
|
|
5
|
+
import { PredictionsAPI } from "./predictions.js";
|
|
6
|
+
import { UploadsAPI } from "./uploads.js";
|
|
7
|
+
import { ModelsAPI } from "./model.js";
|
|
8
|
+
import { AccountAPI } from "./account.js";
|
|
9
|
+
|
|
10
|
+
export class MuAPI {
|
|
11
|
+
constructor(apiKey) {
|
|
12
|
+
const client = new MuAPIClient(apiKey);
|
|
13
|
+
|
|
14
|
+
this.images = new ImagesAPI(client);
|
|
15
|
+
this.videos = new VideosAPI(client);
|
|
16
|
+
this.audio = new AudioAPI(client);
|
|
17
|
+
this.predictions = new PredictionsAPI(client);
|
|
18
|
+
this.uploads = new UploadsAPI(client);
|
|
19
|
+
this.models = new ModelsAPI();
|
|
20
|
+
this.account = new AccountAPI(client);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
ImagesAPI,
|
|
26
|
+
VideosAPI,
|
|
27
|
+
AudioAPI,
|
|
28
|
+
PredictionsAPI,
|
|
29
|
+
UploadsAPI,
|
|
30
|
+
ModelsAPI,
|
|
31
|
+
AccountAPI
|
|
32
|
+
};
|
|
33
|
+
export { MuAPIError } from "./errors.js";
|
package/src/model.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
T2I_MODELS,
|
|
3
|
+
T2V_MODELS,
|
|
4
|
+
I2V_MODELS
|
|
5
|
+
} from "./modelRegistry.js";
|
|
6
|
+
|
|
7
|
+
export class ModelsAPI {
|
|
8
|
+
list(category = "all") {
|
|
9
|
+
switch (category) {
|
|
10
|
+
case "image":
|
|
11
|
+
return T2I_MODELS;
|
|
12
|
+
|
|
13
|
+
case "text-to-video":
|
|
14
|
+
return T2V_MODELS;
|
|
15
|
+
|
|
16
|
+
case "image-to-video":
|
|
17
|
+
return I2V_MODELS;
|
|
18
|
+
|
|
19
|
+
case "video":
|
|
20
|
+
return {
|
|
21
|
+
textToVideo: T2V_MODELS,
|
|
22
|
+
imageToVideo: I2V_MODELS,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
case "all":
|
|
26
|
+
default:
|
|
27
|
+
return {
|
|
28
|
+
image: T2I_MODELS,
|
|
29
|
+
textToVideo: T2V_MODELS,
|
|
30
|
+
imageToVideo: I2V_MODELS,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
categories() {
|
|
36
|
+
return [
|
|
37
|
+
"image",
|
|
38
|
+
"text-to-video",
|
|
39
|
+
"image-to-video",
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get(modelName) {
|
|
44
|
+
if (modelName in T2I_MODELS) {
|
|
45
|
+
return {
|
|
46
|
+
name: modelName,
|
|
47
|
+
category: "image",
|
|
48
|
+
endpoint: T2I_MODELS[modelName],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (modelName in T2V_MODELS) {
|
|
53
|
+
return {
|
|
54
|
+
name: modelName,
|
|
55
|
+
category: "text-to-video",
|
|
56
|
+
endpoint: T2V_MODELS[modelName],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (modelName in I2V_MODELS) {
|
|
61
|
+
return {
|
|
62
|
+
name: modelName,
|
|
63
|
+
category: "image-to-video",
|
|
64
|
+
endpoint: I2V_MODELS[modelName],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
throw new Error(
|
|
69
|
+
`Model '${modelName}' not found`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
exists(modelName) {
|
|
74
|
+
return (
|
|
75
|
+
modelName in T2I_MODELS ||
|
|
76
|
+
modelName in T2V_MODELS ||
|
|
77
|
+
modelName in I2V_MODELS
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
imageModels() {
|
|
82
|
+
return Object.keys(T2I_MODELS);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
textToVideoModels() {
|
|
86
|
+
return Object.keys(T2V_MODELS);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
imageToVideoModels() {
|
|
90
|
+
return Object.keys(I2V_MODELS);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
export const T2I_MODELS = {
|
|
2
|
+
// Flux
|
|
3
|
+
"flux-dev": "flux-dev-image",
|
|
4
|
+
"flux-schnell": "flux-schnell-image",
|
|
5
|
+
"flux-krea": "flux-krea-dev",
|
|
6
|
+
"flux-kontext-dev": "flux-kontext-dev-t2i",
|
|
7
|
+
"flux-kontext-pro": "flux-kontext-pro-t2i",
|
|
8
|
+
"flux-kontext-max": "flux-kontext-max-t2i",
|
|
9
|
+
"flux-2-dev": "flux-2-dev",
|
|
10
|
+
"flux-2-pro": "flux-2-pro",
|
|
11
|
+
"flux-2-flex": "flux-2-flex",
|
|
12
|
+
|
|
13
|
+
// HiDream
|
|
14
|
+
"hidream-fast": "hidream_i1_fast_image",
|
|
15
|
+
"hidream-dev": "hidream_i1_dev_image",
|
|
16
|
+
"hidream-full": "hidream_i1_full_image",
|
|
17
|
+
|
|
18
|
+
// Wan
|
|
19
|
+
"wan2.1": "wan2.1-text-to-image",
|
|
20
|
+
"wan2.5": "wan2.5-text-to-image",
|
|
21
|
+
"wan2.6": "wan2.6-text-to-image",
|
|
22
|
+
"wan2.7": "wan2.7-text-to-image",
|
|
23
|
+
|
|
24
|
+
// GPT
|
|
25
|
+
"gpt4o": "gpt4o-text-to-image",
|
|
26
|
+
"gpt-image": "gpt-image-1.5",
|
|
27
|
+
"gpt-image-2": "gpt-image-2-text-to-image",
|
|
28
|
+
|
|
29
|
+
// Google
|
|
30
|
+
"imagen4": "google-imagen4",
|
|
31
|
+
"imagen4-fast": "google-imagen4-fast",
|
|
32
|
+
"imagen4-ultra": "google-imagen4-ultra",
|
|
33
|
+
|
|
34
|
+
// Midjourney
|
|
35
|
+
"midjourney": "midjourney-v7-text-to-image",
|
|
36
|
+
"midjourney-v7": "midjourney-v7",
|
|
37
|
+
"midjourney-v8": "midjourney-v8",
|
|
38
|
+
"midjourney-niji": "midjourney-niji",
|
|
39
|
+
|
|
40
|
+
// Seedream
|
|
41
|
+
"seedream": "bytedance-seedream-v4.5",
|
|
42
|
+
"seedream-v3": "bytedance-seedream-image",
|
|
43
|
+
"seedream-v4": "bytedance-seedream-v4",
|
|
44
|
+
"seedream-v4.5": "bytedance-seedream-v4.5",
|
|
45
|
+
"seedream-5": "seedream-5.0",
|
|
46
|
+
|
|
47
|
+
// Qwen
|
|
48
|
+
"qwen": "qwen-image",
|
|
49
|
+
"qwen-2": "qwen-image-2.0",
|
|
50
|
+
"qwen-2-pro": "qwen-image-2.0-pro",
|
|
51
|
+
|
|
52
|
+
// Nano Banana
|
|
53
|
+
"nano-banana": "nano-banana",
|
|
54
|
+
"nano-banana-pro": "nano-banana-pro",
|
|
55
|
+
"nano-banana-2": "nano-banana-2",
|
|
56
|
+
|
|
57
|
+
// Kling
|
|
58
|
+
"kling-o1": "kling-o1-text-to-image",
|
|
59
|
+
"kling-o3": "kling-o3-image",
|
|
60
|
+
|
|
61
|
+
// Others
|
|
62
|
+
"hunyuan": "hunyuan-image-2.1",
|
|
63
|
+
"hunyuan-3": "hunyuan-image-3.0",
|
|
64
|
+
"ideogram": "ideogram-v3-t2i",
|
|
65
|
+
"reve": "reve-text-to-image",
|
|
66
|
+
"sdxl": "sdxl-image",
|
|
67
|
+
"grok": "grok-imagine-text-to-image"
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const I2I_MODELS = {
|
|
71
|
+
"flux-kontext-dev": "flux-kontext-dev-i2i",
|
|
72
|
+
"flux-kontext-pro": "flux-kontext-pro-i2i",
|
|
73
|
+
"flux-kontext-max": "flux-kontext-max-i2i",
|
|
74
|
+
|
|
75
|
+
"gpt4o": "gpt4o-image-to-image",
|
|
76
|
+
"gpt4o-edit": "gpt4o-edit",
|
|
77
|
+
"gpt-image-edit": "gpt-image-1.5-edit",
|
|
78
|
+
"gpt-image-2-edit": "gpt-image-2-image-to-image",
|
|
79
|
+
|
|
80
|
+
"seededit": "bytedance-seededit-image",
|
|
81
|
+
"seedream-edit": "bytedance-seedream-edit-v4",
|
|
82
|
+
"seedream-v4.5-edit": "bytedance-seedream-v4.5-edit",
|
|
83
|
+
|
|
84
|
+
"midjourney": "midjourney-v7-image-to-image",
|
|
85
|
+
"midjourney-style": "midjourney-v7-style-reference",
|
|
86
|
+
|
|
87
|
+
"qwen": "qwen-image-edit",
|
|
88
|
+
"qwen-plus": "qwen-image-edit-plus",
|
|
89
|
+
"qwen-2-edit": "qwen-image-2.0-edit",
|
|
90
|
+
|
|
91
|
+
"nano-banana-edit": "nano-banana-edit",
|
|
92
|
+
"nano-banana-effects": "nano-banana-effects",
|
|
93
|
+
|
|
94
|
+
"reve": "reve-image-edit",
|
|
95
|
+
|
|
96
|
+
"wan2.5-edit": "wan2.5-image-edit",
|
|
97
|
+
"wan2.6-edit": "wan2.6-image-edit",
|
|
98
|
+
"wan2.7-edit": "wan2.7-image-edit"
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const T2V_MODELS = {
|
|
102
|
+
// Veo
|
|
103
|
+
"veo3": "veo3-text-to-video",
|
|
104
|
+
"veo3-fast": "veo3-fast-text-to-video",
|
|
105
|
+
"veo3.1": "veo3.1-text-to-video",
|
|
106
|
+
"veo4": "veo-4-text-to-video",
|
|
107
|
+
|
|
108
|
+
// Kling
|
|
109
|
+
"kling-master": "kling-v2.1-master-t2v",
|
|
110
|
+
"kling-v2.5-pro": "kling-v2.5-turbo-pro-t2v",
|
|
111
|
+
"kling-v2.6-pro": "kling-v2.6-pro-t2v",
|
|
112
|
+
"kling-v3-pro": "kling-v3.0-pro-text-to-video",
|
|
113
|
+
|
|
114
|
+
// Wan
|
|
115
|
+
"wan2.1": "wan2.1-text-to-video",
|
|
116
|
+
"wan2.2": "wan2.2-text-to-video",
|
|
117
|
+
"wan2.5": "wan2.5-text-to-video",
|
|
118
|
+
"wan2.6": "wan2.6-text-to-video",
|
|
119
|
+
"wan2.7": "wan2.7-text-to-video",
|
|
120
|
+
|
|
121
|
+
// Seedance
|
|
122
|
+
"seedance-pro": "seedance-pro-t2v",
|
|
123
|
+
"seedance-pro-fast": "seedance-pro-t2v-fast",
|
|
124
|
+
|
|
125
|
+
// Others
|
|
126
|
+
"runway": "runway-text-to-video",
|
|
127
|
+
"pixverse": "pixverse-v4.5-t2v",
|
|
128
|
+
"pixverse-v5": "pixverse-v5-t2v",
|
|
129
|
+
"pixverse-v6": "pixverse-v6-t2v",
|
|
130
|
+
|
|
131
|
+
"vidu": "vidu-v2.0-t2v",
|
|
132
|
+
"vidu-q2-pro": "vidu-q2-pro-text-to-video",
|
|
133
|
+
"vidu-q3-pro": "vidu-q3-pro-text-to-video",
|
|
134
|
+
|
|
135
|
+
"sora": "openai-sora",
|
|
136
|
+
"sora-2": "openai-sora-2-text-to-video",
|
|
137
|
+
|
|
138
|
+
"hunyuan": "hunyuan-text-to-video"
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export const I2V_MODELS = {
|
|
142
|
+
// Kling
|
|
143
|
+
"kling-std": "kling-v2.1-standard-i2v",
|
|
144
|
+
"kling-pro": "kling-v2.1-pro-i2v",
|
|
145
|
+
"kling-master": "kling-v2.1-master-i2v",
|
|
146
|
+
"kling-v2.5-pro": "kling-v2.5-turbo-pro-i2v",
|
|
147
|
+
|
|
148
|
+
// Veo
|
|
149
|
+
"veo3": "veo3-image-to-video",
|
|
150
|
+
"veo3.1": "veo3.1-image-to-video",
|
|
151
|
+
"veo4": "veo-4-image-to-video",
|
|
152
|
+
|
|
153
|
+
// Wan
|
|
154
|
+
"wan2.1": "wan2.1-image-to-video",
|
|
155
|
+
"wan2.5": "wan2.5-image-to-video",
|
|
156
|
+
"wan2.6": "wan2.6-image-to-video",
|
|
157
|
+
"wan2.7": "wan2.7-image-to-video",
|
|
158
|
+
|
|
159
|
+
// Seedance
|
|
160
|
+
"seedance-pro": "seedance-pro-i2v",
|
|
161
|
+
"seedance-v2": "seedance-v2.0-i2v",
|
|
162
|
+
"seedance-2": "seedance-2-image-to-video",
|
|
163
|
+
|
|
164
|
+
// Others
|
|
165
|
+
"runway": "runway-image-to-video",
|
|
166
|
+
|
|
167
|
+
"pixverse-v4.5": "pixverse-v4.5-i2v",
|
|
168
|
+
"pixverse-v5": "pixverse-v5-i2v",
|
|
169
|
+
"pixverse-v6": "pixverse-v6-i2v",
|
|
170
|
+
|
|
171
|
+
"vidu": "vidu-v2.0-i2v",
|
|
172
|
+
"vidu-q2-pro": "vidu-q2-pro-image-to-video",
|
|
173
|
+
"vidu-q3-pro": "vidu-q3-pro-image-to-video",
|
|
174
|
+
|
|
175
|
+
"midjourney": "midjourney-v7-image-to-video",
|
|
176
|
+
|
|
177
|
+
"sora-2": "openai-sora-2-image-to-video",
|
|
178
|
+
|
|
179
|
+
"hunyuan": "hunyuan-image-to-video"
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export const LIST_INPUT_I2V = new Set([
|
|
183
|
+
"wan2.1",
|
|
184
|
+
"wan2.5",
|
|
185
|
+
"wan2.6",
|
|
186
|
+
"wan2.7",
|
|
187
|
+
|
|
188
|
+
"seedance-pro",
|
|
189
|
+
"seedance-v2",
|
|
190
|
+
"seedance-2",
|
|
191
|
+
|
|
192
|
+
"vidu",
|
|
193
|
+
"vidu-q2-pro",
|
|
194
|
+
|
|
195
|
+
"pixverse-v4.5",
|
|
196
|
+
"pixverse-v5",
|
|
197
|
+
"pixverse-v6",
|
|
198
|
+
|
|
199
|
+
"sora-2"
|
|
200
|
+
]);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class PredictionsAPI {
|
|
2
|
+
constructor(client) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
async get(id) {
|
|
7
|
+
return this.client.getPrediction(id);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async wait(id, interval = 3000) {
|
|
11
|
+
while (true) {
|
|
12
|
+
const result = await this.get(id);
|
|
13
|
+
|
|
14
|
+
if (result.status === "completed") {
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (result.status === "failed") {
|
|
19
|
+
throw new Error(
|
|
20
|
+
result.error || "Generation failed"
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
await new Promise(resolve =>
|
|
25
|
+
setTimeout(resolve, interval)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/uploads.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import FormData from "form-data";
|
|
4
|
+
|
|
5
|
+
export class UploadsAPI {
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async upload(filePath) {
|
|
11
|
+
const form = new FormData();
|
|
12
|
+
|
|
13
|
+
form.append(
|
|
14
|
+
"file",
|
|
15
|
+
fs.createReadStream(filePath)
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const response = await axios.post(
|
|
19
|
+
"https://api.muapi.ai/api/v1/upload_file",
|
|
20
|
+
form,
|
|
21
|
+
{
|
|
22
|
+
headers: {
|
|
23
|
+
...form.getHeaders(),
|
|
24
|
+
"x-api-key": this.client.apiKey,
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
return response.data;
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/videos.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
T2V_MODELS,
|
|
3
|
+
I2V_MODELS,
|
|
4
|
+
LIST_INPUT_I2V
|
|
5
|
+
} from "./modelRegistry.js";
|
|
6
|
+
|
|
7
|
+
export class VideosAPI {
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async generate({
|
|
13
|
+
prompt,
|
|
14
|
+
model = "kling-master",
|
|
15
|
+
duration = 5,
|
|
16
|
+
aspectRatio = "16:9",
|
|
17
|
+
}) {
|
|
18
|
+
const endpoint = T2V_MODELS[model];
|
|
19
|
+
|
|
20
|
+
if (!endpoint) {
|
|
21
|
+
throw new Error(`Unknown model: ${model}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return this.client.post(endpoint, {
|
|
25
|
+
prompt,
|
|
26
|
+
duration,
|
|
27
|
+
aspect_ratio: aspectRatio,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async fromImage({
|
|
32
|
+
prompt,
|
|
33
|
+
image,
|
|
34
|
+
model = "kling-std",
|
|
35
|
+
duration = 5,
|
|
36
|
+
aspectRatio = "16:9",
|
|
37
|
+
}) {
|
|
38
|
+
const endpoint = I2V_MODELS[model];
|
|
39
|
+
|
|
40
|
+
if (!endpoint) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Unknown model: ${model}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const payload = {
|
|
47
|
+
prompt,
|
|
48
|
+
duration,
|
|
49
|
+
aspect_ratio: aspectRatio,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
if (LIST_INPUT_I2V.has(model)) {
|
|
53
|
+
payload.images_list = [image];
|
|
54
|
+
} else {
|
|
55
|
+
payload.image_url = image;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return this.client.post(
|
|
59
|
+
endpoint,
|
|
60
|
+
payload
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|