Video API

Tạo video

Tạo video từ một prompt, hoặc tạo ảnh động từ ảnh bắt đầu, với các mô hình video được liệt kê bên dưới.

POSThttps://api.oxyy.ai/v1/videos/generations
Video luôn là một tác vụ. Endpoint này trả lời 202 Accepted với một job id — không bao giờ là video. Kiểm tra trạng thái job cho đến khi status là completed, sau đó đọc tệp từ result.data[0].url. Một đoạn video thường mất 30–120 giây.

Các tham số

Tham sốLoạiBắt buộcMô tả
mô hìnhstringBắt buộcID mô hình video, e.g. grok-imagine-video.
promptstringRequired*Nội dung cần diễn ra trong cảnh quay. *Tùy chọn khi bạn cung cấp một image để tạo hoạt ảnh.
hình ảnhfile|stringKhông bắt buộcMột khung hình bắt đầu — một tệp tải lên, một URL hoặc một data URL. Biến request thành dạng chuyển đổi hình ảnh thành video.
durationnumberKhông bắt buộcĐộ dài clip tính bằng giây, từ 1 đến 60. Các nhà cung cấp giới hạn ở các độ dài mà mỗi mô hình hỗ trợ, và bạn bị tính phí theo độ dài thực tế được tạo ra. Mặc định 4
secondsstring|integerKhông bắt buộcCách viết tương đương của OpenAI. Một trong:4812
resolutionstringKhông bắt buộcMột trong:480p720p1080p4k
sizestringKhông bắt buộcWIDTHxHEIGHT, v.d. 1280x720. Thay thế cho resolution.
aspect_ratiostringKhông bắt buộce.g. 16:9, 9:16.
negative_promptstringKhông bắt buộcNhững gì cần loại bỏ khỏi khung hình.
generate_audiobooleanKhông bắt buộcYêu cầu nhạc nền trên các model có hỗ trợ tính năng đó.
person_generationstringKhông bắt buộcChính sách phía nhà cung cấp về việc miêu tả con người.
seedintegerKhông bắt buộcKhả năng tái tạo, nếu được hỗ trợ.
nintegerKhông bắt buộcSố đoạn clip cần tạo, từ 1 đến 4. Không phải mọi nhà cung cấp đều trả về nhiều hơn một. Mặc định 1
syncbooleanKhông bắt buộcChờ clip của request thay vì trả về một job. Chỉ dùng cho các clip ngắn — các thao tác tạo dài sẽ vượt quá thời gian chờ của request. Mặc định false
userstringKhông bắt buộcMột id ổn định cho người dùng cuối của chính bạn.

Đang gửi tác vụ

import os, requests

headers = {
    "Authorization": f"Bearer {os.environ['OXYY_API_KEY']}",
    "Content-Type": "application/json",
}

# Video is asynchronous: this returns 202 with a job, not a video.
response = requests.post(
    "https://api.oxyy.ai/v1/videos/generations",
    headers=headers,
    json={
        "model": "grok-imagine-video",
        "prompt": "A serene lake with mountains, slow dolly in",
        "duration": 8,
        "resolution": "1080p",
        "aspect_ratio": "16:9",
    },
)
job = response.json()
print(response.status_code, job["id"], job["status"])
curl https://api.oxyy.ai/v1/videos/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OXYY_API_KEY" \
  -d '{
    "model": "grok-imagine-video",
    "prompt": "A serene lake with mountains",
    "duration": 8,
    "resolution": "1080p"
  }'
202 Accepted
HTTP/1.1 202 Accepted

{
  "id": "gen_01JQXY8M3K2T4V6W8Z",
  "object": "generation.job",
  "status": "queued",
  "type": "video",
  "model": "grok-imagine-video",
  "created_at": 1700000000,
  "expires_at": 1700086400,
  "_links": {
    "self": "/v1/videos/generations/gen_01JQXY8M3K2T4V6W8Z",
    "cancel": "/v1/videos/generations/gen_01JQXY8M3K2T4V6W8Z"
  }
}

