> ## 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 unit deductions to Costory with a Bearer API key. Import video-generation spend into Explorer next to AWS, GCP, and Azure.

Kling Open Platform usage lands on its own invoice. Connect with an **Open Platform API key** so unit deductions show up in <Tooltip tip="Costory's main interface for exploring cloud costs across all connected providers." cta="See Glossary" href="/docs/glossary#cost-explorer">Explorer</Tooltip> with your other [billing datasources](/setup/billing).

This connector imports **Unit Deduction Detail** from the Kling developer console. Costory stores it as a billing datasource, the same as other SaaS billing sources.

<Info>
  Spend in Explorer is the **list** rate (`$0.14` times units), not the discounted pack-tier invoice. Wallet PAYG balance is not on this connector.
</Info>

<Tabs>
  <Tab title="Manual setup">
    <Steps>
      <Step title="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.
      </Step>

      <Step title="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;
      </Step>

      <Step title="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.
      </Step>

      <Step title="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. If this is the only billing source and it is demo data, Costory asks you to confirm before replacing it.
      </Step>
    </Steps>

    On first sync, Costory backfills up to **12 months** of unit deductions, depending on what Kling retains. New data then follows the usual [data refresh](/docs/data-refresh) cadence. SaaS sources typically appear in about **10 minutes**.
  </Tab>

  <Tab title="Terraform">
    Not supported yet.
  </Tab>
</Tabs>

## 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 Unit Deduction Detail and maps it into <Tooltip tip="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)." cta="See Glossary" href="/docs/glossary#standard-columns">Standard Columns</Tooltip>.

Typical lines are billed Open Platform unit deductions for that account. Explorer dollars use the list rate (`$0.14` times units).

**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

**What Costory does not include**

* Pack-tier discounts or the invoice you pay after volume tiers
* Wallet PAYG balance (`/account/billing/balance`)
* Pack-name catalog (`/account/costs`)
* AccessKey + SecretKey JWT auth

<Info>
  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.
</Info>

## 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). 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 Kling invoice | Expected. Explorer uses list cash (`$0.14` times units), not the discounted pack-tier invoice.                                                                                                    |

## Related pages

<CardGroup cols={2}>
  <Card title="Billing Data" icon="database" href="/setup/billing">
    All billing providers and shared setup notes.
  </Card>

  <Card title="ElevenLabs billing" icon="microphone" href="/setup/billing/elevenlabs">
    Connect ElevenLabs workspace usage the same way.
  </Card>

  <Card title="OpenAI billing" icon="robot" href="/setup/billing/openai">
    Import OpenAI Platform organization costs.
  </Card>

  <Card title="Explorer" icon="chart-line" href="/features/cost-explorer">
    Filter and group Kling spend with the rest of your stack.
  </Card>
</CardGroup>
