API Doc-CometAPI
HomeDashBoardModel_Price
HomeDashBoardModel_Price
Discord_Support
  1. kling (video)
  • GET START
    • Model New Release Announcement
    • Platform notification
    • Help Center
    • Quick Start
    • About Pricing
    • About Grouping
    • Interface Stability
    • Privacy policy
    • Terms of service
    • Error code description
    • Code example
    • Must see for use
    • Common Misconceptions
    • Confusion about use
    • Best Practices
      • CometAPI Account Balance Query API Usage Instructions
      • Retry Logic Documentation for CometAPI and OpenAI Official API
      • Midjourney Best Practices
      • Runway Best Practices
  • OpenAI Compatiable Endpoint
    • gpt-4o-image generates image
    • Chat
    • Recognizing Images
    • Models
    • Embeddings
    • Images
    • Realtime
    • Image Editing (gpt-image-1)
    • response
  • Audio
    • Create speech
    • Create transcription
    • Create translation
  • Anthropic Compatiable Endpoint
    • Anthropic Claude
  • Music Generation Endpoint
    • Suno
      • Setting suno Version
      • Generate lyrics
      • Generate music clip
      • Upload clip
      • Submit concatenation
      • Single task query
      • Batch query tasks
    • Udio(Temporarily unavailable)
      • Generate music
      • Task query
    • test
      • Suno
        • Full Track Audio Separation
        • Single Track Audio Separation
        • Create New Persona
        • Generate mp4 mv video
        • Get wav format file
        • Timing: lyrics, audio timeline
        • Create music using persona_id
  • Image Generation Endpoint
    • Midjourney(images)
      • Quick Tutorial - Complete Process in One Go
      • Task Fetching API
        • List by Condition
        • Fetch Single Task (most recommended)
      • Imagine
      • Submit Video
      • Action (UPSCALE; VARIATION; REROLL; ZOOM, etc.)
      • Blend (image -> image)
      • Describe (image -> text)
      • Modal (Area Redesign & Zoom)
    • Ideogram(images)
      • Official documentation (updated in real time)
      • Generate 3.0 (text to image)
      • Remix 3.0 (hybrid image)
      • Reframe 3.0(Reconstruction)
      • Replace Background 3.0(Background replacement)
      • Edit 3.0(Editing images)
      • ideogram Text Raw Image
      • ideogram Hybrid image
      • ideogram enlargement HD
      • ideogram describes the image
      • ideogram Edit image((legacy))
    • Flux(images)
      • Generate image (replicate format)
      • flux fine-tune images(Temporarily unavailable)
      • flux generate image(Temporarily unavailable)
      • flux query
    • Replicate(image)
      • replicate Generate
      • replicate query
    • Recraft(images)
      • Appendix
      • Recraft Generate Image
      • Recraft Vectorize Image
      • Recraft Remove Background
      • Recraft Clarity Upscale
      • Recraft Create style
      • Recraft Generative Upscale
  • Video Generation Ednpoint
    • veo3
      • veo3
    • runway(video)
      • official format
        • runway images raw video
        • runway to get task details
      • Reverse Format
        • generate(text)
        • generate(Reference images)
        • Video to Video Style Redraw
        • Act-one Expression Migration
        • feed-get task
    • kling (video)
      • callback_url
      • Expanded
        POST
      • Generating images
        POST
      • Text Generation Video
        POST
      • Image Generation Video
        POST
      • Video Extension
        POST
      • virtual try-on
        POST
      • lip sync
        POST
      • effects
        POST
      • Individual queries (videos)
        GET
    • MiniMax Conch(video)
      • MiniMax Conch Official Documentation
      • MiniMax Conch Generation
      • MiniMax Conch Query
      • MiniMax Conch Download
    • luma (video)
      • Official api interface format
        • luma generate
        • luma search
    • PIKA(video)
      • pika feed
      • PIKA Reference Video Generation
      • PIKA Reference Image Generation
      • PIKA reference text generation
    • sora
      • Reverse Format
        • Create Video
        • Query Video Task
        • Create Video
  • Software Integration Guide
    • cometapi Site API Call Testing
    • OpenManus
    • Chatbox
    • CherryStudio
    • Cursor
    • ChatHub
    • COZE
    • FastGPT
    • cline
    • dify
    • gptme
    • Immersive Translation
    • Lobe-Chat
    • Zotero
    • LangChain
    • AnythingLLM
    • Eudic Translation
    • OpenAI Translator
    • ChatAll Translation
    • Pot Translation
    • GPT Academic Optimization (gpt_academic)
    • NEXT CHAT (ChatGPT Next Web)
    • Obsidian's Text Generator Plugin
    • Open WebUI
    • avante.nvim
    • librechat
    • Lazy Customer Service
    • utools-ChatGPT Friend
    • IntelliJ Translation Plugin
    • n8n
  1. kling (video)

Expanded

POST
https://api.cometapi.com/kling/v1/images/editing/expand
Maintainer:Not configured
This document is not updated in real time; for the complete version, please refer to the official documentation: https://app.klingai.com/cn/dev/document-api/apiReference/model/textToVideo

Request

