> ## Documentation Index
> Fetch the complete documentation index at: https://docs.costory.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Kling AI Billing Setup

> Connect Kling AI Open Platform pack usage and wallet charges to Costory with a Bearer API key, and see video-generation spend in Explorer.

Kling Open Platform usage lands on its own invoice. Connect with an **Open Platform API key** so pack usage and wallet charges show up in Explorer (Costory's main interface for exploring cloud costs across all connected providers.) with your other [billing datasources](https://docs.costory.io/setup/billing).

This connector imports both Kling deduction ledgers. Costory stores them as one billing datasource, the same as other SaaS billing sources.

> [!NOTE]
>
> Prepaid pack lines use the **list** rate (`$0.14` times units). Wallet lines use the cash Kling deducted (`deduction_amount`), with `list_price` kept as the pre-discount amount. A task is on one ledger only, so the two are not added together.

> [tab] Manual setup
>
> **1. Create an Open Platform API key**
>
> In the [Kling AI developer console](https://app.klingai.com/global/dev), create an **Open Platform API key**. Copy it immediately. It is shown once.
>
> Do **not** use AccessKey + SecretKey (JWT). Costory sends `Authorization: Bearer`. See Kling's [Get started](https://kling.ai/document-api/guides/get-started/quick-start) guide for key creation.
>
> **2. Connect in Costory**
>
> Go to [Integrations](https://app.costory.io/integration), click **+ Add integration**, then choose **Kling AI** under **Billing**. The connect URL is `/integration/new/kling-ai/billing`.&#x20;
>
> **3. Enter connection details**
>
> Fill **Connection name** (default **Kling AI**) and **API key**.
>
> **Region** is optional. Leave it on **Singapore** (`api-singapore.klingai.com`) unless this account lives on Beijing (`api-beijing.klingai.com`). The wrong region looks like a bad key.
>
> **Start date** is optional. Leave it empty to use Costory's default lookback.
>
> **4. Validate, then save**
>
> Click **Validate**. Costory calls Kling [Unit Deduction Detail](https://kling.ai/document-api/api/assets/billing-deduction/package) with `Authorization: Bearer`. **Save** stays disabled until the key can read unit deductions. An empty deduction window is still success. After save, each sync also reads [Balance Deduction Detail](https://kling.ai/document-api/api/assets/billing-deduction/balance) with the same key. If this is the only billing source and it is demo data, Costory asks you to confirm before replacing it.
>
> On first sync, Costory backfills up to **12 months** of pack and wallet deductions, depending on what Kling retains. New data then follows the usual [data refresh](https://docs.costory.io/docs/data-refresh.md) cadence. SaaS sources typically appear in about **10 minutes**.

> [tab] Terraform
>
> Not supported yet.

## Field reference

| Field | Required | Description |
| - | - | - |
| **Connection name** | Yes | Label in **Integrations**. |
| **API key** | Yes | Open Platform key from the developer console. Stored in Costory's secret manager. |
| **Region** | No | **Singapore** (default) or **Beijing**. Beijing is only needed for China-region keys. |
| **Start date** | No | Optional start of the first sync. Leave empty for the default lookback. |

## What Costory includes

Costory pulls both deduction APIs and maps them into Standard Columns (Costory's unified billing schema: the same dimensions everywhere (Provider, Billing account id, Service name, SKU ID, Region, Category, and more). In SQL and exports, column names use a cos\_ prefix (for example cos\_service\_name).).

| Ledger | Kling API | Explorer dollars |
| - | - | - |
| Prepaid resource packs | [Unit Deduction Detail](https://kling.ai/document-api/api/assets/billing-deduction/package) | List rate: `$0.14` times units. Kling does not return a pack price on this API. |
| Wallet and test balance | [Balance Deduction Detail](https://kling.ai/document-api/api/assets/billing-deduction/balance) | Charged cash (`deduction_amount`). `list_price` is the amount before discount. `currency` is USD or CNY. |

CNY wallet charges are converted to USD with Costory's monthly exchange rate. The original yuan amount is kept on the line.

**How to analyze Kling AI costs**

* Spend over time: use the same date presets as other billing sources in Explorer
* Spend by product or SKU: group by **Service name** or **SKU** when those fields are populated from the deduction export
* Pack usage vs wallet charges: filter the **ledger** label (`package` or `balance`)

**What Costory does not include**

* The price paid to buy a prepaid pack (pack-tier and volume discounts)
* Pack-name catalog (`/account/costs`)
* AccessKey + SecretKey JWT auth

> [!NOTE]
>
> Rotate the API key from **Integrations** when you need a new credential. The stored region stays the same. A Singapore to Beijing move is a different console and key: create a new datasource.

## Troubleshooting

| Issue | What to check |
| - | - |
| Failed to authenticate | Paste an **Open Platform API key**, not AccessKey + SecretKey. Confirm **Region** matches the console that issued the key (Singapore vs Beijing). |
| Access denied | Confirm the key can read [Unit Deduction Detail](https://kling.ai/document-api/api/assets/billing-deduction/package) and [Balance Deduction Detail](https://kling.ai/document-api/api/assets/billing-deduction/balance). Recreate it in the [developer console](https://app.klingai.com/global/dev). |
| Unit Deduction Detail endpoint not found | Confirm the key and region. Singapore uses `api-singapore.klingai.com`. Beijing uses `api-beijing.klingai.com`. |
| Validation succeeds but Explorer is empty | Wait for the first sync (about 10 minutes). Check the datasource date range on [Integrations](https://app.costory.io/integration). New Open Platform accounts can have no deductions yet. |
| Explorer dollars do not match the pack invoice | Expected for prepaid packs. Explorer uses list cash (`$0.14` times units). Kling does not return the price paid for the pack. Wallet lines should match the charged `deduction_amount` (CNY converted to USD). |

## Related pages

> [card] [Billing Data](https://docs.costory.io/setup/billing)
>
> All billing providers and shared setup notes.

> [card] [ElevenLabs billing](https://docs.costory.io/setup/billing/elevenlabs.md)
>
> Connect ElevenLabs workspace usage the same way.

> [card] [BytePlus billing](https://docs.costory.io/setup/billing/byteplus.md)
>
> Import BytePlus account bill details, including Seedance.

> [card] [OpenAI billing](https://docs.costory.io/setup/billing/openai.md)
>
> Import OpenAI Platform organization costs.

> [card] [Explorer](https://docs.costory.io/features/cost-explorer.md)
>
> Filter and group Kling spend with the rest of your stack.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.