@felores/kie-ai-mcp-server 1.7.2 → 1.7.4

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 CHANGED
@@ -23,6 +23,7 @@ Access the world's best AI models through a single, developer-friendly API. Gene
23
23
  - **ElevenLabs**: Studio-quality text-to-speech and sound effects
24
24
  - **ByteDance Seedance**: High-quality video with text-to-video and image-to-video
25
25
  - **ByteDance Seedream V4**: Advanced image generation and editing with unified interface
26
+ - **Qwen**: Powerful image generation and editing with acceleration options
26
27
 
27
28
  ### 💰 **Affordable Pricing**
28
29
  Pay-as-you-go credit system means you only pay for what you use. Good for startups and enterprises looking to reduce AI costs.
@@ -580,7 +581,79 @@ Multiple image editing:
580
581
 
581
582
  **Note**: The `callBackUrl` is optional and will use the `KIE_AI_CALLBACK_URL` environment variable if not provided. Image generation typically takes 30-120 seconds depending on resolution and complexity.
582
583
 
583
- ### 14. `runway_aleph_video`
584
+ ### 14. `qwen_image`
585
+ Generate and edit images using Qwen models (unified tool for both text-to-image and image editing).
586
+
587
+ **Parameters:**
588
+ - `prompt` (string, required): Text prompt for image generation or editing
589
+ - `image_url` (string, optional): URL of image to edit (if not provided, uses text-to-image)
590
+ - `image_size` (string, optional): Image size (default: "square_hd")
591
+ - Options: `square`, `square_hd`, `portrait_4_3`, `portrait_16_9`, `landscape_4_3`, `landscape_16_9`
592
+ - `num_inference_steps` (integer, optional): Number of inference steps (default: 30 for text-to-image, 25 for edit)
593
+ - Text-to-image: 2-250, Edit: 2-49
594
+ - `guidance_scale` (number, optional): CFG scale (default: 2.5 for text-to-image, 4 for edit)
595
+ - Range: 0-20
596
+ - `enable_safety_checker` (boolean, optional): Enable safety checker (default: true)
597
+ - `output_format` (string, optional): Output format (default: "png")
598
+ - Options: `png`, `jpeg`
599
+ - `negative_prompt` (string, optional): Negative prompt (max 500 chars, default: " ")
600
+ - `acceleration` (string, optional): Acceleration level (default: "none")
601
+ - Options: `none`, `regular`, `high`
602
+ - `num_images` (string, optional): Number of images (edit mode only)
603
+ - Options: `1`, `2`, `3`, `4`
604
+ - `sync_mode` (boolean, optional): Sync mode (edit mode only, default: false)
605
+ - `seed` (number, optional): Random seed for reproducible results
606
+ - `callBackUrl` (string, optional): URL for task completion notifications
607
+
608
+ **Examples:**
609
+
610
+ Text-to-image generation:
611
+ ```json
612
+ {
613
+ "prompt": "A beautiful landscape with mountains and a lake at sunset",
614
+ "image_size": "landscape_16_9",
615
+ "num_inference_steps": 30,
616
+ "guidance_scale": 2.5,
617
+ "output_format": "png",
618
+ "seed": 42
619
+ }
620
+ ```
621
+
622
+ Image editing:
623
+ ```json
624
+ {
625
+ "prompt": "Change the day scene to night with stars and moonlight",
626
+ "image_url": "https://example.com/day-landscape.jpg",
627
+ "image_size": "landscape_16_9",
628
+ "num_inference_steps": 25,
629
+ "guidance_scale": 4,
630
+ "num_images": "2",
631
+ "output_format": "png"
632
+ }
633
+ ```
634
+
635
+ High-acceleration generation:
636
+ ```json
637
+ {
638
+ "prompt": "A futuristic city with flying cars",
639
+ "image_size": "square_hd",
640
+ "acceleration": "high",
641
+ "enable_safety_checker": true,
642
+ "negative_prompt": "blurry, low quality"
643
+ }
644
+ ```
645
+
646
+ **Key Features:**
647
+ - **Unified Interface**: Single tool for both text-to-image and image editing
648
+ - **Smart Mode Detection**: Automatically detects mode based on presence of `image_url`
649
+ - **Flexible Sizing**: Support for multiple aspect ratios and resolutions
650
+ - **Acceleration Options**: Speed up generation with acceleration levels
651
+ - **Batch Generation**: Generate multiple images in edit mode
652
+ - **Reproducible Results**: Seed control for consistent output
653
+
654
+ **Note**: The `callBackUrl` is optional and will use the `KIE_AI_CALLBACK_URL` environment variable if not provided. Image generation typically takes 10-60 seconds depending on settings and acceleration level.
655
+
656
+ ### 15. `runway_aleph_video`
584
657
  Transform videos using Runway Aleph video-to-video generation with AI-powered editing.
585
658
 
586
659
  **Parameters:**
@@ -636,7 +709,125 @@ Vertical video for social media:
636
709
 
637
710
  **Note**: The `callBackUrl` is optional and will use the `KIE_AI_CALLBACK_URL` environment variable if not provided. Video-to-video transformation typically takes 3-8 minutes depending on complexity and length.
638
711
 
639
- ### 14. `wan_video`
712
+ ### 16. `midjourney_generate`
713
+ Generate images and videos using Midjourney AI models (unified tool for text-to-image, image-to-image, style reference, omni reference, and video generation).
714
+
715
+ **Parameters:**
716
+ - `prompt` (string, required): Text prompt describing the desired image or video (max 2000 chars)
717
+ - `taskType` (string, optional): Task type for generation mode (auto-detected if not provided)
718
+ - Options: `mj_txt2img`, `mj_img2img`, `mj_style_reference`, `mj_omni_reference`, `mj_video`, `mj_video_hd`
719
+ - `fileUrl` (string, optional): Single image URL for image-to-image or video generation (legacy - use fileUrls instead)
720
+ - `fileUrls` (array, optional): Array of image URLs for image-to-image or video generation (recommended, max 10)
721
+ - `speed` (string, optional): Generation speed (not required for video/omni tasks)
722
+ - Options: `relaxed`, `fast`, `turbo`
723
+ - `aspectRatio` (string, optional): Output aspect ratio (default: "16:9")
724
+ - Options: `1:2`, `9:16`, `2:3`, `3:4`, `5:6`, `6:5`, `4:3`, `3:2`, `1:1`, `16:9`, `2:1`
725
+ - `version` (string, optional): Midjourney model version (default: "7")
726
+ - Options: `7`, `6.1`, `6`, `5.2`, `5.1`, `niji6`
727
+ - `variety` (integer, optional): Controls diversity of generated results (0-100, increment by 5)
728
+ - `stylization` (integer, optional): Artistic style intensity (0-1000, suggested multiple of 50)
729
+ - `weirdness` (integer, optional): Creativity and uniqueness level (0-3000, suggested multiple of 100)
730
+ - `ow` (integer, optional): Omni intensity parameter for omni reference tasks (1-1000)
731
+ - `waterMark` (string, optional): Watermark identifier (max 100 chars)
732
+ - `enableTranslation` (boolean, optional): Auto-translate non-English prompts to English (default: false)
733
+ - `videoBatchSize` (string, optional): Number of videos to generate (video mode only, default: "1")
734
+ - Options: `1`, `2`, `4`
735
+ - `motion` (string, optional): Motion level for video generation (required for video mode, default: "high")
736
+ - Options: `high`, `low`
737
+ - `high_definition_video` (boolean, optional): Use HD video generation instead of standard definition (default: false)
738
+ - `callBackUrl` (string, optional): URL for task completion notifications
739
+
740
+ **Examples:**
741
+
742
+ Text-to-image generation:
743
+ ```json
744
+ {
745
+ "prompt": "A majestic dragon perched atop a crystal mountain at sunset, digital art style",
746
+ "aspectRatio": "16:9",
747
+ "version": "7",
748
+ "speed": "fast",
749
+ "stylization": 500
750
+ }
751
+ ```
752
+
753
+ Image-to-image generation:
754
+ ```json
755
+ {
756
+ "prompt": "Transform this portrait into a cyberpunk style with neon lights",
757
+ "fileUrls": ["https://example.com/portrait.jpg"],
758
+ "aspectRatio": "1:1",
759
+ "version": "7",
760
+ "variety": 10
761
+ }
762
+ ```
763
+
764
+ Standard definition video generation (default):
765
+ ```json
766
+ {
767
+ "prompt": "Add gentle movement and atmospheric effects",
768
+ "fileUrls": ["https://example.com/landscape.jpg"],
769
+ "motion": "high",
770
+ "videoBatchSize": "1",
771
+ "aspectRatio": "16:9"
772
+ }
773
+ ```
774
+
775
+ High definition video generation (explicit):
776
+ ```json
777
+ {
778
+ "prompt": "Create cinematic video with dramatic motion",
779
+ "fileUrls": ["https://example.com/cityscape.jpg"],
780
+ "motion": "high",
781
+ "high_definition_video": true,
782
+ "videoBatchSize": "2",
783
+ "aspectRatio": "16:9"
784
+ }
785
+ ```
786
+
787
+ Omni reference generation:
788
+ ```json
789
+ {
790
+ "prompt": "Place this character in a fantasy forest setting",
791
+ "fileUrls": ["https://example.com/character.jpg"],
792
+ "ow": 500,
793
+ "aspectRatio": "16:9",
794
+ "version": "7"
795
+ }
796
+ ```
797
+
798
+ Style reference generation:
799
+ ```json
800
+ {
801
+ "prompt": "Apply this artistic style to a new landscape",
802
+ "fileUrls": ["https://example.com/artistic-style.jpg"],
803
+ "taskType": "mj_style_reference",
804
+ "aspectRatio": "16:9",
805
+ "stylization": 700
806
+ }
807
+ ```
808
+
809
+ **Key Features:**
810
+ - **Unified Interface**: Single tool for all Midjourney generation modes
811
+ - **Smart Mode Detection**: Automatically detects task type based on parameters
812
+ - **Video Default**: Uses standard definition video by default, HD only when explicitly requested
813
+ - **Multiple Aspect Ratios**: Support for vertical, horizontal, square, and ultra-wide formats
814
+ - **Style Control**: Fine-tune artistic style with stylization, variety, and weirdness parameters
815
+ - **Speed Options**: Choose generation speed based on urgency (relaxed/fast/turbo)
816
+ - **Model Versions**: Access different Midjourney models including niji for anime/illustration
817
+ - **Reference Modes**: Advanced omni and style reference for character and style transfer
818
+ - **Batch Generation**: Generate multiple videos in a single request
819
+
820
+ **Smart Detection Logic:**
821
+ - If `high_definition_video` is true → `mj_video_hd`
822
+ - If `motion` or `videoBatchSize` present → `mj_video` (standard) or `mj_video_hd` (explicit)
823
+ - If `ow` present → `mj_omni_reference`
824
+ - If `taskType` is `mj_style_reference` → `mj_style_reference`
825
+ - If `fileUrl`/`fileUrls` present → `mj_img2img`
826
+ - Otherwise → `mj_txt2img`
827
+
828
+ **Note**: The `callBackUrl` is optional and will use the `KIE_AI_CALLBACK_URL` environment variable if not provided. Generation times vary: text-to-image (1-3 minutes), image-to-image (2-4 minutes), video generation (3-8 minutes), reference modes (2-5 minutes).
829
+
830
+ ### 17. `wan_video`
640
831
  Generate videos using Alibaba Wan 2.5 models (unified tool for both text-to-video and image-to-video).
