Get Video Content
Download the rendered binary MP4 video data for a completed video generation job, bypassing Base64 JSON wrapping for high-throughput streaming playback.
Last updated
The /v1/videos/{id}/content endpoint streams the raw binary MP4 video stream for a completed video generation request. By returning binary media directly rather than wrapping assets in Base64 JSON strings, nRouter eliminates decoding overhead, reduces client memory consumption, and enables high-throughput streaming playback in media applications.
GET https://api.nrouter.ai/v1/videos/{id}/contentReturns raw video/mp4 bytes without base64 JSON serialization overhead.
Supports HTTP Range headers for fast video seeking and responsive client playback.
Video download incurs zero additional charge; billed solely on generation completion.
Asset download requires authenticated bearer key matching the job's owner.
Architectural Role & Lifecycle
When a client requests video content from /v1/videos/{id}/content:
- Phase 1: In-Memory Key Auth & Tenancy Validation: Authenticates the
sk-nrouter-...key and verifies that the video job was created by the caller's tenant organization. If a key from another tenant attempts to download the asset, the gateway returns HTTP 404 Not Found (model_not_found). - State Verification: Inspects the rendering lifecycle state:
- If the job is still
queuedorprocessing, the gateway halts with HTTP 400 Bad Request (invalid_request:"Video rendering is still in progress. Please poll /v1/videos/{id} until status is completed."). - If the job
failed, the gateway returns HTTP 400 Bad Request describing the generation failure. - If
completed, the gateway initiates a binary media pipe.
- If the job is still
- Binary Stream Pipe: Streams the raw
video/mp4data directly from the storage cache to the client while applyingContent-Type: video/mp4andContent-Dispositionheaders. - Zero Incremental Billing: Downloading the generated asset costs $0. All financial billing occurs once upon job rendering completion.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The unique video generation job ID (e.g. nrouter_video_01j89azxckm3287). |
Headers Reference
Inbound Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Bearer authentication format: Bearer sk-nrouter-.... |
Range | string | No | Optional HTTP byte range header for partial video buffering (e.g. bytes=0-1048576). |
Outbound Response Headers
| Header | Type | Description |
|---|---|---|
Content-Type | string | Always video/mp4. |
Content-Length | integer | Total size of the video file in bytes. |
Accept-Ranges | string | bytes indicating support for range requests. |
x-nr-request-id | string | Unique UUID correlation identifier for tracing. |
x-nr-latency-ms | integer | Gateway edge turnaround time in milliseconds. |
x-nr-model | string | Upstream physical model that rendered the video. |
SDK Code Examples
import { nRouter } from "@nrouter_ai/sdk";
import * as fs from "node:fs";
const client = new nRouter({
apiKey: process.env.NROUTER_API_KEY,
});
const jobId = "nrouter_video_01j89azxckm3287";
// Download binary video stream
const response = await client.videos.download(jobId);
const buffer = Buffer.from(await response.arrayBuffer());
await fs.promises.writeFile("rendered_video.mp4", buffer);
console.log("Video saved to rendered_video.mp4");Error Handling & Status Codes
{
"error": {
"type": "gateway_error",
"message": "Video rendering is still in progress. Current status: processing.",
"code": "invalid_request"
}
}| HTTP Status | Error Code | Root Cause | Mitigation Strategy |
|---|---|---|---|
| 400 Bad Request | invalid_request | Video generation job is still queued or processing, or rendering encountered an error. | Poll GET /v1/videos/{id} until status === "completed" before attempting download. |
| 401 Unauthorized | invalid_api_key | Virtual key missing, expired, or invalid. | Check Authorization: Bearer sk-nrouter-... key in dashboard. |
| 404 Not Found | model_not_found | Job ID does not exist or belongs to another tenant organization. | Verify the job identifier returned by POST /v1/videos. |
| 429 Too Many Requests | rate_limit_exceeded | Virtual key download bandwidth or RPM ceiling exceeded. | Implement rate-limiting across concurrent media worker threads. |
| 500 / 503 Gateway Error | service_unavailable | Video storage cluster or edge proxy temporarily unreachable. | Retry request; downloads carry no financial charge. |
Binary Asset Streaming & Storage Architecture
When downloading high-definition video assets through GET /v1/videos/{id}/content, the response streams binary MP4 bytes directly from regional storage nodes.
Chunked Transfer & Range Requests
Large video files can exceed 50 MB depending on prompt length and duration. The nRouter gateway supports standard HTTP Range requests (bytes=start-end) for resuming interrupted downloads and seeking playback:
- Content-Type: Always set to
video/mp4. - Accept-Ranges: Emits
bytesto signal partial content capability. - Cache-Control: Completed video assets are immutable. Responses include
public, max-age=31536000, immutableheaders for optimal CDN edge caching. - Content-Length: Provides exact byte count for progress bar calculations in client user interfaces.
Integration Patterns for Media Pipelines
- Direct Cloud Storage Ingestion: Stream binary chunks directly to Amazon S3, Google Cloud Storage, or Azure Blob Storage without buffering the entire file into local application memory.
- CDN Distribution: Store the binary asset in your public CDN bucket (e.g. Cloudflare R2, CloudFront) to serve end users with sub-millisecond first-frame delivery.
- Automated Post-Processing: Pipe bytes into FFmpeg or transcoding workers to generate thumbnails, GIF previews, or HLS adaptive bitrate streams.
Storage Retention & Access Lifecycle Policies
Media artifacts generated through the nRouter video engine adhere to tenant-configurable retention policies:
- Default TTL: Video binary blobs remain available for download for 24 hours post-completion before automatic purge.
- Permanent Mirroring: Organizations requiring persistent archiving can configure automated cloud sync in their dashboard settings to mirror completed videos directly to enterprise S3 buckets.
- Signed URL Delegation: For secure browser-side rendering, backend servers can retrieve pre-signed temporary URLs with configurable expiry windows (15 minutes to 4 hours).
- Encryption at Rest: All stored video binaries are encrypted using AES-256 with tenant-isolated encryption keys, ensuring full compliance with SOC2 Type II and HIPAA requirements.
Authorization
NRouterApiKey Your nRouter virtual key (sk-nrouter-…). Sent as Authorization: Bearer sk-nrouter-….
In: header
Path Parameters
Header Parameters
Target MCP server ID when routing MCP tool calls or prompts through the gateway
Response Body
video/mp4
application/json
application/json
application/json
application/json
curl -X GET "https://example.com/v1/videos/string/content""video/mp4 byte stream"