「KlingAI」APISpecification
UpdateTime
UpdateNotes
2024.12.2
【VideoGeneration】
Withmultipleversionsofthevideogenerationmodel(V1,V1.5)andvariousplugincapabilities(e.g.,cameracontrol,start/endframe,motionbrush,videoextension,etc.),wehavecreateda"CapabilityMap"tomakeiteasierforeveryonetovisuallychecktheavailabilityofdifferentversionsandfeatures.Fordetails,pleaserefertothe"3-0CapabilityMap."
2024.11.29
【VideoGeneration-ImageToVideo】NewFeature:MotionBrush
ThisfeatureisonlysupportedinStandardMode5sandProfessionalMode5sfortheV1.0model,andiscurrentlynotavailablefortheV1.5model.
2024.11.15
【VideoGeneration】KlingV1.5ProModelNowOpenforVideoGeneration:Image-to-VideoFunctionalityEnabled,Text-to-VideoUnsupported
Onlysupportsprofessionalmode
Tailframecontrolisnotsupported
Allotherparametersaresupported
【VideoGeneration】NewFeature:VideoExtension
SupportsextendingvideosgeneratedbytheV1.0modeldirectly,adding4-5secondsofvideolengthperextension
Includescreatetask,querytask(single),andquerytask(list)interfaces
【VideoGeneration】OtherUpdates
Added"external_task_id"field,allowingyoutocustomizeataskIDwhencreatingatask,andquerythevideousingthiscustomIDwhenneeded
2024.10.30
Addedthe"QueryResourcePackageListandRemainingQuantity"interfaceforyourconvenience.See"SectionVI:AccountInformationQuery".
2024.10.25
Toclarifythestoragedurationofmodel-generatedcontent(images/videos):
Toensureinformationsecurity,generatedimages/videoswillbeclearedafter30days.Pleasemakesuretosavethempromptly.
2024.10.15
AddasampleJavacodeforgeneratingtheAPI_Token.
2024.9.19
VideoGeneration
Whencreatingatask,thecharacterlimitforthepromptandnegative_promptintherequestparametershasbeenupdatedto:cannotexceed2500characters.
2024.9.19
Officiallysupportingthe"AIVirtualTry-on"relatedAPI(kolors-virtual-try-on).
 
I.GeneralInformation
1.APIDomain
💎
https://api.klingai.com
 
2.APIAuthentication
Step-1:ObtainAccessKey+SecretKey
Step-2:EverytimeyourequesttheAPI,youneedtogenerateanAPITokenaccordingtotheFixedEncryptionMethod,Authorization=Bearer<APIToken>inRequsetHeader
EncryptionMethod:FollowJWT(JsonWebToken,RFC7519)standard
JWTconsistsofthreeparts:Header、Payload、Signature
Samplecode(Python)
Samplecode(Java):
 
3.ErrorCode
HTTPStatusCode
ServiceCode
DefinitionofServiceCode
ExplainationofServiceCode
SuggestedSolutions
200
0
Request
-
-
401
1000
Authenticationfailed
Authenticationfailed
CheckiftheAuthorizationiscorrect
401
1001
Authenticationfailed
Authorizationisempty
FillinthecorrectAuthorizationintheRequestHeader
401
1002
Authenticationfailed
Authorizationisinvalid
FillinthecorrectAuthorizationintheRequestHeader
401
1003
Authenticationfailed
Authorizationisnotyetvalid
Checkthestarteffectivetimeofthetoken,waitforittotakeeffectorreissue
401
1004
Authenticationfailed
Authorizationhasexpired
Checkthevalidityperiodofthetokenandreissueit
429
1100
Accountexception
Accountexception
Verifyingaccountconfigurationinformation
429
1101
Accountexception
Accountinarrears(postpaidscenario)
Rechargetheaccounttoensuresufficientbalance
429
1102
Accountexception
Resourcepackdepletedorexpired(prepaidscenario)
Purchaseadditionalresourcepackages,oractivatethepost-paymentservice(ifavailable)
403
1103
Accountexception
Unauthorizedaccesstorequestedresource,suchasAPI/model
Verifyingaccountpermissions
400
1200
Invalidrequestparameters
Invalidrequestparameters
Checkwhethertherequestparametersarecorrect
400
1201
Invalidrequestparameters
Invalidparameters,suchasincorrectkeyorillegalvalue
Refertothespecificinformationinthemessagefieldofthereturnedbodyandmodifytherequestparameters
404
1202
Invalidrequestparameters
Therequestedmethodisinvalid
ReviewtheAPIdocumentationandusethecorrectrequestmethod
404
1203
Invalidrequestparameters
Therequestedresourcedoesnotexist,suchasthemodel
Refertothespecificinformationinthemessagefieldofthereturnedbodyandmodifytherequestparameters
400
1300
Triggerstrategy
Triggerstrategyoftheplatform
Checkifanyplatformpolicieshavebeentriggered
400
1301
Triggerstrategy
Triggerthecontentsecuritypolicyoftheplatform
Checktheinputcontent,modifyit,andresendtherequest
429
1302
Triggerstrategy
TheAPIrequestistoofast,exceedingtheplatform'sratelimit
Reducetherequestfrequency,tryagainlater,orcontactcustomerservicetoincreasethelimit
429
1303
Triggerstrategy
ConcurrencyorQPSexceedstheprepaidresourcepackagelimit
Reducetherequestfrequency,tryagainlater,orcontactcustomerservicetoincreasethelimit
429
1304
Triggerstrategy
Triggertheplatform'sIPwhitelistingpolicy
Contactcustomerservice
500
5000
Internalerror
Serverinternalerror
Tryagainlater,orcontactcustomerservice
503
5001
Internalerror
Servertemporarilyunavailable,usuallyduetomaintenance
Tryagainlater,orcontactcustomerservice
504
5002
Internalerror
Serverinternaltimeout,usuallyduetoabacklog
Tryagainlater,orcontactcustomerservice