# Stream a viral-video replication prompt

- API version: 1.11.0
- Last updated: 2026-11-16
- Server: `https://api.ailingtu.com`
- Web document: [Stream a viral-video replication prompt](/en/openapi/viral-replication)
- Full schema: [JSON Schema](/en/openapi/operations/streamViralVideoReplication.json)
- Discovery: [Operation index](/en/openapi/operations/index.json)

## POST /v1/material/analysisTask/stream

Operation ID: `streamViralVideoReplication`

Stream a reusable replication prompt from a public video URL or an uploaded file. Concatenate result from streaming events in order; if a done event arrives, use its result as the complete prompt.

Authentication: Request header `x-api-key: <YOUR_API_KEY>`; keep the key on the server and never expose it in client code, logs or shared files.

Success criteria: Decide success from the SSE events and concatenate the streaming chunks; use the complete result from the done event. On errors, check the HTTP status and message instead of JSON code=0.

### Request parameters

| Field | Location | Type | Required | Description |
|---|---|---|---|---|
| `type` | body | REPLICATION | Yes | Always send REPLICATION; ANALYSIS is reserved and not covered here |
| `url` | body | string(uri) | Conditional | Public video URL; send this or businessId. Supports TikTok, Douyin, Xiaohongshu, WeChat Channels, Instagram, YouTube, and Bilibili |
| `businessId` | body | string | Conditional | Uploaded file or material ID; send this or url. Upload a local file first, then pass the fileId as a string |
| `businessType` | body | FILE \| MATERIAL | Conditional | Required with businessId; use FILE for uploaded files and MATERIAL for library assets |

Request format: `application/json`

### Request example: Replicate a public video URL

```json
{
  "type": "REPLICATION",
  "url": "https://www.tiktok.com/@creator/video/7123456789012345678"
}
```

### Request example: Replicate an uploaded file

```json
{
  "type": "REPLICATION",
  "businessId": "591",
  "businessType": "FILE"
}
```

### Stream events: Prompt delta

```json
{
  "status": "streaming",
  "result": "**Video Script Title**\nA clean product reveal with a slow camera push-in.\n",
  "thinking": null,
  "id": 2066122904659169300
}
```

### Stream events: Full prompt

```json
{
  "status": "done",
  "result": "**Video Script Title**\nA clean product reveal with a slow camera push-in.\n\n**Characters / Main Subjects**\nA seller presenting a summer product against a bright studio backdrop.\n\n**Scene / Environment**\nBright studio lighting, close-up product shots, and a final call to action.\n\n**Script**\n00:00-00:02 Hook the viewer with the product in hand.\n00:02-00:08 Show the key selling points in short cuts.\n00:08-00:10 End with a clear purchase CTA.\n\n**Notes**\nKeep the pacing tight and preserve the original hook-to-CTA structure.",
  "thinking": null,
  "id": 2066122904659169300
}
```

### Response fields

Main levels are listed below. The endpoint JSON Schema is authoritative for the full structure, unions and validation rules; Required refers to the containing object.

| Field | Type | Required | Description |
|---|---|---|---|
| `status` | string | Yes | streaming carries a prompt delta; when the server sends the terminal event, done carries the full prompt.; Allowed values: streaming, done |
| `result` | string | Yes | Prompt delta in streaming events and the full prompt in the done event. |
| `thinking` | string \| null | No | — |
| `id` | integer | No | Analysis task ID; it stays the same for every chunk of one request. |

### Integration notes and limits

- A successful response uses Content-Type text/event-stream. Do not judge success by JSON code === 0.
- Each SSE line is data:<json> with status, result, thinking, and a task id. The id stays constant for one request.
- Concatenate result from status=streaming events in arrival order. If status=done arrives, use that result as the complete prompt.
- Failures return a JSON error body instead of SSE. Read the HTTP status and message.
- For a local MP4, call /v1/file/presign and /v1/file/confirm first, then send businessId with businessType=FILE.
- The assembled prompt is usually Markdown with title, subjects, scene, timestamped script, and notes, and can feed AI video generation.

### Error handling

| HTTP | Description |
|---|---|
| 400 | The request parameters or body are invalid. Fix them and retry. |
| 401 | The API key is missing or invalid. Check x-api-key. |
| 403 | The API key has no permission to call this endpoint. |
| 429 | Too many requests. Retry with exponential backoff. |
| 500 | The server failed. Retry transient failures with exponential backoff. |

Treat any non-zero business code as a failure. Do not blindly retry parameter, permission or authorization errors. If creating a publishing or generation task times out, query the existing task first instead of creating another one.

### Related endpoints

- [Create a presigned upload](/en/openapi/presign) · [Markdown](/en/openapi/operations/createFileUpload.md)
- [Confirm an uploaded file](/en/openapi/confirm) · [Markdown](/en/openapi/operations/confirmFileUpload.md)
- [Create an AI image or video schedule](/en/openapi/schedule-create) · [Markdown](/en/openapi/operations/createAiGenerationSchedule.md)
