# API reference

Moteur API generates videos and images. There are two flavours of the API; both use the same key:

| Flavour | Base URL | Best for |
|---|---|---|
| **Seedance style** (recommended) | `https://api.usehooo.com/api/v3` | Your own code. If you have used Volcengine Ark / BytePlus Seedance, just change the base URL and key |
| OpenAI-compatible | `https://api.usehooo.com/v1` | The official OpenAI SDK, and apps with an “OpenAI-compatible” option such as Dify or n8n |

Plain-text versions for AI assistants and the command line: [/docs.en.md](https://api.usehooo.com/docs.en.md) (English), [/docs.md](https://api.usehooo.com/docs.md) (Chinese), index at [/llms.txt](https://api.usehooo.com/llms.txt).

The request and response examples in this document are checked against the live API by automated tests.

## Before you start (three steps)

1. Open [api.usehooo.com](https://api.usehooo.com) and sign in with an email code or Google (your account is created on first sign-in).
2. Console → **API keys** → **New key**. **The key is shown only once** — copy it right away.
3. Console → **Redeem**, enter a redeem code to top up. Your balance is shown on the console overview.

| Model | What it does | Price (standard tier) |
|---|---|---|
| `muse-video` | Video from text, from one first-frame image, or from a few reference images. 2 to 10 seconds (default 5), 720p, usually with sound | ¥0.05 per second of actual output |
| `muse-image` | Image from text, optionally with reference images | ¥0.10 per image |

Every request carries the key in a header:

```
Authorization: Bearer your-key
```

## 1. Quick start

Put your key in an environment variable:

```bash
export API_KEY="your-key"
```

**Make a video**: submit a task → poll every 5 seconds → get the video URL. A video usually takes 1–3 minutes.

```bash
# 1. Submit; returns the task id {"id": "vid_…"}
curl https://api.usehooo.com/api/v3/contents/generations/tasks \
  -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" \
  -d '{"model": "muse-video", "content": [{"type": "text", "text": "An orange kitten walking slowly across the grass"}], "ratio": "16:9", "duration": 5}'

# 2. Poll (replace vid_… with the id from step 1) until status is succeeded or failed
curl https://api.usehooo.com/api/v3/contents/generations/tasks/vid_… -H "Authorization: Bearer $API_KEY"
# → {"status": "succeeded", "content": {"video_url": "https://api.usehooo.com/media/videos/vid_….mp4"}, "cost": {"amount": "0.25", …}, …}
```

**Make an image**: one request returns the image URL, usually within 30 seconds to 2 minutes. After 90 seconds you get a 504 first — **send the same request again** and it keeps waiting on the same image, with no double charge (see section 3).

```bash
curl https://api.usehooo.com/api/v3/images/generations \
  -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" \
  -d '{"model": "muse-image", "prompt": "A cute kitten sunbathing by the window", "size": "1024x1024"}'
# → {"data": [{"url": "https://api.usehooo.com/media/images/img_….webp"}], "cost": {"amount": "0.10", …}, …}
```

**Complete Python example** (only needs `pip install requests`):

```python
import os, time, requests

BASE = "https://api.usehooo.com/api/v3"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

# Video: submit → poll → download
task_id = requests.post(f"{BASE}/contents/generations/tasks", headers=HEADERS, json={
    "model": "muse-video",
    "content": [{"type": "text", "text": "An orange kitten walking slowly across the grass"}],
    "ratio": "16:9", "duration": 5,
}).json()["id"]
while True:
    task = requests.get(f"{BASE}/contents/generations/tasks/{task_id}", headers=HEADERS).json()
    if task["status"] not in ("queued", "running"):
        break
    time.sleep(5)
if task["status"] == "succeeded":
    with open("video.mp4", "wb") as f:
        f.write(requests.get(task["content"]["video_url"]).content)
    print("Saved, cost", task["cost"]["amount"], "CNY")
else:
    print("Failed:", task["error"]["message"])

# Image: one request; after 90 s you get a 504 — resend the same body to keep waiting on the same image (no double charge)
body = {"model": "muse-image", "prompt": "A cute kitten sunbathing by the window", "size": "1024x1024"}
for _ in range(3):
    r = requests.post(f"{BASE}/images/generations", headers=HEADERS, json=body, timeout=120)
    if r.status_code != 504:
        break
print(r.json()["data"][0]["url"] if r.ok else r.json()["error"])
```

Video and image URLs can be downloaded **without a key**. **They are kept for 7 days (7 × 24 hours), then deleted automatically and can't be recovered — download what you need.** `expires_at` in the response is the deletion time (Unix seconds).

## 2. Video

### 2.1 Create a task `POST /api/v3/contents/generations/tasks`

```json
{
  "model": "muse-video",
  "content": [{"type": "text", "text": "An orange kitten walking slowly across the grass"}],
  "ratio": "16:9",
  "duration": 5
}
```

Response: `{"id": "vid_0123456789abcdefghjkmnpqrs"}`

| Field | Required | Notes |
|---|---|---|
| `model` | yes | `muse-video` |
| `content` | yes | Array. Must contain `{"type": "text", "text": "description"}`; may also contain images, see below |
| `ratio` | no | `16:9`, `9:16`, or `adaptive` (default — the model decides) |
| `duration` | no | Seconds: an integer from 2 to 10; omitted or `-1` means 5 |
| `resolution` | no | Only `720p` (default) |

**Output**: MP4 (H.264), 720p, 24 fps, usually with sound. `16:9` is 1280×720, `9:16` is 720×1280.

Images in `content`: a public `http(s)` URL or `data:image/png;base64,…` (PNG, JPG or WebP; up to 40 MB each, 60 MB for the whole request). Match the video's aspect ratio, otherwise the picture is cropped:

| Item | Meaning |
|---|---|
| `{"type": "image_url", "image_url": {"url": "…"}, "role": "first_frame"}` | First frame: the video starts from this image. At most one; with a single image `role` may be omitted |
| `{"type": "image_url", "image_url": {"url": "…"}, "role": "reference_image"}` | Reference images, up to 4; cannot be mixed with a first frame. The model uses **the first one as the opening shot** and the rest as references for people, scene and style; a single reference image behaves like a first frame |

Parameters may also be appended to the description (Seedance's older style): `"a kitten --rt 9:16 --dur 8"`. `--rt` is the ratio, `--dur` the duration, `--rs` the resolution. When both are given, the body fields win.

On submit we hold “10 seconds (the maximum) × unit price”; after the video is made we settle on the actual seconds and release the rest. You may send an `Idempotency-Key` header, see section 6.

### 2.2 Get a task `GET /api/v3/contents/generations/tasks/{id}`

```json
{
  "id": "vid_0123456789abcdefghjkmnpqrs",
  "model": "muse-video",
  "status": "succeeded",
  "content": {"video_url": "https://api.usehooo.com/media/videos/vid_0123456789abcdefghjkmnpqrs.mp4"},
  "error": null,
  "created_at": 1795756368,
  "updated_at": 1795756470,
  "ratio": "16:9",
  "resolution": "720p",
  "duration": 5,
  "framespersecond": 24,
  "generate_audio": true,
  "service_tier": "default",
  "cost": {"amount": "0.25", "currency": "CNY"},
  "billed_seconds": 5,
  "duration_seconds": 5.04,
  "expires_at": 1796361270
}
```

| `status` | Meaning |
|---|---|
| `queued` | Waiting |
| `running` | Generating |
| `succeeded` | Done; `content.video_url` is the video |
| `failed` | Failed; reason in `error`; not charged |
| `cancelled` | You cancelled it; not charged |
| `expired` | No video within 30 minutes; not charged |

`cost` is what the task cost (CNY), `billed_seconds` the seconds charged, `duration_seconds` the actual length. `content` is `null` until the task succeeds. A failed task looks like:

```json
{
  "id": "vid_0123456789abcdefghjkmnpqrs",
  "model": "muse-video",
  "status": "failed",
  "content": null,
  "error": {"code": "upstream_failed", "message": "生成失败，本次未扣费"},
  "cost": {"amount": "0.00", "currency": "CNY"}
}
```

Failure codes (`error.code`): `upstream_failed`, `upstream_rejected` (content or parameters refused, e.g. a real person's face in a reference image), `timeout` (status `expired`), `cancelled` (status `cancelled`), `upstream_lost` / `submit_lost` / `finalize_failed` (our side), `admin_force` (cancelled manually). **None of these are charged.** Messages are in Chinese.

### 2.3 List tasks `GET /api/v3/contents/generations/tasks`

Query parameters: `page_num` (default 1), `page_size` (default 20, max 100), `filter.status` (one of the statuses above), `filter.task_ids` (repeatable), `filter.model`. Newest first. Response: `{"items": [...], "total": 1}`, where each item is the same as the get response.

### 2.4 Cancel a task `DELETE /api/v3/contents/generations/tasks/{id}`

A queued or running task is cancelled, the hold is released in full and the status becomes `cancelled`. Finished tasks are not actually deleted (we keep them for accounting); the call simply succeeds.

## 3. Images

### `POST /api/v3/images/generations`

```json
{
  "model": "muse-image",
  "prompt": "A cute kitten sunbathing by the window",
  "size": "1024x1024"
}
```

```json
{
  "model": "muse-image",
  "created": 1795756368,
  "data": [{"url": "https://api.usehooo.com/media/images/img_0123456789abcdefghjkmnpqrs.webp"}],
  "usage": {"generated_images": 1, "output_tokens": 0, "total_tokens": 0},
  "task_id": "img_0123456789abcdefghjkmnpqrs",
  "cost": {"amount": "0.10", "currency": "CNY"},
  "expires_at": 1796361268
}
```

| Field | Required | Notes |
|---|---|---|
| `model` | yes | `muse-image` |
| `prompt` | yes | Description |
| `size` | no | Ratio `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, or width×height such as `1024x1536` (mapped to the nearest ratio); `2K` and similar mean no particular ratio |
| `image` | no | Reference image(s): a URL (or `data:image/…;base64,…`), or an array of up to 10 |

Images are WebP, one per request. **Each ratio has a fixed size; the pixels you write are not used** (`1024x1024` gives you 1600×1600):

| Ratio | Size (W×H) |
|---|---|
| `1:1` | 1600×1600 |
| `16:9` | 2048×1152 |
| `9:16` | 1152×2048 |
| `4:3` | 1792×1344 |
| `3:4` | 1344×1792 |
| not set | chosen by the model (we have seen 1920×1280) |

 You may send an `Idempotency-Key` header (section 6).

**An image usually takes 30 seconds to 2 minutes; this endpoint waits up to 90 seconds:**

- **Ready**: returns the body above and charges one image.
- **Failed**: returns 502 with `task_id` in `error`; not charged.
- **Not ready after 90 seconds**: returns 504 with `error.code = "generation_pending"` and `task_id`. The task keeps running:
  - **resend the same request** (same key, identical body): it keeps waiting on the same task and returns the image when ready; you are charged once;
  - or fetch it with `GET /v1/images/tasks/{task_id}`;
  - **if nobody picks it up within 10 minutes, the task is cancelled and not charged** (an image that was already made is discarded).

Once you have received the image, the same request makes a new one; two identical requests waiting at the same time also get one image each.

This endpoint is synchronous only. To avoid holding the connection, use `"async": true` on `/v1/images/generations` (section 4). Both create the same kind of image task; any image task id can be fetched with `GET /v1/images/tasks/{id}` (statuses in section 4).

## 4. OpenAI-compatible API (`/v1`)

The image endpoint matches OpenAI's `/v1/images/generations`: use the official OpenAI SDK, or fill it into Dify, n8n, LobeHub, FastGPT or any app with an “OpenAI-compatible” option.

| Field in the app | Value |
|---|---|
| Base URL | `https://api.usehooo.com/v1` (some apps want `https://api.usehooo.com` and add `/v1` themselves) |
| API key | Your key |
| Model | `muse-image` (these apps usually use it for images only; for video, call section 2 from the app's HTTP request node) |

```python
from openai import OpenAI

client = OpenAI(base_url="https://api.usehooo.com/v1", api_key="your-key", timeout=300)
image = client.images.generate(model="muse-image", prompt="A cat", size="1024x1024")
print(image.data[0].url)
```

On a 504 the SDK retries after 1 second; the retry keeps waiting on the same task and you are charged once. The default 2 retries cover about 4½ minutes. If an app times out, generate again with the same input.

### `POST /v1/images/generations`

Fields: `model`, `prompt`, `size` (as in section 3), `images` (array of reference images; `image` also works), `async`. Response:

```json
{
  "created": 1795756368,
  "data": [{"url": "https://api.usehooo.com/media/images/img_0123456789abcdefghjkmnpqrs.webp"}],
  "task_id": "img_0123456789abcdefghjkmnpqrs",
  "cost": {"amount": "0.10", "currency": "CNY"}
}
```

Waiting, 504, resend and the 10-minute auto-cancel work as in section 3. To avoid holding the connection, send `"async": true` to get **HTTP 202** and a task id straight away (`{"id": "img_…", "object": "image.task", "status": "processing", …}`), then poll every 5 seconds:

### `GET /v1/images/tasks/{id}`

```json
{
  "id": "img_0123456789abcdefghjkmnpqrs",
  "object": "image.task",
  "status": "completed",
  "model": "muse-image",
  "created_at": 1795756368,
  "url": "https://api.usehooo.com/media/images/img_0123456789abcdefghjkmnpqrs.webp",
  "error": null,
  "cost": {"amount": "0.10", "currency": "CNY"},
  "data": [{"url": "https://api.usehooo.com/media/images/img_0123456789abcdefghjkmnpqrs.webp"}]
}
```

Image task `status`: `queued`, `processing`, `completed` (`url` is the image), `failed` (not charged), `refunded` (refunded by support after delivery; the image remains). Note these differ from the video statuses in section 2.2. Failure codes as in section 2.2, plus `not_collected`: a synchronous request ended before the image was ready and nobody picked it up within 10 minutes.

### `POST /v1/images/edits` (upload reference files)

```bash
curl https://api.usehooo.com/v1/images/edits \
  -H "Authorization: Bearer $API_KEY" \
  -F model=muse-image -F prompt="Change the background to a beach" -F image=@photo.png
```

`image` may repeat, up to 10 files, 60 MB in total. The response is the same as `/v1/images/generations`.

### `POST /v1/videos`, `GET /v1/videos/{id}`

The earlier video endpoints still work: fields `model`, `prompt`, `duration`, `aspect_ratio`, `images`; statuses `queued`, `processing`, `completed`, `failed`; the video URL is in `url`. New projects should use section 2.

## 5. Coming from Seedance? Just change the base URL

The official Volcengine Ark / BytePlus SDK works as-is — change only the base URL, key and model names:

```python
# pip install volcengine-ark-runtime
import time
from volcenginesdkarkruntime import Ark

client = Ark(base_url="https://api.usehooo.com/api/v3", api_key="your-key")

task = client.content_generation.tasks.create(
    model="muse-video",
    content=[{"type": "text", "text": "An orange kitten walking slowly across the grass --rt 16:9 --dur 5"}],
)
while (t := client.content_generation.tasks.get(task_id=task.id)).status in ("queued", "running"):
    time.sleep(5)
print(t.status, t.content.video_url if t.content else t.error)

image = client.images.generate(model="muse-image", prompt="A kitten", size="1024x1024")
print(image.data[0].url)
```

Differences from Seedance:

| Seedance | Here |
|---|---|
| Model names | `muse-video`, `muse-image` |
| `ratio` | Only `16:9`, `9:16`, `adaptive` |
| `duration` | 2 to 10 seconds (omitted or `-1` means 5) |
| `resolution` | Only `720p` |
| Last frame (`last_frame`), video / audio references, `asset://` | Not supported — 400 `unsupported_parameter` |
| `callback_url`, `return_last_frame`, `seed`, `camera_fixed`, `draft`, `frames` | Not supported — 400 `unsupported_parameter` |
| `generate_audio` | Videos always have sound (`false` returns 400) |
| `watermark`, `priority`, `execution_expires_after`, `safety_identifier` | Ignored (we never add a watermark) |
| Video URL valid 24 hours | 7 days (see `expires_at`), then deleted |
| Billed by tokens (`usage`) | Video per second, image per picture — see `cost` |
| Deleting a finished task | Succeeds, but the record is kept for accounting |

## 6. Account, billing, idempotency

### `GET /v1/account`

```json
{
  "object": "account",
  "currency": "CNY",
  "balance": "10.00",
  "frozen": "0.00",
  "pricing_tier": "standard"
}
```

`balance` is available funds, `frozen` is held for tasks in progress, `pricing_tier` is your tier (`standard`, `member`, `vip`). Amounts are strings in CNY, to the cent.

### `GET /v1/models`

Lists the models you can use with prices for your tier (`pricing.billing_mode` is `per_second` for video, `per_request` for images; `pricing.unit_price` in CNY).

### Billing

| Type | Rule |
|---|---|
| Video | Actual output seconds: `billed = min(requested, max(1, ceil(actual − 0.3)))`. 5.04 s bills as 5. Longer output is trimmed to what you asked for; you never pay for more than the seconds you requested |
| Image | Per image, only on success |

- **Hold first, settle later**: a hold is placed before each task (longest duration for video, one image for images); after the task the actual cost is settled and the rest released at once. If the balance can't cover the hold you get 402.
- **Failed, cancelled and expired tasks are free**; the hold is released in full.
- There are three price tiers (standard, member, vip); your prices are in `/v1/models`. A unit price may have 3 decimals (e.g. ¥0.042 per second); each charge is quantity × unit price rounded to the cent (7 s × 0.042 = 0.294 → ¥0.29).

### Idempotency keys

Send `Idempotency-Key: your-unique-id` when submitting a video or an image (on either API flavour). The same id with the same parameters returns the original task — no duplicate generation, no double charge. The same id with different parameters returns 409 `idempotency_conflict`. If you're unsure whether a submission went through, resend with the same id.

## 7. Rate limits

| Limit | Default | When exceeded |
|---|---|---|
| Requests per minute per key | 60 | 429 `rate_limit_exceeded` |
| Concurrent requests per key | 3 | 429 `concurrency_limit_exceeded` |
| Concurrent requests per account | 10 | 429 `user_concurrency_limit_exceeded` |
| Video tasks in progress per account | 2 | 429 `too_many_tasks` |
| Image tasks in progress per account | 4 | 429 `too_many_tasks` |
| Site-wide queue full | — | 429 `capacity_full`; try again shortly |

429s are never charged; the `Retry-After` header says how many seconds to wait. Get, list, account and model calls don't count toward the per-minute limit.

## 8. Errors

Every error has the same shape:

```json
{
  "error": {
    "type": "billing_error",
    "code": "insufficient_balance",
    "message": "余额不足，请充值后重试"
  }
}
```

| Status | `code` | Meaning |
|---|---|---|
| 400 | `model_required`, `content_required`, `prompt_required`, `invalid_parameter`, `invalid_duration`, `invalid_json`, `invalid_n` | Bad parameters; `message` says what is wrong |
| 400 | `unsupported_parameter` | This parameter or value isn't supported (see section 5) |
| 400 | `upstream_rejected`, `content_policy_violation` | Content or parameters refused. Repeated violations get the key blocked |
| 401 | `invalid_api_key` | Wrong or disabled key |
| 402 | `insufficient_balance` | Not enough balance |
| 403 | `key_risk_blocked`, `account_suspended`, `account_frozen`, `model_not_allowed` | Key blocked, account suspended or frozen, or this key may not use the model |
| 404 | `model_not_found`, `task_not_found` | No such model or task |
| 409 | `idempotency_conflict` | Idempotency key reused with different parameters |
| 413 | `request_too_large` | Body too large (60 MB with reference images) |
| 429 | see section 7 | Rate limited |
| 502 | `upstream_failed`, `upstream_unavailable`, … | Generation failed or upstream unavailable; not charged; you may retry |
| 504 | `generation_pending` | Image not ready yet; see section 3 |
| 500 | `internal_error` | Our fault; not charged |

Error messages are in Chinese; rely on `code`.

## 9. FAQ

**How long are videos kept?** 7 days (7 × 24 hours); the URL needs no key. They are then deleted and can't be recovered, so download them in time; `expires_at` in the response is the deletion time.

**I asked for 5 seconds — can I be charged for more?** No. Longer output is trimmed to 5 seconds; shorter output is billed by its actual length.

**My connection dropped after submitting — did it go through?** Resend with the same `Idempotency-Key`, or check the task list.

**Part of my balance is frozen.** Tasks in progress hold some money; it is settled automatically when they finish and the rest is released.

**The image endpoint returned 504 after a long wait.** The task is still running. Resend the same request (it keeps waiting on the same task, no double charge) or fetch it by `task_id`. If nobody picks it up within 10 minutes it is cancelled and not charged.

**How do I top up? Who do I contact?** Until online payment opens, top up with a redeem code. To buy codes, ask about volume pricing, or get help with integration or incidents, reach us at https://api.usehooo.com/contact (Telegram / WeChat). Please include your account email and the task id.