Đang chờ kết quả

GEThttps://api.oxyy.ai/v1/videos/generations/{id}

Kiểm tra lại khoảng năm giây một lần. status đi qua queued → processing → completed, với progress dưới dạng phần trăm; các lỗi nghiêm trọng là failed và cancelled.

import os, time, requests

headers = { "Authorization": f"Bearer {os.environ['OXYY_API_KEY']}" }
job_id = "gen_..."  # the `id` the 202 returned

while True:
    job = requests.get(
        f"https://api.oxyy.ai/v1/videos/generations/{job_id}",
        headers=headers,
    ).json()

    if job["status"] == "completed":
        # The video lives under result.data[0].url
        print("Video:", job["result"]["data"][0]["url"])
        print("Charged:", job["usage"]["credits_consumed"])
        break
    if job["status"] in ("failed", "cancelled"):
        print("Failed:", job.get("error"))
        break

    print(f"{job['status']} — {job['progress']}%")
    time.sleep(5)
const headers = { Authorization: `Bearer ${process.env.OXYY_API_KEY}` };
const jobId = 'gen_...';

while (true) {
  const job = await fetch(
    `https://api.oxyy.ai/v1/videos/generations/${jobId}`,
    { headers }
  ).then((r) => r.json());

  if (job.status === 'completed') {
    console.log('Video:', job.result.data[0].url);
    break;
  }
  if (job.status === 'failed' || job.status === 'cancelled') {
    console.error('Failed:', job.error);
    break;
  }
  console.log(`${job.status} — ${job.progress}%`);
  await new Promise((r) => setTimeout(r, 5000));
}
# 1. Submit — the 202 body carries the job id.
curl -X POST https://api.oxyy.ai/v1/videos/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OXYY_API_KEY" \
  -d '{"model": "grok-imagine-video", "prompt": "A serene lake", "duration": 8}'

# 2. Poll until status is completed, failed or cancelled.
curl https://api.oxyy.ai/v1/videos/generations/gen_abc123 \
  -H "Authorization: Bearer $OXYY_API_KEY"

# 3. Cancel a job you no longer want.
curl -X DELETE https://api.oxyy.ai/v1/videos/generations/gen_abc123 \
  -H "Authorization: Bearer $OXYY_API_KEY"

Đã hoàn thành công việc

Phản hồi
{
  "id": "gen_01JQXY8M3K2T4V6W8Z",
  "object": "generation.job",
  "status": "completed",
  "type": "video",
  "model": "grok-imagine-video",
  "progress": 100,
  "created_at": 1700000000,
  "started_at": 1700000004,
  "completed_at": 1700000098,
  "expires_at": 1700086400,
  "result": {
    "created": 1700000098,
    "data": [
      {
        "url": "https://api.oxyy.ai/storage/videos/2026/01/abc123.mp4",
        "duration": 8,
        "resolution": "1080p"
      }
    ]
  },
  "usage": { "credits_consumed": 3.2 }
}

Tác vụ thất bại

Phản hồi
{
  "id": "gen_01JQXY8M3K2T4V6W8Z",
  "object": "generation.job",
  "status": "failed",
  "type": "video",
  "model": "grok-imagine-video",
  "progress": 30,
  "created_at": 1700000000,
  "error": {
    "message": "The video was filtered by the provider's safety system",
    "code": "CONTENT_FILTER"
  }
}

Quản lý tác vụ

GEThttps://api.oxyy.ai/v1/videos/generationsyour jobs; ?status=&limit=&offset=
DELETEhttps://api.oxyy.ai/v1/videos/generations/{id}hủy
POSThttps://api.oxyy.ai/v1/videos/image-to-videotạo hoạt ảnh cho hình ảnh

Một công việc là của riêng bạn — ID của tài khoản khác trả lời 404, không phải 403. Các công việc hết hạn vào expires_at; hãy tải xuống tệp trước thời điểm đó hoặc tự lưu trữ lại.

Các model có sẵn