Agent skill · software engineering · jeremylongshore

klingai-sdk-patterns

Production SDK patterns for Kling AI: client wrapper, retry logic, async

Why this skill is useful

Adds a complete Python client wrapper for the Kling AI API with advanced features like JWT handling and exponential backoff polling.

What it needs

Requires npm installed locally. Requires klingai account access. About 4k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.

What this skill does

Kling AI SDK Patterns Overview Production-ready client patterns for the Kling AI API. Covers auto-refreshing JWT, typed request/response models, exponential backoff polling, async batch submission, and structured error handling. Python Client Wrapper Usage Node.js Client Retry Decorator Prerequisites A pinned SDK version, sandbox workspace, secret references, synthetic or rights-cleared brief, approved rate/credit limits, content-policy check, and rollback owner. Instructions 1. Exercise SDK patterns with one sandbox, draft-only canary; do not hard-code credentials or submit private/unlicensed materials. 2. Apply idempotency, bounded retries, redacted telemetry, and explicit task cancellation; verify policy, rights, credit, destination, and retention controls. 3. Stop on authentication, policy, rights, scope, budget, or retention drift and restore the previous client configuration. 4. Promote dependency or retry changes only after owner approval; remove temporary assets and retain a redacted receipt. Output Produce an SDK receipt with version, environment, test classification, retry/idempotency result, aggregate task outcome, policy/rights/budget checks, draft-only assertion, approver, and cleanup/rollback reference. Exclude prompts, assets, identities, and secrets. Error Handling Condition Response --- --- Retry creates duplicate work Cancel duplicate tasks, preserve only aggregate redacted evidence, and enforce idempotency before retrying. Policy, rights, budget, or retention drift Stop the canary, remove drafts, and restore the approved SDK configuration. Examples sdk=pinned; env=ci-sandbox; retry=bounded; idempotency=pass; policy=pass; destination=draft-only; cleanup=verified is an acceptable pattern test. Resources Kling AI Developer Portal API Overview

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills jeremylongshore/klingai-sdk-patterns

View the source on GitHub

Browse the @skills marketplace