POST
javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 const axios = require('axios'); const fs = require('fs'); const path = require('path'); async function toB64(imgPath) { const data = fs.readFileSync(path.resolve(imgPath)); return Buffer.from(data).toString('base64'); } const api_key = "YOUR API-KEY"; const url = "https://api.segmind.com/v1/kling-2.1"; const data = { "image": "toB64('https://segmind-resources.s3.amazonaws.com/input/e1fcf474-2790-4e1a-b094-ae0b20a18ab8-428e317b-d7c2-48fb-a001-ed0820fb04be.jpg')", "prompt": "Front View Shot of model in casual wear. [Push in] [Static shot] Subtle shoulder rotation, confident smile, hands in pockets, slight weight shift.", "negative_prompt": "No jittery motion, avoid rapid scene changes.", "cfg_scale": 0.7, "mode": "pro", "aspect_ratio": "16:9", "duration": 5 }; (async function() { try { const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } }); console.log(response.data); } catch (error) { console.error('Error:', error.response.data); } })();
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


imageimage *

Provide an image URL to be animated. Use clear, high-quality images for best results.


promptstr ( default: Front View Shot of model in casual wear. [Push in] [Static shot] Subtle shoulder rotation, confident smile, hands in pockets, slight weight shift. )

Describe the desired animation effect. Use creative, vivid descriptions for dynamic animations.


negative_promptstr ( default: No jittery motion, avoid rapid scene changes. )

Specify unwanted effects. List distractions like sudden flashes or fast zooms to avoid them.


cfg_scalefloat ( default: 0.7 )

Controls animation adherence to the prompt. Lower for more freedom, higher for precise adherence.

min : 0,

max : 1


modeenum:str ( default: pro )

Choose animation quality mode. 'Pro' for balanced quality, 'Master' for quality focus.

Allowed values:


aspect_ratioenum:str ( default: 16:9 )

Select output aspect ratio. '16:9' is best for widescreens, '1:1' for social media.

Allowed values:


durationenum:str ( default: 5 )

Set animation duration. Choose '5' for short previews, '10' for detailed views.

Allowed values:

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.

Leveraging Kling 2.1 for Enhanced Video and Image Generation

Kling 2.1, a noteworthy advancement in AI-driven video and image generation, offers developers and creators a robust platform to transform their creative processes. With its dual operational modes, Kling 2.1 provides versatile solutions suited for different project needs and budgets.

Key Features

Kling 2.1 introduces two modes: Standard Mode (720p), ideal for cost-effective projects, and Professional Mode (1080p), which delivers high-quality outputs. This dual-mode operation ensures flexibility in producing both draft content and polished, professional deliverables seamlessly.

Advanced Capabilities

This model excels in dynamic video creation through improved motion dynamics and aesthetic quality, making it particularly adept at tasks such as text-to-video generation and image-to-video transformation. By capturing more nuanced interpretations of text prompts via enhanced NLP capabilities, Kling 2.1 sets a high standard for visual storytelling.

Practical Applications for Creators

Creators can harness Kling 2.1 for tasks like transforming product photos into engaging promotional videos or animating static visuals effortlessly. Its video extension feature supports creators in expanding existing footage without compromising quality, which is invaluable for maintaining narrative flows.

Optimization Strategies

To maximize Kling 2.1’s capabilities, thoughtful application of prompt engineering and strategic mode selection are essential. Begin with Standard Mode for concept exploration, then transition to Professional Mode for final cuts. This approach balances quality and cost-effectiveness.

Kling 2.1 positions itself as a formidable tool in content generation, offering unique features like video extension and continuous improvement capabilities, which ensure it remains relevant and powerful in rapidly evolving creative workflows. By integrating these strategies, users can capitalize on Kling 2.1’s full potential, driving innovation and efficiency in their projects.