@felores/kie-ai-mcp-server 1.0.2 → 1.1.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/README.md +70 -18
- package/dist/index.js +134 -8
- package/dist/kie-ai-client.d.ts +2 -1
- package/dist/kie-ai-client.js +25 -10
- package/dist/types.d.ts +29 -3
- package/dist/types.js +12 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,8 @@ An MCP (Model Context Protocol) server that provides access to Kie.ai's AI APIs
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **Nano Banana Image Generation**: Text-to-image generation using Google's Gemini 2.5 Flash Image Preview
|
|
8
|
-
- **Nano Banana Image Editing**: Natural language image editing with up to
|
|
8
|
+
- **Nano Banana Image Editing**: Natural language image editing with up to 10 input images
|
|
9
|
+
- **Nano Banana Image Upscaling**: Upscale images 1-4x with optional face enhancement
|
|
9
10
|
- **Veo3 Video Generation**: Professional-quality video generation with text-to-video and image-to-video capabilities
|
|
10
11
|
- **1080p Video Upgrade**: Get high-definition versions of Veo3 videos
|
|
11
12
|
- **Task Management**: SQLite-based task tracking with status polling
|
|
@@ -22,14 +23,14 @@ An MCP (Model Context Protocol) server that provides access to Kie.ai's AI APIs
|
|
|
22
23
|
### From NPM
|
|
23
24
|
|
|
24
25
|
```bash
|
|
25
|
-
npm install -g @
|
|
26
|
+
npm install -g @felores/kie-ai-mcp-server
|
|
26
27
|
```
|
|
27
28
|
|
|
28
29
|
### From Source
|
|
29
30
|
|
|
30
31
|
```bash
|
|
31
32
|
# Clone the repository
|
|
32
|
-
git clone https://github.com/
|
|
33
|
+
git clone https://github.com/felores/kie-ai-mcp-server.git
|
|
33
34
|
cd kie-ai-mcp-server
|
|
34
35
|
|
|
35
36
|
# Install dependencies
|
|
@@ -75,7 +76,7 @@ Or if installed globally:
|
|
|
75
76
|
{
|
|
76
77
|
"kie-ai-mcp-server": {
|
|
77
78
|
"command": "npx",
|
|
78
|
-
"args": ["-y", "@
|
|
79
|
+
"args": ["-y", "@felores/kie-ai-mcp-server"],
|
|
79
80
|
"env": {
|
|
80
81
|
"KIE_AI_API_KEY": "your-api-key-here"
|
|
81
82
|
}
|
|
@@ -89,12 +90,16 @@ Or if installed globally:
|
|
|
89
90
|
Generate images using Nano Banana.
|
|
90
91
|
|
|
91
92
|
**Parameters:**
|
|
92
|
-
- `prompt` (string, required): Text description of the image to generate
|
|
93
|
+
- `prompt` (string, required): Text description of the image to generate (max 5000 chars)
|
|
94
|
+
- `output_format` (string, optional): "png" or "jpeg" (default: "png")
|
|
95
|
+
- `image_size` (string, optional): Aspect ratio - "1:1", "9:16", "16:9", "3:4", "4:3", "3:2", "2:3", "5:4", "4:5", "21:9", "auto" (default: "1:1")
|
|
93
96
|
|
|
94
97
|
**Example:**
|
|
95
98
|
```json
|
|
96
99
|
{
|
|
97
|
-
"prompt": "A surreal painting of a giant banana floating in space"
|
|
100
|
+
"prompt": "A surreal painting of a giant banana floating in space",
|
|
101
|
+
"output_format": "png",
|
|
102
|
+
"image_size": "16:9"
|
|
98
103
|
}
|
|
99
104
|
```
|
|
100
105
|
|
|
@@ -102,18 +107,39 @@ Generate images using Nano Banana.
|
|
|
102
107
|
Edit images using natural language prompts.
|
|
103
108
|
|
|
104
109
|
**Parameters:**
|
|
105
|
-
- `prompt` (string, required): Description of edits to make
|
|
106
|
-
- `image_urls` (array, required): URLs of images to edit (max
|
|
110
|
+
- `prompt` (string, required): Description of edits to make (max 5000 chars)
|
|
111
|
+
- `image_urls` (array, required): URLs of images to edit (max 10)
|
|
112
|
+
- `output_format` (string, optional): "png" or "jpeg" (default: "png")
|
|
113
|
+
- `image_size` (string, optional): Aspect ratio (default: "1:1")
|
|
107
114
|
|
|
108
115
|
**Example:**
|
|
109
116
|
```json
|
|
110
117
|
{
|
|
111
118
|
"prompt": "Add a rainbow arching over the mountains",
|
|
112
|
-
"image_urls": ["https://example.com/image.jpg"]
|
|
119
|
+
"image_urls": ["https://example.com/image.jpg"],
|
|
120
|
+
"output_format": "png",
|
|
121
|
+
"image_size": "16:9"
|
|
113
122
|
}
|
|
114
123
|
```
|
|
115
124
|
|
|
116
|
-
### 3. `
|
|
125
|
+
### 3. `upscale_nano_banana`
|
|
126
|
+
Upscale images with optional face enhancement.
|
|
127
|
+
|
|
128
|
+
**Parameters:**
|
|
129
|
+
- `image` (string, required): URL of image to upscale (max 10MB, jpeg/png/webp)
|
|
130
|
+
- `scale` (integer, optional): Upscale factor 1-4 (default: 2)
|
|
131
|
+
- `face_enhance` (boolean, optional): Enable GFPGAN face enhancement (default: false)
|
|
132
|
+
|
|
133
|
+
**Example:**
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"image": "https://example.com/image.jpg",
|
|
137
|
+
"scale": 4,
|
|
138
|
+
"face_enhance": true
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 4. `generate_veo3_video`
|
|
117
143
|
Generate videos using Veo3.
|
|
118
144
|
|
|
119
145
|
**Parameters:**
|
|
@@ -135,20 +161,20 @@ Generate videos using Veo3.
|
|
|
135
161
|
}
|
|
136
162
|
```
|
|
137
163
|
|
|
138
|
-
###
|
|
164
|
+
### 5. `get_task_status`
|
|
139
165
|
Check the status of a generation task.
|
|
140
166
|
|
|
141
167
|
**Parameters:**
|
|
142
168
|
- `task_id` (string, required): Task ID to check
|
|
143
169
|
|
|
144
|
-
###
|
|
170
|
+
### 6. `list_tasks`
|
|
145
171
|
List recent tasks with their status.
|
|
146
172
|
|
|
147
173
|
**Parameters:**
|
|
148
174
|
- `limit` (integer, optional): Max tasks to return (default: 20, max: 100)
|
|
149
175
|
- `status` (string, optional): Filter by status ("pending", "processing", "completed", "failed")
|
|
150
176
|
|
|
151
|
-
###
|
|
177
|
+
### 7. `get_veo3_1080p_video`
|
|
152
178
|
Get 1080P high-definition version of a Veo3 video.
|
|
153
179
|
|
|
154
180
|
**Parameters:**
|
|
@@ -164,10 +190,12 @@ The server interfaces with these Kie.ai API endpoints:
|
|
|
164
190
|
- **Veo3 Video Generation**: `POST /api/v1/veo/generate` ✅ **VALIDATED**
|
|
165
191
|
- **Veo3 Video Status**: `GET /api/v1/veo/record-info` ✅ **VALIDATED**
|
|
166
192
|
- **Veo3 1080p Upgrade**: `GET /api/v1/veo/get-1080p-video` ✅ **VALIDATED**
|
|
167
|
-
- **Nano Banana Generation**: `POST /api/v1/
|
|
168
|
-
- **Nano Banana
|
|
193
|
+
- **Nano Banana Generation**: `POST /api/v1/jobs/createTask`
|
|
194
|
+
- **Nano Banana Edit**: `POST /api/v1/jobs/createTask`
|
|
195
|
+
- **Nano Banana Upscale**: `POST /api/v1/jobs/createTask`
|
|
196
|
+
- **Nano Banana Status**: `GET /api/v1/jobs/recordInfo`
|
|
169
197
|
|
|
170
|
-
All endpoints
|
|
198
|
+
All endpoints follow official Kie.ai API documentation.
|
|
171
199
|
|
|
172
200
|
## Database Schema
|
|
173
201
|
|
|
@@ -285,7 +313,7 @@ See https://kie.ai/billing for detailed pricing.
|
|
|
285
313
|
## Support
|
|
286
314
|
|
|
287
315
|
For issues related to:
|
|
288
|
-
- **MCP Server**: Open an issue at https://github.com/
|
|
316
|
+
- **MCP Server**: Open an issue at https://github.com/felores/kie-ai-mcp-server/issues
|
|
289
317
|
- **Kie.ai API**: Contact support@kie.ai or check https://docs.kie.ai/
|
|
290
318
|
- **API Keys**: Visit https://kie.ai/api-key
|
|
291
319
|
|
|
@@ -303,7 +331,31 @@ MIT License - see LICENSE file for details.
|
|
|
303
331
|
|
|
304
332
|
## Changelog
|
|
305
333
|
|
|
306
|
-
### v1.
|
|
334
|
+
### v1.1.0 (2025-01-14)
|
|
335
|
+
|
|
336
|
+
**Breaking Changes:**
|
|
337
|
+
- Migrated from `/playground/*` to official `/jobs/*` API endpoints for all Nano Banana operations
|
|
338
|
+
- Updated status check endpoint from `/playground/recordInfo` to `/jobs/recordInfo`
|
|
339
|
+
|
|
340
|
+
**New Features:**
|
|
341
|
+
- Added `upscale_nano_banana` tool for image upscaling (1-4x) with optional GFPGAN face enhancement
|
|
342
|
+
- Added `output_format` parameter (png/jpeg) to `generate_nano_banana` and `edit_nano_banana`
|
|
343
|
+
- Added `image_size` parameter (11 aspect ratios) to `generate_nano_banana` and `edit_nano_banana`
|
|
344
|
+
|
|
345
|
+
**Improvements:**
|
|
346
|
+
- Increased prompt max length from 1,000 to 5,000 characters for Nano Banana tools
|
|
347
|
+
- Increased max input images from 5 to 10 for `edit_nano_banana`
|
|
348
|
+
- Enhanced `get_task_status` to properly parse `resultJson` and extract result URLs
|
|
349
|
+
- Improved task status mapping: `waiting` → `processing`, `success` → `completed`, `fail` → `failed`
|
|
350
|
+
- Task status now automatically updates local database with API responses
|
|
351
|
+
- Better error message handling from API responses
|
|
352
|
+
|
|
353
|
+
**Documentation:**
|
|
354
|
+
- Updated README with all new parameters and tools
|
|
355
|
+
- Corrected API endpoints to match official Kie.ai documentation
|
|
356
|
+
- Added comprehensive examples for all tools
|
|
357
|
+
|
|
358
|
+
### v1.0.0 (2024-12-XX)
|
|
307
359
|
- Initial release
|
|
308
360
|
- Nano Banana image generation and editing
|
|
309
361
|
- Veo3 video generation
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
|
4
4
|
import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import { KieAiClient } from './kie-ai-client.js';
|
|
6
6
|
import { TaskDatabase } from './database.js';
|
|
7
|
-
import { NanoBananaGenerateSchema, NanoBananaEditSchema, Veo3GenerateSchema } from './types.js';
|
|
7
|
+
import { NanoBananaGenerateSchema, NanoBananaEditSchema, NanoBananaUpscaleSchema, Veo3GenerateSchema } from './types.js';
|
|
8
8
|
class KieAiMcpServer {
|
|
9
9
|
server;
|
|
10
10
|
client;
|
|
@@ -12,7 +12,7 @@ class KieAiMcpServer {
|
|
|
12
12
|
constructor() {
|
|
13
13
|
this.server = new Server({
|
|
14
14
|
name: 'kie-ai-mcp-server',
|
|
15
|
-
version: '1.
|
|
15
|
+
version: '1.1.0',
|
|
16
16
|
});
|
|
17
17
|
// Initialize client with config from environment
|
|
18
18
|
const config = {
|
|
@@ -41,7 +41,19 @@ class KieAiMcpServer {
|
|
|
41
41
|
type: 'string',
|
|
42
42
|
description: 'Text prompt for image generation',
|
|
43
43
|
minLength: 1,
|
|
44
|
-
maxLength:
|
|
44
|
+
maxLength: 5000
|
|
45
|
+
},
|
|
46
|
+
output_format: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
enum: ['png', 'jpeg'],
|
|
49
|
+
description: 'Output format for the images',
|
|
50
|
+
default: 'png'
|
|
51
|
+
},
|
|
52
|
+
image_size: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
enum: ['1:1', '9:16', '16:9', '3:4', '4:3', '3:2', '2:3', '5:4', '4:5', '21:9', 'auto'],
|
|
55
|
+
description: 'Aspect ratio for the output image',
|
|
56
|
+
default: '1:1'
|
|
45
57
|
}
|
|
46
58
|
},
|
|
47
59
|
required: ['prompt']
|
|
@@ -57,19 +69,58 @@ class KieAiMcpServer {
|
|
|
57
69
|
type: 'string',
|
|
58
70
|
description: 'Text prompt for image editing',
|
|
59
71
|
minLength: 1,
|
|
60
|
-
maxLength:
|
|
72
|
+
maxLength: 5000
|
|
61
73
|
},
|
|
62
74
|
image_urls: {
|
|
63
75
|
type: 'array',
|
|
64
|
-
description: 'URLs of input images for editing (max
|
|
76
|
+
description: 'URLs of input images for editing (max 10)',
|
|
65
77
|
items: { type: 'string', format: 'uri' },
|
|
66
78
|
minItems: 1,
|
|
67
|
-
maxItems:
|
|
79
|
+
maxItems: 10
|
|
80
|
+
},
|
|
81
|
+
output_format: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
enum: ['png', 'jpeg'],
|
|
84
|
+
description: 'Output format for the images',
|
|
85
|
+
default: 'png'
|
|
86
|
+
},
|
|
87
|
+
image_size: {
|
|
88
|
+
type: 'string',
|
|
89
|
+
enum: ['1:1', '9:16', '16:9', '3:4', '4:3', '3:2', '2:3', '5:4', '4:5', '21:9', 'auto'],
|
|
90
|
+
description: 'Aspect ratio for the output image',
|
|
91
|
+
default: '1:1'
|
|
68
92
|
}
|
|
69
93
|
},
|
|
70
94
|
required: ['prompt', 'image_urls']
|
|
71
95
|
}
|
|
72
96
|
},
|
|
97
|
+
{
|
|
98
|
+
name: 'upscale_nano_banana',
|
|
99
|
+
description: 'Upscale images using Nano Banana Upscale with optional face enhancement',
|
|
100
|
+
inputSchema: {
|
|
101
|
+
type: 'object',
|
|
102
|
+
properties: {
|
|
103
|
+
image: {
|
|
104
|
+
type: 'string',
|
|
105
|
+
format: 'uri',
|
|
106
|
+
description: 'URL of the image to upscale (max 10MB, jpeg/png/webp)'
|
|
107
|
+
},
|
|
108
|
+
scale: {
|
|
109
|
+
type: 'integer',
|
|
110
|
+
description: 'Upscale factor (1-4)',
|
|
111
|
+
minimum: 1,
|
|
112
|
+
maximum: 4,
|
|
113
|
+
default: 2
|
|
114
|
+
},
|
|
115
|
+
face_enhance: {
|
|
116
|
+
type: 'boolean',
|
|
117
|
+
description: 'Enable GFPGAN face enhancement',
|
|
118
|
+
default: false
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
required: ['image']
|
|
122
|
+
}
|
|
123
|
+
},
|
|
73
124
|
{
|
|
74
125
|
name: 'generate_veo3_video',
|
|
75
126
|
description: 'Generate professional-quality videos using Google\'s Veo3 API',
|
|
@@ -184,6 +235,8 @@ class KieAiMcpServer {
|
|
|
184
235
|
return await this.handleGenerateNanoBanana(args);
|
|
185
236
|
case 'edit_nano_banana':
|
|
186
237
|
return await this.handleEditNanoBanana(args);
|
|
238
|
+
case 'upscale_nano_banana':
|
|
239
|
+
return await this.handleUpscaleNanoBanana(args);
|
|
187
240
|
case 'generate_veo3_video':
|
|
188
241
|
return await this.handleGenerateVeo3Video(args);
|
|
189
242
|
case 'get_task_status':
|
|
@@ -285,6 +338,46 @@ class KieAiMcpServer {
|
|
|
285
338
|
};
|
|
286
339
|
}
|
|
287
340
|
}
|
|
341
|
+
async handleUpscaleNanoBanana(args) {
|
|
342
|
+
const request = NanoBananaUpscaleSchema.parse(args);
|
|
343
|
+
try {
|
|
344
|
+
const response = await this.client.upscaleNanaBanana(request);
|
|
345
|
+
if (response.data?.taskId) {
|
|
346
|
+
await this.db.createTask({
|
|
347
|
+
task_id: response.data.taskId,
|
|
348
|
+
api_type: 'nano-banana-upscale',
|
|
349
|
+
status: 'pending',
|
|
350
|
+
result_url: response.data.imageUrl
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
return {
|
|
354
|
+
content: [
|
|
355
|
+
{
|
|
356
|
+
type: 'text',
|
|
357
|
+
text: JSON.stringify({
|
|
358
|
+
success: true,
|
|
359
|
+
response: response,
|
|
360
|
+
message: 'Nano Banana upscale initiated'
|
|
361
|
+
}, null, 2)
|
|
362
|
+
}
|
|
363
|
+
]
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
const message = error instanceof Error ? error.message : 'Upscale failed';
|
|
368
|
+
return {
|
|
369
|
+
content: [
|
|
370
|
+
{
|
|
371
|
+
type: 'text',
|
|
372
|
+
text: JSON.stringify({
|
|
373
|
+
success: false,
|
|
374
|
+
error: message
|
|
375
|
+
}, null, 2)
|
|
376
|
+
}
|
|
377
|
+
]
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
}
|
|
288
381
|
async handleGenerateVeo3Video(args) {
|
|
289
382
|
const request = Veo3GenerateSchema.parse(args);
|
|
290
383
|
try {
|
|
@@ -334,21 +427,54 @@ class KieAiMcpServer {
|
|
|
334
427
|
const localTask = await this.db.getTask(task_id);
|
|
335
428
|
// Always try to get updated status from API, passing api_type if available
|
|
336
429
|
let apiResponse = null;
|
|
430
|
+
let parsedResult = null;
|
|
337
431
|
try {
|
|
338
432
|
apiResponse = await this.client.getTaskStatus(task_id, localTask?.api_type);
|
|
433
|
+
// Update local database with API response
|
|
434
|
+
if (apiResponse?.data) {
|
|
435
|
+
const { state, resultJson, failCode, failMsg } = apiResponse.data;
|
|
436
|
+
// Map API state to our status
|
|
437
|
+
let status = 'pending';
|
|
438
|
+
if (state === 'success')
|
|
439
|
+
status = 'completed';
|
|
440
|
+
else if (state === 'fail')
|
|
441
|
+
status = 'failed';
|
|
442
|
+
else if (state === 'waiting')
|
|
443
|
+
status = 'processing';
|
|
444
|
+
// Parse resultJson if available
|
|
445
|
+
if (resultJson) {
|
|
446
|
+
try {
|
|
447
|
+
parsedResult = JSON.parse(resultJson);
|
|
448
|
+
}
|
|
449
|
+
catch (e) {
|
|
450
|
+
// Invalid JSON in resultJson
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
// Update database
|
|
454
|
+
await this.db.updateTask(task_id, {
|
|
455
|
+
status,
|
|
456
|
+
result_url: parsedResult?.resultUrls?.[0] || undefined,
|
|
457
|
+
error_message: failMsg || undefined
|
|
458
|
+
});
|
|
459
|
+
}
|
|
339
460
|
}
|
|
340
461
|
catch (error) {
|
|
341
462
|
// API call failed, use local data if available
|
|
342
463
|
}
|
|
464
|
+
// Fetch updated local task
|
|
465
|
+
const updatedTask = await this.db.getTask(task_id);
|
|
343
466
|
return {
|
|
344
467
|
content: [
|
|
345
468
|
{
|
|
346
469
|
type: 'text',
|
|
347
470
|
text: JSON.stringify({
|
|
348
471
|
success: true,
|
|
349
|
-
|
|
472
|
+
task_id: task_id,
|
|
473
|
+
status: apiResponse?.data?.state || updatedTask?.status,
|
|
474
|
+
result_urls: parsedResult?.resultUrls || (updatedTask?.result_url ? [updatedTask.result_url] : []),
|
|
475
|
+
error: apiResponse?.data?.failMsg || updatedTask?.error_message,
|
|
350
476
|
api_response: apiResponse,
|
|
351
|
-
message:
|
|
477
|
+
message: updatedTask ? 'Task found' : 'Task not found in local database'
|
|
352
478
|
}, null, 2)
|
|
353
479
|
}
|
|
354
480
|
]
|
package/dist/kie-ai-client.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { KieAiConfig, KieAiResponse, NanoBananaGenerateRequest, NanaBananaEditRequest, Veo3GenerateRequest, ImageResponse, TaskResponse } from './types.js';
|
|
1
|
+
import { KieAiConfig, KieAiResponse, NanoBananaGenerateRequest, NanaBananaEditRequest, NanoBananaUpscaleRequest, Veo3GenerateRequest, ImageResponse, TaskResponse } from './types.js';
|
|
2
2
|
export declare class KieAiClient {
|
|
3
3
|
private config;
|
|
4
4
|
constructor(config: KieAiConfig);
|
|
5
5
|
private makeRequest;
|
|
6
6
|
generateNanoBanana(request: NanoBananaGenerateRequest): Promise<KieAiResponse<ImageResponse>>;
|
|
7
7
|
editNanoBanana(request: NanaBananaEditRequest): Promise<KieAiResponse<ImageResponse>>;
|
|
8
|
+
upscaleNanaBanana(request: NanoBananaUpscaleRequest): Promise<KieAiResponse<ImageResponse>>;
|
|
8
9
|
generateVeo3Video(request: Veo3GenerateRequest): Promise<KieAiResponse<TaskResponse>>;
|
|
9
10
|
getTaskStatus(taskId: string, apiType?: string): Promise<KieAiResponse<any>>;
|
|
10
11
|
getVeo1080pVideo(taskId: string, index?: number): Promise<KieAiResponse<any>>;
|
package/dist/kie-ai-client.js
CHANGED
|
@@ -33,23 +33,38 @@ export class KieAiClient {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
async generateNanoBanana(request) {
|
|
36
|
-
const
|
|
36
|
+
const jobRequest = {
|
|
37
37
|
model: 'google/nano-banana',
|
|
38
38
|
input: {
|
|
39
|
-
prompt: request.prompt
|
|
39
|
+
prompt: request.prompt,
|
|
40
|
+
...(request.output_format && { output_format: request.output_format }),
|
|
41
|
+
...(request.image_size && { image_size: request.image_size })
|
|
40
42
|
}
|
|
41
43
|
};
|
|
42
|
-
return this.makeRequest('/
|
|
44
|
+
return this.makeRequest('/jobs/createTask', 'POST', jobRequest);
|
|
43
45
|
}
|
|
44
46
|
async editNanoBanana(request) {
|
|
45
|
-
const
|
|
47
|
+
const jobRequest = {
|
|
46
48
|
model: 'google/nano-banana-edit',
|
|
47
49
|
input: {
|
|
48
50
|
prompt: request.prompt,
|
|
49
|
-
image_urls: request.image_urls
|
|
51
|
+
image_urls: request.image_urls,
|
|
52
|
+
...(request.output_format && { output_format: request.output_format }),
|
|
53
|
+
...(request.image_size && { image_size: request.image_size })
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return this.makeRequest('/jobs/createTask', 'POST', jobRequest);
|
|
57
|
+
}
|
|
58
|
+
async upscaleNanaBanana(request) {
|
|
59
|
+
const jobRequest = {
|
|
60
|
+
model: 'nano-banana-upscale',
|
|
61
|
+
input: {
|
|
62
|
+
image: request.image,
|
|
63
|
+
...(request.scale !== undefined && { scale: request.scale }),
|
|
64
|
+
...(request.face_enhance !== undefined && { face_enhance: request.face_enhance })
|
|
50
65
|
}
|
|
51
66
|
};
|
|
52
|
-
return this.makeRequest('/
|
|
67
|
+
return this.makeRequest('/jobs/createTask', 'POST', jobRequest);
|
|
53
68
|
}
|
|
54
69
|
async generateVeo3Video(request) {
|
|
55
70
|
return this.makeRequest('/veo/generate', 'POST', request);
|
|
@@ -59,12 +74,12 @@ export class KieAiClient {
|
|
|
59
74
|
if (apiType === 'veo3') {
|
|
60
75
|
return this.makeRequest(`/veo/record-info?taskId=${taskId}`, 'GET');
|
|
61
76
|
}
|
|
62
|
-
else if (apiType === 'nano-banana' || apiType === 'nano-banana-edit') {
|
|
63
|
-
return this.makeRequest(`/
|
|
77
|
+
else if (apiType === 'nano-banana' || apiType === 'nano-banana-edit' || apiType === 'nano-banana-upscale') {
|
|
78
|
+
return this.makeRequest(`/jobs/recordInfo?taskId=${taskId}`, 'GET');
|
|
64
79
|
}
|
|
65
|
-
// Fallback: try
|
|
80
|
+
// Fallback: try jobs first, then veo (for tasks not in database)
|
|
66
81
|
try {
|
|
67
|
-
return await this.makeRequest(`/
|
|
82
|
+
return await this.makeRequest(`/jobs/recordInfo?taskId=${taskId}`, 'GET');
|
|
68
83
|
}
|
|
69
84
|
catch (error) {
|
|
70
85
|
try {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,20 +1,45 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const NanoBananaGenerateSchema: z.ZodObject<{
|
|
3
3
|
prompt: z.ZodString;
|
|
4
|
+
output_format: z.ZodOptional<z.ZodDefault<z.ZodEnum<["png", "jpeg"]>>>;
|
|
5
|
+
image_size: z.ZodOptional<z.ZodDefault<z.ZodEnum<["1:1", "9:16", "16:9", "3:4", "4:3", "3:2", "2:3", "5:4", "4:5", "21:9", "auto"]>>>;
|
|
4
6
|
}, "strip", z.ZodTypeAny, {
|
|
5
7
|
prompt: string;
|
|
8
|
+
output_format?: "png" | "jpeg" | undefined;
|
|
9
|
+
image_size?: "1:1" | "9:16" | "16:9" | "3:4" | "4:3" | "3:2" | "2:3" | "5:4" | "4:5" | "21:9" | "auto" | undefined;
|
|
6
10
|
}, {
|
|
7
11
|
prompt: string;
|
|
12
|
+
output_format?: "png" | "jpeg" | undefined;
|
|
13
|
+
image_size?: "1:1" | "9:16" | "16:9" | "3:4" | "4:3" | "3:2" | "2:3" | "5:4" | "4:5" | "21:9" | "auto" | undefined;
|
|
8
14
|
}>;
|
|
9
15
|
export declare const NanoBananaEditSchema: z.ZodObject<{
|
|
10
16
|
prompt: z.ZodString;
|
|
11
17
|
image_urls: z.ZodArray<z.ZodString, "many">;
|
|
18
|
+
output_format: z.ZodOptional<z.ZodDefault<z.ZodEnum<["png", "jpeg"]>>>;
|
|
19
|
+
image_size: z.ZodOptional<z.ZodDefault<z.ZodEnum<["1:1", "9:16", "16:9", "3:4", "4:3", "3:2", "2:3", "5:4", "4:5", "21:9", "auto"]>>>;
|
|
12
20
|
}, "strip", z.ZodTypeAny, {
|
|
13
21
|
prompt: string;
|
|
14
22
|
image_urls: string[];
|
|
23
|
+
output_format?: "png" | "jpeg" | undefined;
|
|
24
|
+
image_size?: "1:1" | "9:16" | "16:9" | "3:4" | "4:3" | "3:2" | "2:3" | "5:4" | "4:5" | "21:9" | "auto" | undefined;
|
|
15
25
|
}, {
|
|
16
26
|
prompt: string;
|
|
17
27
|
image_urls: string[];
|
|
28
|
+
output_format?: "png" | "jpeg" | undefined;
|
|
29
|
+
image_size?: "1:1" | "9:16" | "16:9" | "3:4" | "4:3" | "3:2" | "2:3" | "5:4" | "4:5" | "21:9" | "auto" | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const NanoBananaUpscaleSchema: z.ZodObject<{
|
|
32
|
+
image: z.ZodString;
|
|
33
|
+
scale: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
34
|
+
face_enhance: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
image: string;
|
|
37
|
+
scale?: number | undefined;
|
|
38
|
+
face_enhance?: boolean | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
image: string;
|
|
41
|
+
scale?: number | undefined;
|
|
42
|
+
face_enhance?: boolean | undefined;
|
|
18
43
|
}>;
|
|
19
44
|
export declare const Veo3GenerateSchema: z.ZodObject<{
|
|
20
45
|
prompt: z.ZodString;
|
|
@@ -28,7 +53,7 @@ export declare const Veo3GenerateSchema: z.ZodObject<{
|
|
|
28
53
|
}, "strip", z.ZodTypeAny, {
|
|
29
54
|
prompt: string;
|
|
30
55
|
model: "veo3" | "veo3_fast";
|
|
31
|
-
aspectRatio: "16
|
|
56
|
+
aspectRatio: "9:16" | "16:9";
|
|
32
57
|
enableFallback: boolean;
|
|
33
58
|
imageUrls?: string[] | undefined;
|
|
34
59
|
watermark?: string | undefined;
|
|
@@ -39,13 +64,14 @@ export declare const Veo3GenerateSchema: z.ZodObject<{
|
|
|
39
64
|
imageUrls?: string[] | undefined;
|
|
40
65
|
model?: "veo3" | "veo3_fast" | undefined;
|
|
41
66
|
watermark?: string | undefined;
|
|
42
|
-
aspectRatio?: "16
|
|
67
|
+
aspectRatio?: "9:16" | "16:9" | undefined;
|
|
43
68
|
seeds?: number | undefined;
|
|
44
69
|
callBackUrl?: string | undefined;
|
|
45
70
|
enableFallback?: boolean | undefined;
|
|
46
71
|
}>;
|
|
47
72
|
export type NanoBananaGenerateRequest = z.infer<typeof NanoBananaGenerateSchema>;
|
|
48
73
|
export type NanaBananaEditRequest = z.infer<typeof NanoBananaEditSchema>;
|
|
74
|
+
export type NanoBananaUpscaleRequest = z.infer<typeof NanoBananaUpscaleSchema>;
|
|
49
75
|
export type Veo3GenerateRequest = z.infer<typeof Veo3GenerateSchema>;
|
|
50
76
|
export interface KieAiResponse<T = any> {
|
|
51
77
|
code: number;
|
|
@@ -62,7 +88,7 @@ export interface TaskResponse {
|
|
|
62
88
|
export interface TaskRecord {
|
|
63
89
|
id?: number;
|
|
64
90
|
task_id: string;
|
|
65
|
-
api_type: 'nano-banana' | 'nano-banana-edit' | 'veo3';
|
|
91
|
+
api_type: 'nano-banana' | 'nano-banana-edit' | 'nano-banana-upscale' | 'veo3';
|
|
66
92
|
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
67
93
|
created_at: string;
|
|
68
94
|
updated_at: string;
|
package/dist/types.js
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
// Zod schemas for request validation
|
|
3
3
|
export const NanoBananaGenerateSchema = z.object({
|
|
4
|
-
prompt: z.string().min(1).max(
|
|
4
|
+
prompt: z.string().min(1).max(5000),
|
|
5
|
+
output_format: z.enum(['png', 'jpeg']).default('png').optional(),
|
|
6
|
+
image_size: z.enum(['1:1', '9:16', '16:9', '3:4', '4:3', '3:2', '2:3', '5:4', '4:5', '21:9', 'auto']).default('1:1').optional()
|
|
5
7
|
});
|
|
6
8
|
export const NanoBananaEditSchema = z.object({
|
|
7
|
-
prompt: z.string().min(1).max(
|
|
8
|
-
image_urls: z.array(z.string().url()).min(1).max(
|
|
9
|
+
prompt: z.string().min(1).max(5000),
|
|
10
|
+
image_urls: z.array(z.string().url()).min(1).max(10),
|
|
11
|
+
output_format: z.enum(['png', 'jpeg']).default('png').optional(),
|
|
12
|
+
image_size: z.enum(['1:1', '9:16', '16:9', '3:4', '4:3', '3:2', '2:3', '5:4', '4:5', '21:9', 'auto']).default('1:1').optional()
|
|
13
|
+
});
|
|
14
|
+
export const NanoBananaUpscaleSchema = z.object({
|
|
15
|
+
image: z.string().url(),
|
|
16
|
+
scale: z.number().int().min(1).max(4).default(2).optional(),
|
|
17
|
+
face_enhance: z.boolean().default(false).optional()
|
|
9
18
|
});
|
|
10
19
|
export const Veo3GenerateSchema = z.object({
|
|
11
20
|
prompt: z.string().min(1).max(2000),
|