KLingAI API Key
The KLingAI 'API Key' node that's secretly a JWT mint
- api_token
Every workflow in this pack starts here, so if you're just getting oriented, this is the node to understand first. The whole ComfyUI-JM-KLing-API pack is a wrapper around the Kling AI API - Kuaishou's closed video model, the one the community rates around Wan 2.2 master quality but that you can't download. You rent it per generation. And to rent it, you need this node, because Kling doesn't accept a plain API token in the header.
The display name says "API Key," which is a small lie. You don't paste a token into this node. You paste two things - access_key and secret_key - that you grab from the Kling AI developer console (app.klingai.com), and the node mints the token for you. Every time it runs, actually. It builds a fresh JWT signed with your secret, valid for 24 hours, using PyJWT. That's the whole mechanism: an HS256 JWT with your access key as the issuer (iss), an expiry 24 hours out, and a 5-second buffer so it's valid the instant it's created.
What that means in practice: you never manually refresh anything. The node's IS_CHANGED always returns the current time, so ComfyUI re-executes it on every queue run and hands you a fresh token. Set it up once, forget it.
The only two inputs
- access_key (required) - your Kling AI access key, a plain string.
- secret_key (required) - the matching secret. Treat it like a password; it's the thing that signs your tokens.
Both are just text fields with no dropdowns or sliders to trip over. Paste, run, done.
The output
api_token (STRING) is the one output, and it's the required first input of literally every other node in this pack - text2video, image2video, query-status, all of them. Wire it in once and route it to every generation and status node in your graph. You'll be dragging a lot of those thin token wires around, which is a little ugly, but it's also exactly what makes the pack so self-contained: no extra API-key storage node, no environment variable to configure, just wires.
Installing it
The node comes with the pack, so there's nothing special to fetch:
cd ComfyUI/custom_nodes
git clone https://github.com/synthetai/ComfyUI-JM-KLing-API
cd ComfyUI-JM-KLing-API
pip install -r requirements.txt
That requirements.txt is short - PyJWT, requests, pydub - and PyJWT is the one this node needs. Install via ComfyUI Manager instead (search "ComfyUI-JM-KLing-API") and the dependencies are handled for you. Then restart ComfyUI.
Where people get burned
- Blank keys. Leave either field empty and the node prints
Access Key and Secret Key are requiredto the console and returnsNone. There's no red error bubble - watch the terminal. - Wrong keys. The access/secret pair is from the developer console, not the login you use to browse the Kling web app. If your generation tasks all come back 401, that's what you've mixed up.
- Missing PyJWT. If the node errors with an import failure, the requirements never got installed.
pip install PyJWTfixes it instantly.
One more honest note: this pack is small and lightly maintained, and it's built around Kling's token scheme. If Kling ever changes that auth flow, this node is the first thing to break. But for now it's the boring, essential foundation everything else sits on.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| access_key | STRING | — | |
| secret_key | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| api_token | STRING | — |