641
832
 
642
833
  **Parameters:**
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } f
5
5
  import { KieAiClient } from './kie-ai-client.js';
6
6
  import { TaskDatabase } from './database.js';
7
7
  import { z } from 'zod';
8
- import { NanoBananaGenerateSchema, NanoBananaEditSchema, NanoBananaUpscaleSchema, Veo3GenerateSchema, SunoGenerateSchema, ElevenLabsTTSSchema, ElevenLabsSoundEffectsSchema, ByteDanceSeedanceVideoSchema, ByteDanceSeedreamImageSchema, RunwayAlephVideoSchema, WanVideoSchema } from './types.js';
8
+ import { NanoBananaGenerateSchema, NanoBananaEditSchema, NanoBananaUpscaleSchema, Veo3GenerateSchema, SunoGenerateSchema, ElevenLabsTTSSchema, ElevenLabsSoundEffectsSchema, ByteDanceSeedanceVideoSchema, ByteDanceSeedreamImageSchema, QwenImageSchema, RunwayAlephVideoSchema, WanVideoSchema, MidjourneyGenerateSchema } from './types.js';
9
9
  class KieAiMcpServer {
10
10
  server;
11
11
  client;
@@ -13,7 +13,7 @@ class KieAiMcpServer {
13
13
  constructor() {
14
14
  this.server = new Server({
15
15
  name: 'kie-ai-mcp-server',
16
- version: '1.7.2',
16
+ version: '1.7.4',
17
17
  });
18
18
  // Initialize client with config from environment
19
19
  const config = {
@@ -606,6 +606,196 @@ class KieAiMcpServer {
606
606
  required: ['prompt']
607
607
  }
608
608
  },
609
+ {
610
+ name: 'qwen_image',
611
+ description: 'Generate and edit images using Qwen models (unified tool for both text-to-image and image editing)',
612
+ inputSchema: {
613
+ type: 'object',
614
+ properties: {
615
+ prompt: {
616
+ type: 'string',
617
+ description: 'Text prompt for image generation or editing',
618
+ minLength: 1
619
+ },
620
+ image_url: {
621
+ type: 'string',
622
+ description: 'URL of image to edit (optional - if not provided, uses text-to-image)',
623
+ format: 'uri'
624
+ },
625
+ image_size: {
626
+ type: 'string',
627
+ description: 'Image size',
628
+ enum: ['square', 'square_hd', 'portrait_4_3', 'portrait_16_9', 'landscape_4_3', 'landscape_16_9'],
629
+ default: 'square_hd'
630
+ },
631
+ num_inference_steps: {
632
+ type: 'integer',
633
+ description: 'Number of inference steps (2-250 for text-to-image, 2-49 for edit)',
634
+ minimum: 2,
635
+ maximum: 250,
636
+ default: 30
637
+ },
638
+ guidance_scale: {
639
+ type: 'number',
640
+ description: 'CFG scale (0-20, default: 2.5 for text-to-image, 4 for edit)',
641
+ minimum: 0,
642
+ maximum: 20,
643
+ default: 2.5
644
+ },
645
+ enable_safety_checker: {
646
+ type: 'boolean',
647
+ description: 'Enable safety checker',
648
+ default: true
649
+ },
650
+ output_format: {
651
+ type: 'string',
652
+ description: 'Output format',
653
+ enum: ['png', 'jpeg'],
654
+ default: 'png'
655
+ },
656
+ negative_prompt: {
657
+ type: 'string',
658
+ description: 'Negative prompt (max 500 characters)',
659
+ maxLength: 500,
660
+ default: ' '
661
+ },
662
+ acceleration: {
663
+ type: 'string',
664
+ description: 'Acceleration level',
665
+ enum: ['none', 'regular', 'high'],
666
+ default: 'none'
667
+ },
668
+ num_images: {
669
+ type: 'string',
670
+ description: 'Number of images (1-4, edit mode only)',
671
+ enum: ['1', '2', '3', '4']
672
+ },
673
+ sync_mode: {
674
+ type: 'boolean',
675
+ description: 'Sync mode (edit mode only)',
676
+ default: false
677
+ },
678
+ seed: {
679
+ type: 'number',
680
+ description: 'Random seed for reproducible results'
681
+ },
682
+ callBackUrl: {
683
+ type: 'string',
684
+ description: 'Optional: URL for task completion notifications (uses KIE_AI_CALLBACK_URL env var if not provided)',
685
+ format: 'uri'
686
+ }
687
+ },
688
+ required: ['prompt']
689
+ }
690
+ },
691
+ {
692
+ name: 'midjourney_generate',
693
+ description: 'Generate images and videos using Midjourney AI models (unified tool for text-to-image, image-to-image, style reference, omni reference, and video generation)',
694
+ inputSchema: {
695
+ type: 'object',
696
+ properties: {
697
+ prompt: {
698
+ type: 'string',
699
+ description: 'Text prompt describing the desired image or video (max 2000 characters)',
700
+ minLength: 1,
701
+ maxLength: 2000
702
+ },
703
+ taskType: {
704
+ type: 'string',
705
+ description: 'Task type for generation mode (auto-detected if not provided)',
706
+ enum: ['mj_txt2img', 'mj_img2img', 'mj_style_reference', 'mj_omni_reference', 'mj_video', 'mj_video_hd']
707
+ },
708
+ fileUrl: {
709
+ type: 'string',
710
+ description: 'Single image URL for image-to-image or video generation (legacy - use fileUrls instead)',
711
+ format: 'uri'
712
+ },
713
+ fileUrls: {
714
+ type: 'array',
715
+ description: 'Array of image URLs for image-to-image or video generation (recommended)',
716
+ items: {
717
+ type: 'string',
718
+ format: 'uri'
719
+ },
720
+ maxItems: 10
721
+ },
722
+ speed: {
723
+ type: 'string',
724
+ description: 'Generation speed (not required for video/omni tasks)',
725
+ enum: ['relaxed', 'fast', 'turbo']
726
+ },
727
+ aspectRatio: {
728
+ type: 'string',
729
+ description: 'Output aspect ratio',
730
+ enum: ['1:2', '9:16', '2:3', '3:4', '5:6', '6:5', '4:3', '3:2', '1:1', '16:9', '2:1'],
731
+ default: '16:9'
732
+ },
733
+ version: {
734
+ type: 'string',
735
+ description: 'Midjourney model version',
736
+ enum: ['7', '6.1', '6', '5.2', '5.1', 'niji6'],
737
+ default: '7'
738
+ },
739
+ variety: {
740
+ type: 'integer',
741
+ description: 'Controls diversity of generated results (0-100, increment by 5)',
742
+ minimum: 0,
743
+ maximum: 100
744
+ },
745
+ stylization: {
746
+ type: 'integer',
747
+ description: 'Artistic style intensity (0-1000, suggested multiple of 50)',
748
+ minimum: 0,
749
+ maximum: 1000
750
+ },
751
+ weirdness: {
752
+ type: 'integer',
753
+ description: 'Creativity and uniqueness level (0-3000, suggested multiple of 100)',
754
+ minimum: 0,
755
+ maximum: 3000
756
+ },
757
+ ow: {
758
+ type: 'integer',
759
+ description: 'Omni intensity parameter for omni reference tasks (1-1000)',
760
+ minimum: 1,
761
+ maximum: 1000
762
+ },
763
+ waterMark: {
764
+ type: 'string',
765
+ description: 'Watermark identifier',
766
+ maxLength: 100
767
+ },
768
+ enableTranslation: {
769
+ type: 'boolean',
770
+ description: 'Auto-translate non-English prompts to English',
771
+ default: false
772
+ },
773
+ videoBatchSize: {
774
+ type: 'string',
775
+ description: 'Number of videos to generate (video mode only)',
776
+ enum: ['1', '2', '4'],
777
+ default: '1'
778
+ },
779
+ motion: {
780
+ type: 'string',
781
+ description: 'Motion level for video generation (required for video mode)',
782
+ enum: ['high', 'low'],
783
+ default: 'high'
784
+ },
785
+ high_definition_video: {
786
+ type: 'boolean',
787
+ description: 'Use high definition video generation instead of standard definition',
788
+ default: false
789
+ },
790
+ callBackUrl: {
791
+ type: 'string',
792
+ description: 'Optional: URL for task completion notifications (uses KIE_AI_CALLBACK_URL env var if not provided)',
793
+ format: 'uri'
794
+ }
795
+ },
796
+ required: ['prompt']
797
+ }
798
+ },
609
799
  {
610
800
  name: 'runway_aleph_video',
611
801
  description: 'Transform videos using Runway Aleph video-to-video generation with AI-powered editing',
@@ -750,6 +940,10 @@ class KieAiMcpServer {
750
940
  return await this.handleByteDanceSeedanceVideo(args);
751
941
  case 'bytedance_seedream_image':
752
942
  return await this.handleByteDanceSeedreamImage(args);
943
+ case 'qwen_image':
944
+ return await this.handleQwenImage(args);
945
+ case 'midjourney_generate':
946
+ return await this.handleMidjourneyGenerate(args);
753
947
  case 'runway_aleph_video':
754
948
  return await this.handleRunwayAlephVideo(args);
755
949
  case 'wan_video':
@@ -1515,6 +1709,225 @@ class KieAiMcpServer {
1515
1709
  });
1516
1710
  }
1517
1711
  }
1712
+ async handleQwenImage(args) {
1713
+ try {
1714
+ const request = QwenImageSchema.parse(args);
1715
+ // Use environment variable as fallback if callBackUrl not provided
1716
+ if (!request.callBackUrl && process.env.KIE_AI_CALLBACK_URL) {
1717
+ request.callBackUrl = process.env.KIE_AI_CALLBACK_URL;
1718
+ }
1719
+ const response = await this.client.generateQwenImage(request);
1720
+ if (response.code === 200 && response.data?.taskId) {
1721
+ // Determine mode for user feedback
1722
+ const isEdit = !!request.image_url;
1723
+ const mode = isEdit ? 'Image Editing' : 'Text-to-Image';
1724
+ // Store task in database
1725
+ await this.db.createTask({
1726
+ task_id: response.data.taskId,
1727
+ api_type: 'qwen-image',
1728
+ status: 'pending'
1729
+ });
1730
+ return {
1731
+ content: [
1732
+ {
1733
+ type: 'text',
1734
+ text: JSON.stringify({
1735
+ success: true,
1736
+ task_id: response.data.taskId,
1737
+ message: `Qwen ${mode} task created successfully`,
1738
+ parameters: {
1739
+ mode: mode,
1740
+ prompt: request.prompt.substring(0, 100) + (request.prompt.length > 100 ? '...' : ''),
1741
+ image_size: request.image_size || 'square_hd',
1742
+ num_inference_steps: request.num_inference_steps || (isEdit ? 25 : 30),
1743
+ guidance_scale: request.guidance_scale || (isEdit ? 4 : 2.5),
1744
+ enable_safety_checker: request.enable_safety_checker !== false,
1745
+ output_format: request.output_format || 'png',
1746
+ negative_prompt: request.negative_prompt || (isEdit ? 'blurry, ugly' : ' '),
1747
+ acceleration: request.acceleration || 'none',
1748
+ seed: request.seed,
1749
+ ...(isEdit && {
1750
+ image_url: request.image_url,
1751
+ num_images: request.num_images,
1752
+ sync_mode: request.sync_mode
1753
+ })
1754
+ },
1755
+ next_steps: [
1756
+ `Use get_task_status with task_id: ${response.data.taskId} to check progress`,
1757
+ 'Generated images will be available when status is "completed"'
1758
+ ],
1759
+ usage_examples: [
1760
+ `get_task_status: {"task_id": "${response.data.taskId}"}`,
1761
+ `list_tasks: {"limit": 10}`
1762
+ ]
1763
+ }, null, 2)
1764
+ }
1765
+ ]
1766
+ };
1767
+ }
1768
+ else {
1769
+ throw new Error(response.msg || 'Failed to create Qwen image task');
1770
+ }
1771
+ }
1772
+ catch (error) {
1773
+ if (error instanceof z.ZodError) {
1774
+ return this.formatError('qwen_image', error, {
1775
+ prompt: 'Required: Text prompt for image generation or editing',
1776
+ image_url: 'Optional: URL of image to edit (required for edit mode)',
1777
+ image_size: 'Optional: Image size (square, square_hd, portrait_4_3, portrait_16_9, landscape_4_3, landscape_16_9)',
1778
+ num_inference_steps: 'Optional: Number of inference steps (2-250 for text-to-image, 2-49 for edit)',
1779
+ guidance_scale: 'Optional: CFG scale (0-20, default: 2.5 for text-to-image, 4 for edit)',
1780
+ enable_safety_checker: 'Optional: Enable safety checker (default: true)',
1781
+ output_format: 'Optional: Output format (png/jpeg, default: png)',
1782
+ negative_prompt: 'Optional: Negative prompt (max 500 chars)',
1783
+ acceleration: 'Optional: Acceleration level (none/regular/high, default: none)',
1784
+ num_images: 'Optional: Number of images (1-4, edit mode only)',
1785
+ sync_mode: 'Optional: Sync mode (edit mode only)',
1786
+ seed: 'Optional: Random seed for reproducible results',
1787
+ callBackUrl: 'Optional: URL for task completion notifications (uses KIE_AI_CALLBACK_URL env var if not provided)'
1788
+ });
1789
+ }
1790
+ return this.formatError('qwen_image', error, {
1791
+ prompt: 'Required: Text prompt for image generation or editing',
1792
+ image_url: 'Optional: URL of image to edit (required for edit mode)',
1793
+ image_size: 'Optional: Image size (square, square_hd, portrait_4_3, portrait_16_9, landscape_4_3, landscape_16_9)',
1794
+ num_inference_steps: 'Optional: Number of inference steps (2-250 for text-to-image, 2-49 for edit)',
1795
+ guidance_scale: 'Optional: CFG scale (0-20, default: 2.5 for text-to-image, 4 for edit)',
1796
+ enable_safety_checker: 'Optional: Enable safety checker (default: true)',
1797
+ output_format: 'Optional: Output format (png/jpeg, default: png)',
1798
+ negative_prompt: 'Optional: Negative prompt (max 500 chars)',
1799
+ acceleration: 'Optional: Acceleration level (none/regular/high, default: none)',
1800
+ num_images: 'Optional: Number of images (1-4, edit mode only)',
1801
+ sync_mode: 'Optional: Sync mode (edit mode only)',
1802
+ seed: 'Optional: Random seed for reproducible results',
1803
+ callBackUrl: 'Optional: URL for task completion notifications (uses KIE_AI_CALLBACK_URL env var if not provided)'
1804
+ });
1805
+ }
1806
+ }
1807
+ async handleMidjourneyGenerate(args) {
1808
+ try {
1809
+ const request = MidjourneyGenerateSchema.parse(args);
1810
+ // Use environment variable as fallback if callBackUrl not provided
1811
+ if (!request.callBackUrl && process.env.KIE_AI_CALLBACK_URL) {
1812
+ request.callBackUrl = process.env.KIE_AI_CALLBACK_URL;
1813
+ }
1814
+ const response = await this.client.generateMidjourney(request);
1815
+ if (response.code === 200 && response.data?.taskId) {
1816
+ // Determine task type for user feedback
1817
+ const hasImage = request.fileUrl || (request.fileUrls && request.fileUrls.length > 0);
1818
+ const isVideoMode = request.motion || request.videoBatchSize || request.high_definition_video;
1819
+ const isOmniMode = request.ow || request.taskType === 'mj_omni_reference';
1820
+ const isStyleMode = request.taskType === 'mj_style_reference';
1821
+ let taskTypeDisplay = 'Text-to-Image';
1822
+ if (isOmniMode) {
1823
+ taskTypeDisplay = 'Omni Reference';
1824
+ }
1825
+ else if (isStyleMode) {
1826
+ taskTypeDisplay = 'Style Reference';
1827
+ }
1828
+ else if (isVideoMode) {
1829
+ taskTypeDisplay = request.high_definition_video ? 'Image-to-HD-Video' : 'Image-to-Video';
1830
+ }
1831
+ else if (hasImage) {
1832
+ taskTypeDisplay = 'Image-to-Image';
1833
+ }
1834
+ // Store task in database
1835
+ await this.db.createTask({
1836
+ task_id: response.data.taskId,
1837
+ api_type: 'midjourney',
1838
+ status: 'pending'
1839
+ });
1840
+ return {
1841
+ content: [
1842
+ {
1843
+ type: 'text',
1844
+ text: JSON.stringify({
1845
+ success: true,
1846
+ task_id: response.data.taskId,
1847
+ message: `Midjourney ${taskTypeDisplay} task created successfully`,
1848
+ parameters: {
1849
+ task_type: taskTypeDisplay,
1850
+ prompt: request.prompt.substring(0, 100) + (request.prompt.length > 100 ? '...' : ''),
1851
+ aspect_ratio: request.aspectRatio || '16:9',
1852
+ version: request.version || '7',
1853
+ speed: request.speed,
1854
+ variety: request.variety,
1855
+ stylization: request.stylization,
1856
+ weirdness: request.weirdness,
1857
+ enable_translation: request.enableTranslation || false,
1858
+ waterMark: request.waterMark,
1859
+ ...(hasImage && {
1860
+ file_urls: request.fileUrls || [request.fileUrl]
1861
+ }),
1862
+ ...(isVideoMode && {
1863
+ motion: request.motion || 'high',
1864
+ video_batch_size: request.videoBatchSize || '1',
1865
+ high_definition_video: request.high_definition_video || false
1866
+ }),
1867
+ ...(isOmniMode && {
1868
+ ow: request.ow
1869
+ })
1870
+ },
1871
+ next_steps: [
1872
+ `Use get_task_status with task_id: ${response.data.taskId} to check progress`,
1873
+ 'Generated content will be available when status is "completed"'
1874
+ ],
1875
+ usage_examples: [
1876
+ `get_task_status: {"task_id": "${response.data.taskId}"}`,
1877
+ `list_tasks: {"limit": 10}`
1878
+ ]
1879
+ }, null, 2)
1880
+ }
1881
+ ]
1882
+ };
1883
+ }
1884
+ else {
1885
+ throw new Error(response.msg || 'Failed to create Midjourney task');
1886
+ }
1887
+ }
1888
+ catch (error) {
1889
+ if (error instanceof z.ZodError) {
1890
+ return this.formatError('midjourney_generate', error, {
1891
+ prompt: 'Required: Text prompt describing the desired image (max 2000 chars)',
1892
+ taskType: 'Optional: Task type (mj_txt2img, mj_img2img, mj_style_reference, mj_omni_reference, mj_video, mj_video_hd) - auto-detected if not provided',
1893
+ fileUrl: 'Optional: Single image URL for image-to-image or video generation (legacy)',
1894
+ fileUrls: 'Optional: Array of image URLs for image-to-image or video generation (recommended)',
1895
+ speed: 'Optional: Generation speed (relaxed/fast/turbo) - not required for video/omni tasks',
1896
+ aspectRatio: 'Optional: Output aspect ratio (1:2, 9:16, 2:3, 3:4, 5:6, 6:5, 4:3, 3:2, 1:1, 16:9, 2:1, default: 16:9)',
1897
+ version: 'Optional: Midjourney model version (7, 6.1, 6, 5.2, 5.1, niji6, default: 7)',
1898
+ variety: 'Optional: Diversity control (0-100, increment by 5)',
1899
+ stylization: 'Optional: Artistic style intensity (0-1000, suggested multiple of 50)',
1900
+ weirdness: 'Optional: Creativity level (0-3000, suggested multiple of 100)',
1901
+ ow: 'Optional: Omni intensity for omni reference tasks (1-1000)',
1902
+ waterMark: 'Optional: Watermark identifier (max 100 chars)',
1903
+ enableTranslation: 'Optional: Auto-translate non-English prompts (default: false)',
1904
+ videoBatchSize: 'Optional: Number of videos to generate (1/2/4, default: 1, video mode only)',
1905
+ motion: 'Optional: Video motion level (high/low, default: high, required for video)',
1906
+ high_definition_video: 'Optional: Use HD video generation (default: false, uses standard definition)',
1907
+ callBackUrl: 'Optional: URL for task completion notifications (uses KIE_AI_CALLBACK_URL env var if not provided)'
1908
+ });
1909
+ }
1910
+ return this.formatError('midjourney_generate', error, {
1911
+ prompt: 'Required: Text prompt describing the desired image (max 2000 chars)',
1912
+ taskType: 'Optional: Task type (mj_txt2img, mj_img2img, mj_style_reference, mj_omni_reference, mj_video, mj_video_hd) - auto-detected if not provided',
1913
+ fileUrl: 'Optional: Single image URL for image-to-image or video generation (legacy)',
1914
+ fileUrls: 'Optional: Array of image URLs for image-to-image or video generation (recommended)',
1915
+ speed: 'Optional: Generation speed (relaxed/fast/turbo) - not required for video/omni tasks',
1916
+ aspectRatio: 'Optional: Output aspect ratio (1:2, 9:16, 2:3, 3:4, 5:6, 6:5, 4:3, 3:2, 1:1, 16:9, 2:1, default: 16:9)',
1917
+ version: 'Optional: Midjourney model version (7, 6.1, 6, 5.2, 5.1, niji6, default: 7)',
1918
+ variety: 'Optional: Diversity control (0-100, increment by 5)',
1919
+ stylization: 'Optional: Artistic style intensity (0-1000, suggested multiple of 50)',
1920
+ weirdness: 'Optional: Creativity level (0-3000, suggested multiple of 100)',
1921
+ ow: 'Optional: Omni intensity for omni reference tasks (1-1000)',
1922
+ waterMark: 'Optional: Watermark identifier (max 100 chars)',
1923
+ enableTranslation: 'Optional: Auto-translate non-English prompts (default: false)',
1924
+ videoBatchSize: 'Optional: Number of videos to generate (1/2/4, default: 1, video mode only)',
1925
+ motion: 'Optional: Video motion level (high/low, default: high, required for video)',
1926
+ high_definition_video: 'Optional: Use HD video generation (default: false, uses standard definition)',
1927
+ callBackUrl: 'Optional: URL for task completion notifications (uses KIE_AI_CALLBACK_URL env var if not provided)'
1928
+ });
1929
+ }
1930
+ }
1518
1931
  async handleRunwayAlephVideo(args) {
1519
1932
  try {
1520
1933
  const request = RunwayAlephVideoSchema.parse(args);
@@ -1,4 +1,4 @@
1
- import { KieAiConfig, KieAiResponse, NanoBananaGenerateRequest, NanaBananaEditRequest, NanoBananaUpscaleRequest, Veo3GenerateRequest, SunoGenerateRequest, ElevenLabsTTSRequest, ElevenLabsSoundEffectsRequest, ByteDanceSeedanceVideoRequest, RunwayAlephVideoRequest, WanVideoRequest, ByteDanceSeedreamImageRequest, ImageResponse, TaskResponse } from './types.js';
1
+ import { KieAiConfig, KieAiResponse, NanoBananaGenerateRequest, NanaBananaEditRequest, NanoBananaUpscaleRequest, Veo3GenerateRequest, SunoGenerateRequest, ElevenLabsTTSRequest, ElevenLabsSoundEffectsRequest, ByteDanceSeedanceVideoRequest, RunwayAlephVideoRequest, WanVideoRequest, ByteDanceSeedreamImageRequest, QwenImageRequest, MidjourneyGenerateRequest, ImageResponse, TaskResponse } from './types.js';
2
2
  export declare class KieAiClient {
3
3
  private config;
4
4
  constructor(config: KieAiConfig);
@@ -15,5 +15,7 @@ export declare class KieAiClient {
15
15
  generateRunwayAlephVideo(request: RunwayAlephVideoRequest): Promise<KieAiResponse<TaskResponse>>;
16
16
  generateWanVideo(request: WanVideoRequest): Promise<KieAiResponse<TaskResponse>>;
17
17
  generateByteDanceSeedreamImage(request: ByteDanceSeedreamImageRequest): Promise<KieAiResponse<TaskResponse>>;
18
+ generateQwenImage(request: QwenImageRequest): Promise<KieAiResponse<TaskResponse>>;
19
+ generateMidjourney(request: MidjourneyGenerateRequest): Promise<KieAiResponse<TaskResponse>>;
18
20
  getVeo1080pVideo(taskId: string, index?: number): Promise<KieAiResponse<any>>;
19
21
  }
@@ -80,13 +80,16 @@ export class KieAiClient {
80
80
  else if (apiType === 'suno') {
81
81
  return this.makeRequest(`/generate/record-info?taskId=${taskId}`, 'GET');
82
82
  }
83
- else if (apiType === 'elevenlabs-tts' || apiType === 'elevenlabs-sound-effects' || apiType === 'bytedance-seedance-video' || apiType === 'bytedance-seedream-image' || apiType === 'wan-video') {
83
+ else if (apiType === 'elevenlabs-tts' || apiType === 'elevenlabs-sound-effects' || apiType === 'bytedance-seedance-video' || apiType === 'bytedance-seedream-image' || apiType === 'qwen-image' || apiType === 'wan-video') {
84
84
  return this.makeRequest(`/jobs/recordInfo?taskId=${taskId}`, 'GET');
85
85
  }
86
86
  else if (apiType === 'runway-aleph-video') {
87
87
  return this.makeRequest(`/api/v1/aleph/record-info?taskId=${taskId}`, 'GET');
88
88
  }
89
- // Fallback: try jobs first, then veo, then generate (for tasks not in database)
89
+ else if (apiType === 'midjourney') {
90
+ return this.makeRequest(`/mj/record-info?taskId=${taskId}`, 'GET');
91
+ }
92
+ // Fallback: try jobs first, then veo, then generate, then mj (for tasks not in database)
90
93
  try {
91
94
  return await this.makeRequest(`/jobs/recordInfo?taskId=${taskId}`, 'GET');
92
95
  }
@@ -99,7 +102,12 @@ export class KieAiClient {
99
102
  return await this.makeRequest(`/generate/record-info?taskId=${taskId}`, 'GET');
100
103
  }
101
104
  catch (sunoError) {
102
- throw error;
105
+ try {
106
+ return await this.makeRequest(`/mj/record-info?taskId=${taskId}`, 'GET');
107
+ }
108
+ catch (mjError) {
109
+ throw error;
110
+ }
103
111
  }
104
112
  }
105
113
  }
@@ -254,6 +262,107 @@ export class KieAiClient {
254
262
  };
255
263
  return this.makeRequest('/jobs/createTask', 'POST', jobRequest);
256
264
  }
265
+ async generateQwenImage(request) {
266
+ // Determine mode based on presence of image_url
267
+ const isEdit = !!request.image_url;
268
+ const model = isEdit ? 'qwen/image-edit' : 'qwen/text-to-image';
269
+ const input = {
270
+ prompt: request.prompt,
271
+ image_size: request.image_size || 'square_hd',
272
+ num_inference_steps: request.num_inference_steps || (isEdit ? 25 : 30),
273
+ seed: request.seed,
274
+ guidance_scale: request.guidance_scale || (isEdit ? 4 : 2.5),
275
+ enable_safety_checker: request.enable_safety_checker !== false,
276
+ output_format: request.output_format || 'png',
277
+ negative_prompt: request.negative_prompt || (isEdit ? 'blurry, ugly' : ' '),
278
+ acceleration: request.acceleration || 'none'
279
+ };
280
+ // Add edit-specific parameters
281
+ if (isEdit) {
282
+ input.image_url = request.image_url;
283
+ if (request.num_images) {
284
+ input.num_images = request.num_images;
285
+ }
286
+ if (request.sync_mode !== undefined) {
287
+ input.sync_mode = request.sync_mode;
288
+ }
289
+ }
290
+ const jobRequest = {
291
+ model,
292
+ input,
293
+ callBackUrl: request.callBackUrl || process.env.KIE_AI_CALLBACK_URL
294
+ };
295
+ return this.makeRequest('/jobs/createTask', 'POST', jobRequest);
296
+ }
297
+ async generateMidjourney(request) {
298
+ // Smart task type detection
299
+ let taskType = request.taskType;
300
+ const hasImage = request.fileUrl || (request.fileUrls && request.fileUrls.length > 0);
301
+ const isVideoMode = request.motion || request.videoBatchSize || request.high_definition_video;
302
+ const isOmniMode = request.ow || request.taskType === 'mj_omni_reference';
303
+ const isStyleMode = request.taskType === 'mj_style_reference';
304
+ // Auto-detect task type if not provided
305
+ if (!taskType) {
306
+ if (isOmniMode) {
307
+ taskType = 'mj_omni_reference';
308
+ }
309
+ else if (isStyleMode) {
310
+ taskType = 'mj_style_reference';
311
+ }
312
+ else if (isVideoMode) {
313
+ taskType = request.high_definition_video ? 'mj_video_hd' : 'mj_video';
314
+ }
315
+ else if (hasImage) {
316
+ taskType = 'mj_img2img';
317
+ }
318
+ else {
319
+ taskType = 'mj_txt2img';
320
+ }
321
+ }
322
+ // Build request payload
323
+ const payload = {
324
+ taskType,
325
+ prompt: request.prompt,
326
+ aspectRatio: request.aspectRatio || '16:9',
327
+ version: request.version || '7',
328
+ enableTranslation: request.enableTranslation || false,
329
+ callBackUrl: request.callBackUrl || process.env.KIE_AI_CALLBACK_URL
330
+ };
331
+ // Add image URLs (prefer fileUrls array over fileUrl)
332
+ if (request.fileUrls && request.fileUrls.length > 0) {
333
+ payload.fileUrls = request.fileUrls;
334
+ }
335
+ else if (request.fileUrl) {
336
+ payload.fileUrls = [request.fileUrl];
337
+ }
338
+ // Add optional parameters based on task type
339
+ if (request.speed && !['mj_video', 'mj_video_hd', 'mj_omni_reference'].includes(taskType)) {
340
+ payload.speed = request.speed;
341
+ }
342
+ if (request.variety !== undefined) {
343
+ payload.variety = request.variety;
344
+ }
345
+ if (request.stylization !== undefined) {
346
+ payload.stylization = request.stylization;
347
+ }
348
+ if (request.weirdness !== undefined) {
349
+ payload.weirdness = request.weirdness;
350
+ }
351
+ if (request.waterMark !== undefined) {
352
+ payload.waterMark = request.waterMark;
353
+ }
354
+ // Task-specific parameters
355
+ if (taskType === 'mj_omni_reference' && request.ow) {
356
+ payload.ow = request.ow;
357
+ }
358
+ if ((taskType === 'mj_video' || taskType === 'mj_video_hd')) {
359
+ payload.motion = request.motion || 'high';
360
+ if (request.videoBatchSize) {
361
+ payload.videoBatchSize = parseInt(request.videoBatchSize.toString());
362
+ }
363
+ }
364
+ return this.makeRequest('/mj/generate', 'POST', payload);
365
+ }
257
366
  async getVeo1080pVideo(taskId, index) {
258
367
  const params = new URLSearchParams({ taskId });
259
368
  if (index !== undefined) {
package/dist/types.d.ts CHANGED
@@ -443,6 +443,232 @@ export declare const ByteDanceSeedreamImageSchema: z.ZodEffects<z.ZodObject<{
443
443
  image_resolution?: "1K" | "2K" | "4K" | undefined;
444
444
  max_images?: number | undefined;
445
445
  }>;
446
+ export declare const QwenImageSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
447
+ prompt: z.ZodString;
448
+ image_url: z.ZodOptional<z.ZodString>;
449
+ image_size: z.ZodOptional<z.ZodDefault<z.ZodEnum<["square", "square_hd", "portrait_4_3", "portrait_16_9", "landscape_4_3", "landscape_16_9"]>>>;
450
+ num_inference_steps: z.ZodOptional<z.ZodNumber>;
451
+ seed: z.ZodOptional<z.ZodNumber>;
452
+ guidance_scale: z.ZodOptional<z.ZodNumber>;
453
+ enable_safety_checker: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
454
+ output_format: z.ZodOptional<z.ZodDefault<z.ZodEnum<["png", "jpeg"]>>>;
455
+ negative_prompt: z.ZodOptional<z.ZodDefault<z.ZodString>>;
456
+ acceleration: z.ZodOptional<z.ZodDefault<z.ZodEnum<["none", "regular", "high"]>>>;
457
+ num_images: z.ZodOptional<z.ZodEnum<["1", "2", "3", "4"]>>;
458
+ sync_mode: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
459
+ callBackUrl: z.ZodOptional<z.ZodString>;
460
+ }, "strip", z.ZodTypeAny, {
461
+ prompt: string;
462
+ output_format?: "png" | "jpeg" | undefined;
463
+ image_size?: "square" | "square_hd" | "portrait_4_3" | "portrait_16_9" | "landscape_4_3" | "landscape_16_9" | undefined;
464
+ callBackUrl?: string | undefined;
465
+ image_url?: string | undefined;
466
+ seed?: number | undefined;
467
+ enable_safety_checker?: boolean | undefined;
468
+ negative_prompt?: string | undefined;
469
+ num_inference_steps?: number | undefined;
470
+ guidance_scale?: number | undefined;
471
+ acceleration?: "none" | "regular" | "high" | undefined;
472
+ num_images?: "1" | "2" | "3" | "4" | undefined;
473
+ sync_mode?: boolean | undefined;
474
+ }, {
475
+ prompt: string;
476
+ output_format?: "png" | "jpeg" | undefined;
477
+ image_size?: "square" | "square_hd" | "portrait_4_3" | "portrait_16_9" | "landscape_4_3" | "landscape_16_9" | undefined;
478
+ callBackUrl?: string | undefined;
479
+ image_url?: string | undefined;
480
+ seed?: number | undefined;
481
+ enable_safety_checker?: boolean | undefined;
482
+ negative_prompt?: string | undefined;
483
+ num_inference_steps?: number | undefined;
484
+ guidance_scale?: number | undefined;
485
+ acceleration?: "none" | "regular" | "high" | undefined;
486
+ num_images?: "1" | "2" | "3" | "4" | undefined;
487
+ sync_mode?: boolean | undefined;
488
+ }>, {
489
+ prompt: string;
490
+ output_format?: "png" | "jpeg" | undefined;
491
+ image_size?: "square" | "square_hd" | "portrait_4_3" | "portrait_16_9" | "landscape_4_3" | "landscape_16_9" | undefined;
492
+ callBackUrl?: string | undefined;
493
+ image_url?: string | undefined;
494
+ seed?: number | undefined;
495
+ enable_safety_checker?: boolean | undefined;
496
+ negative_prompt?: string | undefined;
497
+ num_inference_steps?: number | undefined;
498
+ guidance_scale?: number | undefined;
499
+ acceleration?: "none" | "regular" | "high" | undefined;
500
+ num_images?: "1" | "2" | "3" | "4" | undefined;
501
+ sync_mode?: boolean | undefined;
502
+ }, {
503
+ prompt: string;
504
+ output_format?: "png" | "jpeg" | undefined;
505
+ image_size?: "square" | "square_hd" | "portrait_4_3" | "portrait_16_9" | "landscape_4_3" | "landscape_16_9" | undefined;
506
+ callBackUrl?: string | undefined;
507
+ image_url?: string | undefined;
508
+ seed?: number | undefined;
509
+ enable_safety_checker?: boolean | undefined;
510
+ negative_prompt?: string | undefined;
511
+ num_inference_steps?: number | undefined;
512
+ guidance_scale?: number | undefined;
513
+ acceleration?: "none" | "regular" | "high" | undefined;
514
+ num_images?: "1" | "2" | "3" | "4" | undefined;
515
+ sync_mode?: boolean | undefined;
516
+ }>, {
517
+ prompt: string;
518
+ output_format?: "png" | "jpeg" | undefined;
519
+ image_size?: "square" | "square_hd" | "portrait_4_3" | "portrait_16_9" | "landscape_4_3" | "landscape_16_9" | undefined;
520
+ callBackUrl?: string | undefined;
521
+ image_url?: string | undefined;
522
+ seed?: number | undefined;
523
+ enable_safety_checker?: boolean | undefined;
524
+ negative_prompt?: string | undefined;
525
+ num_inference_steps?: number | undefined;
526
+ guidance_scale?: number | undefined;
527
+ acceleration?: "none" | "regular" | "high" | undefined;
528
+ num_images?: "1" | "2" | "3" | "4" | undefined;
529
+ sync_mode?: boolean | undefined;
530
+ }, {
531
+ prompt: string;
532
+ output_format?: "png" | "jpeg" | undefined;
533
+ image_size?: "square" | "square_hd" | "portrait_4_3" | "portrait_16_9" | "landscape_4_3" | "landscape_16_9" | undefined;
534
+ callBackUrl?: string | undefined;
535
+ image_url?: string | undefined;
536
+ seed?: number | undefined;
537
+ enable_safety_checker?: boolean | undefined;
538
+ negative_prompt?: string | undefined;
539
+ num_inference_steps?: number | undefined;
540
+ guidance_scale?: number | undefined;
541
+ acceleration?: "none" | "regular" | "high" | undefined;
542
+ num_images?: "1" | "2" | "3" | "4" | undefined;
543
+ sync_mode?: boolean | undefined;
544
+ }>;
545
+ export declare const MidjourneyGenerateSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
546
+ prompt: z.ZodString;
547
+ taskType: z.ZodOptional<z.ZodEnum<["mj_txt2img", "mj_img2img", "mj_style_reference", "mj_omni_reference", "mj_video", "mj_video_hd"]>>;
548
+ fileUrl: z.ZodOptional<z.ZodString>;
549
+ fileUrls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
550
+ speed: z.ZodOptional<z.ZodEnum<["relaxed", "fast", "turbo"]>>;
551
+ aspectRatio: z.ZodOptional<z.ZodDefault<z.ZodEnum<["1:2", "9:16", "2:3", "3:4", "5:6", "6:5", "4:3", "3:2", "1:1", "16:9", "2:1"]>>>;
552
+ version: z.ZodOptional<z.ZodDefault<z.ZodEnum<["7", "6.1", "6", "5.2", "5.1", "niji6"]>>>;
553
+ variety: z.ZodOptional<z.ZodNumber>;
554
+ stylization: z.ZodOptional<z.ZodNumber>;
555
+ weirdness: z.ZodOptional<z.ZodNumber>;
556
+ ow: z.ZodOptional<z.ZodNumber>;
557
+ waterMark: z.ZodOptional<z.ZodString>;
558
+ enableTranslation: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
559
+ callBackUrl: z.ZodOptional<z.ZodString>;
560
+ videoBatchSize: z.ZodOptional<z.ZodDefault<z.ZodEnum<["1", "2", "4"]>>>;
561
+ motion: z.ZodOptional<z.ZodDefault<z.ZodEnum<["high", "low"]>>>;
562
+ high_definition_video: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
563
+ }, "strip", z.ZodTypeAny, {
564
+ prompt: string;
565
+ aspectRatio?: "1:1" | "9:16" | "16:9" | "3:4" | "4:3" | "3:2" | "2:3" | "1:2" | "5:6" | "6:5" | "2:1" | undefined;
566
+ callBackUrl?: string | undefined;
567
+ enableTranslation?: boolean | undefined;
568
+ speed?: "turbo" | "relaxed" | "fast" | undefined;
569
+ waterMark?: string | undefined;
570
+ taskType?: "mj_txt2img" | "mj_img2img" | "mj_style_reference" | "mj_omni_reference" | "mj_video" | "mj_video_hd" | undefined;
571
+ fileUrl?: string | undefined;
572
+ fileUrls?: string[] | undefined;
573
+ version?: "6" | "7" | "6.1" | "5.2" | "5.1" | "niji6" | undefined;
574
+ variety?: number | undefined;
575
+ stylization?: number | undefined;
576
+ weirdness?: number | undefined;
577
+ ow?: number | undefined;
578
+ videoBatchSize?: "1" | "2" | "4" | undefined;
579
+ motion?: "high" | "low" | undefined;
580
+ high_definition_video?: boolean | undefined;
581
+ }, {
582
+ prompt: string;
583
+ aspectRatio?: "1:1" | "9:16" | "16:9" | "3:4" | "4:3" | "3:2" | "2:3" | "1:2" | "5:6" | "6:5" | "2:1" | undefined;
584
+ callBackUrl?: string | undefined;
585
+ enableTranslation?: boolean | undefined;
586
+ speed?: "turbo" | "relaxed" | "fast" | undefined;
587
+ waterMark?: string | undefined;
588
+ taskType?: "mj_txt2img" | "mj_img2img" | "mj_style_reference" | "mj_omni_reference" | "mj_video" | "mj_video_hd" | undefined;
589
+ fileUrl?: string | undefined;
590
+ fileUrls?: string[] | undefined;
591
+ version?: "6" | "7" | "6.1" | "5.2" | "5.1" | "niji6" | undefined;
592
+ variety?: number | undefined;
593
+ stylization?: number | undefined;
594
+ weirdness?: number | undefined;
595
+ ow?: number | undefined;
596
+ videoBatchSize?: "1" | "2" | "4" | undefined;
597
+ motion?: "high" | "low" | undefined;
598
+ high_definition_video?: boolean | undefined;
599
+ }>, {
600
+ prompt: string;
601
+ aspectRatio?: "1:1" | "9:16" | "16:9" | "3:4" | "4:3" | "3:2" | "2:3" | "1:2" | "5:6" | "6:5" | "2:1" | undefined;
602
+ callBackUrl?: string | undefined;
603
+ enableTranslation?: boolean | undefined;
604
+ speed?: "turbo" | "relaxed" | "fast" | undefined;
605
+ waterMark?: string | undefined;
606
+ taskType?: "mj_txt2img" | "mj_img2img" | "mj_style_reference" | "mj_omni_reference" | "mj_video" | "mj_video_hd" | undefined;
607
+ fileUrl?: string | undefined;
608
+ fileUrls?: string[] | undefined;
609
+ version?: "6" | "7" | "6.1" | "5.2" | "5.1" | "niji6" | undefined;
610
+ variety?: number | undefined;
611
+ stylization?: number | undefined;
612
+ weirdness?: number | undefined;
613
+ ow?: number | undefined;
614
+ videoBatchSize?: "1" | "2" | "4" | undefined;
615
+ motion?: "high" | "low" | undefined;
616
+ high_definition_video?: boolean | undefined;
617
+ }, {
618
+ prompt: string;
619
+ aspectRatio?: "1:1" | "9:16" | "16:9" | "3:4" | "4:3" | "3:2" | "2:3" | "1:2" | "5:6" | "6:5" | "2:1" | undefined;
620
+ callBackUrl?: string | undefined;
621
+ enableTranslation?: boolean | undefined;
622
+ speed?: "turbo" | "relaxed" | "fast" | undefined;
623
+ waterMark?: string | undefined;
624
+ taskType?: "mj_txt2img" | "mj_img2img" | "mj_style_reference" | "mj_omni_reference" | "mj_video" | "mj_video_hd" | undefined;
625
+ fileUrl?: string | undefined;
626
+ fileUrls?: string[] | undefined;
627
+ version?: "6" | "7" | "6.1" | "5.2" | "5.1" | "niji6" | undefined;
628
+ variety?: number | undefined;
629
+ stylization?: number | undefined;
630
+ weirdness?: number | undefined;
631
+ ow?: number | undefined;
632
+ videoBatchSize?: "1" | "2" | "4" | undefined;
633
+ motion?: "high" | "low" | undefined;
634
+ high_definition_video?: boolean | undefined;
635
+ }>, {
636
+ prompt: string;
637
+ aspectRatio?: "1:1" | "9:16" | "16:9" | "3:4" | "4:3" | "3:2" | "2:3" | "1:2" | "5:6" | "6:5" | "2:1" | undefined;
638
+ callBackUrl?: string | undefined;
639
+ enableTranslation?: boolean | undefined;
640
+ speed?: "turbo" | "relaxed" | "fast" | undefined;
641
+ waterMark?: string | undefined;
642
+ taskType?: "mj_txt2img" | "mj_img2img" | "mj_style_reference" | "mj_omni_reference" | "mj_video" | "mj_video_hd" | undefined;
643
+ fileUrl?: string | undefined;
644
+ fileUrls?: string[] | undefined;
645
+ version?: "6" | "7" | "6.1" | "5.2" | "5.1" | "niji6" | undefined;
646
+ variety?: number | undefined;
647
+ stylization?: number | undefined;
648
+ weirdness?: number | undefined;
649
+ ow?: number | undefined;
650
+ videoBatchSize?: "1" | "2" | "4" | undefined;
651
+ motion?: "high" | "low" | undefined;
652
+ high_definition_video?: boolean | undefined;
653
+ }, {
654
+ prompt: string;
655
+ aspectRatio?: "1:1" | "9:16" | "16:9" | "3:4" | "4:3" | "3:2" | "2:3" | "1:2" | "5:6" | "6:5" | "2:1" | undefined;
656
+ callBackUrl?: string | undefined;
657
+ enableTranslation?: boolean | undefined;
658
+ speed?: "turbo" | "relaxed" | "fast" | undefined;
659
+ waterMark?: string | undefined;
660
+ taskType?: "mj_txt2img" | "mj_img2img" | "mj_style_reference" | "mj_omni_reference" | "mj_video" | "mj_video_hd" | undefined;
661
+ fileUrl?: string | undefined;
662
+ fileUrls?: string[] | undefined;
663
+ version?: "6" | "7" | "6.1" | "5.2" | "5.1" | "niji6" | undefined;
664
+ variety?: number | undefined;
665
+ stylization?: number | undefined;
666
+ weirdness?: number | undefined;
667
+ ow?: number | undefined;
668
+ videoBatchSize?: "1" | "2" | "4" | undefined;
669
+ motion?: "high" | "low" | undefined;
670
+ high_definition_video?: boolean | undefined;
671
+ }>;
446
672
  export type NanoBananaGenerateRequest = z.infer<typeof NanoBananaGenerateSchema>;
447
673
  export type NanaBananaEditRequest = z.infer<typeof NanoBananaEditSchema>;
448
674
  export type NanoBananaUpscaleRequest = z.infer<typeof NanoBananaUpscaleSchema>;
@@ -454,6 +680,8 @@ export type ByteDanceSeedanceVideoRequest = z.infer<typeof ByteDanceSeedanceVide
454
680
  export type RunwayAlephVideoRequest = z.infer<typeof RunwayAlephVideoSchema>;
455
681
  export type WanVideoRequest = z.infer<typeof WanVideoSchema>;
456
682
  export type ByteDanceSeedreamImageRequest = z.infer<typeof ByteDanceSeedreamImageSchema>;
683
+ export type QwenImageRequest = z.infer<typeof QwenImageSchema>;
684
+ export type MidjourneyGenerateRequest = z.infer<typeof MidjourneyGenerateSchema>;
457
685
  export interface KieAiResponse<T = any> {
458
686
  code: number;
459
687
  msg: string;
@@ -469,7 +697,7 @@ export interface TaskResponse {
469
697
  export interface TaskRecord {
470
698
  id?: number;
471
699
  task_id: string;
472
- api_type: 'nano-banana' | 'nano-banana-edit' | 'nano-banana-upscale' | 'veo3' | 'suno' | 'elevenlabs-tts' | 'elevenlabs-sound-effects' | 'bytedance-seedance-video' | 'runway-aleph-video' | 'wan-video' | 'bytedance-seedream-image';
700
+ api_type: 'nano-banana' | 'nano-banana-edit' | 'nano-banana-upscale' | 'veo3' | 'suno' | 'elevenlabs-tts' | 'elevenlabs-sound-effects' | 'bytedance-seedance-video' | 'runway-aleph-video' | 'wan-video' | 'bytedance-seedream-image' | 'qwen-image' | 'midjourney';
473
701
  status: 'pending' | 'processing' | 'completed' | 'failed';
474
702
  created_at: string;
475
703
  updated_at: string;
package/dist/types.js CHANGED
@@ -202,3 +202,122 @@ export const ByteDanceSeedreamImageSchema = z.object({
202
202
  message: "callBackUrl is required (either directly or via KIE_AI_CALLBACK_URL environment variable)",
203
203
  path: ["callBackUrl"]
204
204
  });
205
+ export const QwenImageSchema = z.object({
206
+ prompt: z.string().min(1),
207
+ image_url: z.string().url().optional(), // Required for edit mode, optional for text-to-image
208
+ image_size: z.enum([
209
+ 'square', 'square_hd', 'portrait_4_3', 'portrait_16_9',
210
+ 'landscape_4_3', 'landscape_16_9'
211
+ ]).default('square_hd').optional(),
212
+ num_inference_steps: z.number().int().min(2).max(250).optional(),
213
+ seed: z.number().optional(),
214
+ guidance_scale: z.number().min(0).max(20).optional(),
215
+ enable_safety_checker: z.boolean().default(true).optional(),
216
+ output_format: z.enum(['png', 'jpeg']).default('png').optional(),
217
+ negative_prompt: z.string().max(500).default(' ').optional(),
218
+ acceleration: z.enum(['none', 'regular', 'high']).default('none').optional(),
219
+ // Edit-specific parameters
220
+ num_images: z.enum(['1', '2', '3', '4']).optional(),
221
+ sync_mode: z.boolean().default(false).optional(),
222
+ callBackUrl: z.string().url().optional()
223
+ }).refine((data) => {
224
+ // Check if callBackUrl is provided directly or via environment variable
225
+ const hasCallBackUrl = data.callBackUrl || process.env.KIE_AI_CALLBACK_URL;
226
+ if (!hasCallBackUrl) {
227
+ return false;
228
+ }
229
+ return true;
230
+ }, {
231
+ message: "callBackUrl is required (either directly or via KIE_AI_CALLBACK_URL environment variable)",
232
+ path: ["callBackUrl"]
233
+ }).refine((data) => {
234
+ // Validate edit mode requirements
235
+ const isEditMode = !!data.image_url;
236
+ if (isEditMode) {
237
+ // Edit mode specific validations
238
+ if (data.num_inference_steps && (data.num_inference_steps < 2 || data.num_inference_steps > 49)) {
239
+ return false;
240
+ }
241
+ if (data.prompt && data.prompt.length > 2000) {
242
+ return false;
243
+ }
244
+ }
245
+ else {
246
+ // Text-to-image mode specific validations
247
+ if (data.prompt && data.prompt.length > 5000) {
248
+ return false;
249
+ }
250
+ }
251
+ return true;
252
+ }, {
253
+ message: "Invalid parameters for detected mode",
254
+ path: []
255
+ });
256
+ export const MidjourneyGenerateSchema = z.object({
257
+ prompt: z.string().min(1).max(2000),
258
+ taskType: z.enum([
259
+ 'mj_txt2img', 'mj_img2img', 'mj_style_reference', 'mj_omni_reference',
260
+ 'mj_video', 'mj_video_hd'
261
+ ]).optional(), // Auto-detected if not provided
262
+ fileUrl: z.string().url().optional(), // Single image URL (legacy)
263
+ fileUrls: z.array(z.string().url()).max(10).optional(), // Array of image URLs (recommended)
264
+ speed: z.enum(['relaxed', 'fast', 'turbo']).optional(), // Not required for video/omni tasks
265
+ aspectRatio: z.enum([
266
+ '1:2', '9:16', '2:3', '3:4', '5:6', '6:5', '4:3', '3:2', '1:1', '16:9', '2:1'
267
+ ]).default('16:9').optional(),
268
+ version: z.enum(['7', '6.1', '6', '5.2', '5.1', 'niji6']).default('7').optional(),
269
+ variety: z.number().int().min(0).max(100).optional(), // Increment by 5
270
+ stylization: z.number().int().min(0).max(1000).optional(), // Suggested multiple of 50
271
+ weirdness: z.number().int().min(0).max(3000).optional(), // Suggested multiple of 100
272
+ ow: z.number().int().min(1).max(1000).optional(), // Omni intensity (only for mj_omni_reference)
273
+ waterMark: z.string().max(100).optional(),
274
+ enableTranslation: z.boolean().default(false).optional(),
275
+ callBackUrl: z.string().url().optional(),
276
+ // Video-specific parameters
277
+ videoBatchSize: z.enum(['1', '2', '4']).default('1').optional(), // Only for mj_video/mj_video_hd
278
+ motion: z.enum(['high', 'low']).default('high').optional(), // Required for video generation
279
+ high_definition_video: z.boolean().default(false).optional() // If true, use mj_video_hd instead of mj_video
280
+ }).refine((data) => {
281
+ // Check if callBackUrl is provided directly or via environment variable
282
+ const hasCallBackUrl = data.callBackUrl || process.env.KIE_AI_CALLBACK_URL;
283
+ if (!hasCallBackUrl) {
284
+ return false;
285
+ }
286
+ return true;
287
+ }, {
288
+ message: "callBackUrl is required (either directly or via KIE_AI_CALLBACK_URL environment variable)",
289
+ path: ["callBackUrl"]
290
+ }).refine((data) => {
291
+ // Auto-detect and validate task type based on parameters
292
+ const hasImage = data.fileUrl || (data.fileUrls && data.fileUrls.length > 0);
293
+ const isVideoMode = data.motion || data.videoBatchSize || data.high_definition_video;
294
+ const isOmniMode = data.taskType === 'mj_omni_reference' || data.ow;
295
+ const isStyleMode = data.taskType === 'mj_style_reference';
296
+ // If taskType is explicitly provided, validate it
297
+ if (data.taskType) {
298
+ // Video tasks require motion parameter
299
+ if ((data.taskType === 'mj_video' || data.taskType === 'mj_video_hd') && !data.motion) {
300
+ return false;
301
+ }
302
+ // Omni tasks require ow parameter
303
+ if (data.taskType === 'mj_omni_reference' && !data.ow) {
304
+ return false;
305
+ }
306
+ // Image tasks require image URL
307
+ if ((data.taskType === 'mj_img2img' || data.taskType === 'mj_style_reference' || data.taskType === 'mj_omni_reference') && !hasImage) {
308
+ return false;
309
+ }
310
+ // Video tasks require image URL
311
+ if ((data.taskType === 'mj_video' || data.taskType === 'mj_video_hd') && !hasImage) {
312
+ return false;
313
+ }
314
+ // Text-to-image should not have image URL
315
+ if (data.taskType === 'mj_txt2img' && hasImage) {
316
+ return false;
317
+ }
318
+ }
319
+ return true;
320
+ }, {
321
+ message: "Invalid combination of parameters for the detected task type",
322
+ path: []
323
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@felores/kie-ai-mcp-server",
3
- "version": "1.7.2",
4
- "description": "MCP server for Kie.ai APIs (Nano Banana image generation/editing, ByteDance Seedream V4 image generation/editing, Veo3 video generation, Suno music generation, and ElevenLabs text-to-speech)",
3
+ "version": "1.7.4",
4
+ "description": "MCP server for Kie.ai APIs (Nano Banana image generation/editing, ByteDance Seedream V4 image generation/editing, Veo3 video generation, Suno music generation, ElevenLabs text-to-speech, and Midjourney AI generation)",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
7
7
  "kie-ai-mcp-server": "dist/index.js"