Header Params
Authorization
string 
required
Example:
Bearer {{api-key}}
Content-Type
string 
optional
Example:
application/json
Body Params application/json
image
string 
Reference Image
required
Supports input of image Base64 encoding or image URL (ensure it is accessible). Note: If using Base64, please pass the Base64 encoded string directly; do not add the data:image prefix. Supported image formats: .jpg/.jpeg/.png. File size must not exceed 10MB. Image resolution must be no less than 300*300px, and the image aspect ratio should be between 1:2.5 and 2.5:1.
Examples:
iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==https://example.com/image.jpg
up_expansion_ratio
number 
Upward Expansion Range
required
Calculated based on a multiple of the original image height. Value range: [0,2]. The overall area of the new image must not exceed 3 times that of the original image. For example, if the original image height is 20 and the current parameter value is 0.1, then the distance from the top edge of the original image to the top edge of the new image is 20 x 0.1 = 2; the area within this distance is the expansion range.
>= 0<= 2
Examples:
00.10.512
bottom_expansion_ratio
number 
Downward Expansion Range
required
Calculated based on a multiple of the original image height. Value range: [0,2]. The overall area of the new image must not exceed 3 times that of the original image. For example, if the original image height is 20 and the current parameter value is 0.2, then the distance from the bottom edge of the original image to the bottom edge of the new image is 20 x 0.2 = 4; the area within this distance is the expansion range.
left_expansion_ratio
number 
Leftward Expansion Range
required
Calculated based on a multiple of the original image width. Value range: [0,2]. The overall area of the new image must not exceed 3 times that of the original image. For example, if the original image width is 30 and the current parameter value is 0.3, then the distance from the left edge of the original image to the left edge of the new image is 30 x 0.3 = 9; the area within this distance is the expansion range.
>= 0<= 2
Examples:
00.10.512
right_expansion_ratio
number 
Rightward Expansion Range
required
Calculated based on a multiple of the original image width. Value range: [0,2]. The overall area of the new image must not exceed 3 times that of the original image. For example, if the original image width is 30 and the current parameter value is 0.4, then the distance from the right edge of the original image to the right edge of the new image is 30 x 0.4 = 12; the area within this distance is the expansion range.
>= 0<= 2
Examples:
00.10.512
prompt
string 
optional
Must not exceed 2500 characters
<= 2500 characters
Example:
sunset landscape, detailed, high quality
n
string 
optional
Number of images to generate
>= 1 characters<= 9 characters
Examples:
12
callback_url
string 
optional
Callback notification address for the result of this task. If configured, the server will proactively notify when the task status changes. For the schema of the notification message, see the Callback protocol.
Example:
https://your-domain.com/callback
external_task_id
string 
optional
User-defined task ID. Providing this will not overwrite the system-generated task ID, but it can be used to query the task. Please ensure uniqueness under the same user.
Example:
user_task_001
Example
{
    "image": "https://storage.fonedis.cc/upload_1750935799477317519.png",
    "up_expansion_ratio": 0.1495,
    "right_expansion_ratio": 0.6547,
    "left_expansion_ratio": 0.6547,
    "down_expansion_ratio": 0.1495,
    "prompt": "white sun"
}

Request samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.cometapi.com/kling/v1/images/editing/expand' \
--header 'Authorization: Bearer {{api-key}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "image": "https://storage.fonedis.cc/upload_1750935799477317519.png",
    "up_expansion_ratio": 0.1495,
    "right_expansion_ratio": 0.6547,
    "left_expansion_ratio": 0.6547,
    "down_expansion_ratio": 0.1495,
    "prompt": "white sun"
}'

Responses

🟢200Successful Response
application/json
Body
code
integer 
Error code; specifically define error code
optional
Error code; specifically define the error code
image
string 
required
Supports passing in an image Base64-encoded string or image URL (ensure it is accessible). Note: If using Base64, make sure to pass the Base64 encoded string directly without adding the data:image prefix. Supported image formats are .jpg/.jpeg/.png, file size must not exceed 10MB, image resolution must be no less than 300*300px, and the aspect ratio must be between 1:2.5 and 2.5:1
Examples:
iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==https://example.com/image.jpg
message
string 
Error message
optional
error message
request_id
string 
Request ID, system generated, used for tracking requests, troubleshooting issues
optional
Request ID, system-generated, for tracking requests, troubleshooting issues
data
object 
optional
task_id
string 
Task ID, system generated
required
Task ID, system generated
task_status
string 
Task status, enumerated values: submitted (submitted), processing (processing), succeed (succeed), failed (failed)
required
Task status, enumerated values: submitted, processing, succeed, failed.
created_at
integer 
Task creation time, Unix timestamp, unit ms
required
Task creation time, Unix timestamp, in ms.
updated_at
integer 
Task update time, Unix timestamp, unit ms
required
Task update time, Unix timestamp, in ms.
Example
{
    "code": 0,
    "message": "string",
    "request_id": "string",
    "data": {
        "task_id": "string",
        "task_status": "string",
        "created_at": 0,
        "updated_at": 0
    }
}
Previous
callback_url
Next
Generating images
Built with