# LingDong API Developer Documentation

LingDong API provides REST/JSON endpoints for AI image and video generation. It uses Bearer token authentication and provides asynchronous video task queries, signed webhooks, result downloads, and machine-readable model capabilities and pricing.

- Website and base URL: https://www.lingdongapi.com
- Quickstart: https://www.lingdongapi.com/docs/en/quickstart.md
- OpenAPI 3.1: https://www.lingdongapi.com/openapi.json
- Public model catalog: https://www.lingdongapi.com/api/pricing
- Chinese documentation: https://www.lingdongapi.com/docs/api/

LingDong API is an independent service platform and does not represent the original vendors of the models it exposes. Model availability, limits, pricing, billing, and refunds are subject to current platform responses and published terms. Do not describe it as an official service of Codex, OpenAI, or any model vendor without separate verifiable evidence.

## Before integrating

Read `GET /api/pricing` and select a model that is currently callable. Check:

- `callable` and `group_name`;
- `billing_unit` (`request`, `second`, or `token`);
- `supported_duration`, `supported_ratios`, and `supported_resolutions`;
- reference image, video, and audio limits;
- `notes` for model-specific conditions;
- `pricing_version` for change detection.

Do not hard-code prices or assume that a model shown in an old article is still available.

## Authentication

```http
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
```

Store the key in a server-side secret manager or the `LINGDONG_API_KEY` environment variable. Never expose it in browser code, public repositories, logs, screenshots, or chat messages.

## Public endpoints

| Operation | Method and path |
|---|---|
| Create a video task | `POST /v1/video/generations` |
| Query a video task | `GET /v1/video/generations/{task_id}` |
| Download a completed video | `GET /v1/videos/{task_id}/content` |
| Create an image request | `POST /v1/images/generations` |
| Query account balance | `GET /v1/dashboard/billing/balance` |
| Read public models and pricing | `GET /api/pricing` |

## Video task lifecycle

1. Send the create request once and retain the returned task ID.
2. Query the same task every 5–10 seconds, or receive a webhook.
3. Treat `processing` as still running, `completed` as ready, and `failed` as a terminal failure.
4. Download only after `completed`.

A create request may be billable. A timeout, network interruption, or unclear response does not prove that the server did not accept it. Do not automatically create another task; inspect the task history and account ledger first. Polling and downloading may be retried against the original task.

## Reference media

Use the `images`, `videos`, and `audios` arrays with publicly accessible URLs that require no login. Limits differ by model. Do not send local paths, `file://` URLs, or private-network addresses as though they were public media.

## Webhooks

When `notify_secret` is supplied, callback requests include:

- `X-Lingdong-Timestamp`
- `X-Lingdong-Delivery`
- `X-Lingdong-Signature: sha256=...`

Verify `HMAC-SHA256(timestamp + "." + raw_body)` using the raw request body and a constant-time comparison. Use the delivery ID for idempotency. Return a 2xx response within 10 seconds after safely accepting the event.

## Account balance

`GET /v1/dashboard/billing/balance` returns the owning account's available balance and cumulative usage. It does not represent the remaining quota of an individual API key. Do not cache the balance response.

## Support and updates

- Platform announcements: https://www.lingdongapi.com/about
- Frequently asked questions: https://www.lingdongapi.com/docs/en/faq.md
- Full Chinese reference: https://www.lingdongapi.com/docs/api/
