Kling AI icon

Kling AI

Consume Kling AI API

Actions12

Overview

This node integrates with the Kling AI API to retrieve account resource package usage data within a specified time range. It is useful for monitoring and managing your Kling AI account consumption, especially when you want to track how different resource packages are utilized over time.

A practical example: You want to generate a report of your Kling AI resource usage for the past month or check the usage of a specific resource package to optimize costs or plan future usage.

Properties

Name Meaning
API Token JWT token for authenticating with the Kling AI API. Must be generated with specific header and payload as per Kling AI requirements.
Start Time Unix timestamp in milliseconds marking the start of the query period for resource package usage data.
End Time Unix timestamp in milliseconds marking the end of the query period for resource package usage data.
Resource Pack Name (Optional) Specific resource package name to filter the query results more precisely.

Output

The node outputs JSON data representing the resource package usage information returned by the Kling AI API for the specified time range and optional resource package filter.

  • The output JSON structure corresponds directly to the API response from the /account/costs endpoint.
  • Each item in the output array contains detailed usage statistics about resource packages.
  • No binary data output is produced by this operation.

Dependencies

  • Requires an active internet connection to reach https://api.klingai.com.
  • Needs a valid JWT API token credential for authentication with the Kling AI API.
  • No additional n8n credentials or environment variables are required beyond the API token input property.

Troubleshooting

  • Authentication Errors: If you receive an authentication failure error, verify that your JWT token is correctly formatted without the "Bearer" prefix and that it has not expired.
  • No Response Data: If no data is returned, ensure the time range (startTime and endTime) is valid and that there is usage data available for that period.
  • API Errors: Any other API errors will include messages from the Kling AI API; check these messages for hints on invalid parameters or server issues.
  • Continue On Fail: If enabled, the node will continue processing subsequent items even if one fails, returning error details in the output JSON.

Links and References

  • Kling AI API Documentation (hypothetical link, replace with actual if available)
  • JWT Token Generation Guide: Use header {"alg":"HS256","typ":"JWT"} and payload {"iss":"YOUR_ACCESS_KEY","exp":EXPIRATION_TIME,"nbf":NOT_BEFORE_TIME} as described in the property description.

Discussion