# Seedance 2.5 Video API

Base URL: `https://<your-gateway>/v1`

The gateway sends each registered user's request to the Seedance 2.5 tool discovered from that user's own Higgsfield MCP authorization. The platform balance limits the number of accepted generation tasks; each accepted task reserves one count, and video duration does not change that count. Higgsfield separately enforces the authorized account's own available free seconds. The server never stores prompt text, image/video/audio contents, or generated video files for these user-owned MCP requests.

## Authentication

```http
Authorization: Bearer hfp_...
Content-Type: application/json
```

Obtain the API key from the account portal after registration. The full key is shown once. The database stores only its SHA-256 hash. Resetting the key immediately disables the former key.

## Create a video

`POST /v1/videos`

```json
{
  "model": "seedance-2.5",
  "prompt": "A red kite passes above a quiet mountain lake at sunrise.",
  "seconds": 8,
  "size": "1280x720",
  "enable_audio": true,
  "reference_images": [
    {"image_url": "https://assets.example.net/first-frame.jpg"}
  ]
}
```

Use `Idempotency-Key` to make a retry safe. Accepted durations are 4-30 integer seconds. Supported sizes include 480p, 720p, and 1080p in 16:9, 9:16, 4:3, 3:4, and 1:1. `reference_images`, `reference_videos`, and `reference_audios` accept public HTTPS URLs; the single `first_frame`/`last_frame` mode cannot be mixed with ordinary references. Inline image/video/audio data URLs are accepted within the request limits and are forwarded directly to Higgsfield MCP without disk persistence.

The platform reserves one generation count before accepting each task. On confirmed success, that count is consumed. A definite generation failure releases it, so failed tasks do not use a count. An ambiguous submission keeps its count reserved until reviewed; the gateway never repeats an ambiguous generation automatically. Video duration is a generation parameter and does not change the platform count charged. Higgsfield's own free seconds remain subject to the user's connected account and the upstream service.

The platform does not accept billing-mode overrides, unlimited billing, or a different account. The MCP-connected Higgsfield account is the upstream identity.

## Response and polling

```json
{
  "id": "hfvid_0123456789abcdef0123456789abcdef",
  "object": "video",
  "model": "seedance-2.5",
  "status": "queued",
  "seconds": 8,
  "size": "1280x720",
  "actual_seconds": null,
  "charged_count": null
}
```

Poll `GET /v1/videos/{id}` with the same API key. A completed task returns `status: completed`, optional `actual_seconds`, `charged_count: 1`, and `output_url`, the HTTPS URL returned by Higgsfield. The result is not downloaded or proxied by this server. Its expiration and availability are controlled by Higgsfield.

Typical states are `queued`, `in_progress`, `completed`, `failed`, and `needs_review`. `needs_review` means the upstream result could not be determined; its generation count remains reserved to prevent accidental double charging or duplicate generation.

## Errors

Errors use the form `{"error":{"code":"...","message":"..."}}`. Common HTTP statuses: `400` invalid request, `401` invalid key, `402` insufficient generation count, `409` MCP not connected or request conflict, `413` oversized request, `429` rate limited, and `503` no connected MCP tool/account available.

## Higgsfield OAuth

Register and sign in at `/portal`; administrators sign in at `/admin`. Users connect their own Higgsfield account from the portal. OAuth uses Authorization Code + PKCE (S256). The gateway discovers the authorized account's MCP tools and enables generation only when it finds a tool explicitly identified as Seedance 2.5 or whose model schema offers Seedance 2.5, and whose input explicitly selects free/gift generation seconds. If that billing selector is unavailable, the gateway rejects the request before submission; it never assumes a paid or default mode.

For production, configure these environment variables before starting the service:

| Variable | Purpose |
| --- | --- |
| `HFP_PUBLIC_BASE_URL` | Public HTTPS origin used as the OAuth client ID and callback base. The callback is `/auth/mcp/callback`. |
| `HFP_ADMIN_USERNAME`, `HFP_ADMIN_PASSWORD` | Initial administrator credentials, inserted as a password hash only when the database has no administrator. Without both values, administrator login is disabled. Change the password from `/admin`; future restarts do not replace the stored password. |
| `HFP_MCP_TOKEN_KEY` | Stable Fernet key used to encrypt OAuth tokens, PKCE verifiers, and returned upstream video links in SQLite. |

Generate an encryption key with `python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"`, then store it in the server's secret environment configuration. Back it up securely: changing or losing it requires users to reconnect their Higgsfield accounts. Never commit these values. Put the API service behind an HTTPS reverse proxy; the bundled Compose ports remain bound to localhost by default.

The service keeps account credentials encrypted and video status/count ledger in SQLite. User prompts, submitted media, and client idempotency values exist only in process memory while they are sent upstream; the database stores an HMAC digest for request deduplication. Generated video bytes are never downloaded. The encrypted upstream link is retained so the owner can poll the completed task later. Existing legacy task history is not automatically changed by this feature. Administrator recharge requests require an `Idempotency-Key`; retries of the same request cannot credit counts twice.
