Topics

DocsDeveloper reference

SDKs and tools

The Kling packages for developers in Iceland. @klingis/sdk for your server, @klingis/embed for the browser and @klingis/mcp for AI agents.

Kling has three npm packages for your code, and @klingis/cli connects a project to Kling from the terminal. All of them work with test keys straight away.

Package What it is
@klingis/sdk Typed server SDK for the Kling API, generated from the OpenAPI spec
@klingis/embed The payment window: checkout as an overlay on your site
@klingis/mcp MCP server for AI agents, also hosted at https://api.kling.is/mcp

@klingis/sdk

bash
npm install @klingis/sdk
typescript
import { configure, postV1CheckoutSessions } from "@klingis/sdk";

configure({
  baseUrl: "https://api.kling.is",
  headers: {
    Authorization: `Bearer ${process.env.KLING_SECRET_KEY}`,
    "Content-Type": "application/json", // required, see below
  },
});

const res = await postV1CheckoutSessions(
  {
    amount: 5000, // 5.000 kr.
    currency: "ISK",
    success_url: "https://example.is/thanks",
  },
  { headers: { "Idempotency-Key": "order-1042" } },
);

if (res.status === 200) console.log(res.data.id, res.data.url);

Keep the Content-Type header in configure. The SDK does not send it by itself yet, and without it the API ignores the request body: a checkout fails with a 400, a PATCH changes nothing, and a partial refund (amount) refunds the full amount.

Function names follow the method and path: POST /v1/checkout/sessions is postV1CheckoutSessions, GET /v1/customers/{id} is getV1CustomersById. Each returns { data, status, headers }. A 200 from postV1PaymentIntents can still be a declined card: check res.data.status (see Declined payments). The SDK uses the global fetch and runs in Bun and in bundled server code (Next.js, Remix, SvelteKit, Vite). In plain Node ESM without a bundler, call the REST API with fetch instead.

@klingis/embed

bash
npm install @klingis/embed

Or <script src="https://api.kling.is/v1/kling.js"></script>. See Payment window.

@klingis/mcp

Lets AI agents such as Claude, ChatGPT and Cursor work with your Kling account: create checkouts, payment links, products and customers, and read payments, subscriptions and reports. Kling hosts it at https://api.kling.is/mcp, authenticated with a Kling API key as a bearer token; the package runs the same server on your own machine. In the dashboard, the Connect AI assistants card on the API Keys & Docs page has a ready link for Claude and ChatGPT.

View as markdown