Notice: Black Friday 2026 × Cyber Monday: Get up to 30% extra on top-ups, DeepSeek free to use · View the promotion
Blog

Tutorial

How to Call ltx-2.5-pro Audio-to-Video via the HiAPI API: curl and Python

Nov 25, 2026 9 min read
封面图:午夜蓝底上铜色细密平行刻线,密度渐变,抽象呈现声波汇入视频框的几何构图。
On this page

What the ltx-2.5-pro audio-to-video endpoint does

ltx-2.5-pro/audio-to-video is a generative endpoint that turns an audio track plus a text prompt into a video. You send it two creative inputs — the audio that should drive the result and a prompt describing the visuals you want — and it returns a generated video that matches that brief. The audio supplies the timing and mood; the prompt supplies the content and style. If your use case is "I have a soundtrack, voiceover, or music bed and I need matching footage," this is the endpoint you want.

The model path on HiAPI is ltx-2.5-pro/audio-to-video. You do not integrate with any upstream provider directly: the same API key, request shape, and response envelope work across the models HiAPI exposes, so what you learn here transfers to other generative endpoints. Video generation is not instantaneous, so the call is asynchronous — you submit a job, receive a handle, poll it until it finishes, and then download the output. Keeping that lifecycle in mind from the start is what separates a working integration from a flaky one.

Two details are worth fixing in your head before writing code. First, this is a video model, so the output is a media file you fetch from a returned URL, not inline bytes in the JSON response. Second, the input audio is a payload you attach to the request — which means request construction, not just URL parameters, matters here. Everything below builds on those two facts.

Prerequisites: credentials, endpoint, and audio input

Before your first call, line up three things.

An API key. Every request is authenticated with a bearer token issued from your HiAPI account. Treat it like any other secret: load it from an environment variable or secrets manager, never hardcode it into source that gets committed, and rotate it if it leaks.

The model identifier and base URL. The model path is ltx-2.5-pro/audio-to-video, and it goes into the request body where the API expects a model field. Your account's API base URL is the host you send all requests to; keep it in configuration alongside the key so you can point staging and production at different environments without touching code. You can review the model's capabilities on its model page while you plan the integration.

The audio file itself. Decide up front how audio reaches the request. The file must be in a format the endpoint accepts, and you need to know its MIME type and size before you build the payload — both are needed when you attach it. For local testing, keep a short, small clip handy; a brief sample that runs end-to-end in seconds is far better for debugging than a ten-minute track. In production, audio usually arrives from object storage or an upload from your users, so plan for a step that either stages the file somewhere the API can read or streams it into the request body.

Finally, confirm your HTTP client can do multipart uploads and follow redirects when you later download the result. Most standard libraries can; check before you start if you are using something unusual.

A working request with curl

The fastest way to validate credentials and request shape is a shell call. The example below submits an audio-to-video job: it authenticates with your key, names the model, attaches the audio file, and passes the prompt.

export HIAPI_API_KEY="your-api-key-here"

curl -X POST "$HIAPI_BASE_URL/v1/jobs" \
  -H "Authorization: Bearer $HIAPI_API_KEY" \
  -F "model=ltx-2.5-pro/audio-to-video" \
  -F "prompt=A slow dolly through a neon-lit city street at night, rain on the pavement" \
  -F "audio=@./sample.wav;type=audio/wav"

Read it from the outside in. The Authorization header carries the bearer token — if this is wrong you get an authentication error before the model is ever involved. The -F flags build a multipart form: model selects the endpoint, prompt is the text description, and audio attaches the file, with @ telling curl to read from disk and type= declaring the MIME type. If your client guesses the MIME type wrong, the request may be rejected even though the file is valid — set it explicitly.

A successful submission returns JSON containing a job identifier and a status. It does not return the video. Capture that identifier; you will use it in the polling step. If you get a validation error instead, check the field names against the request above and confirm the audio file actually exists at the path you gave — a missing file produces a confusing multipart error rather than a clean "file not found."

Once this call works from the shell, you have proven three things at once: the key is valid, the model path resolves, and your audio payload is acceptable. Now port it.

The same request in Python

The Python client below performs the identical submission. It reads credentials from the environment, streams the audio file rather than loading it fully into memory, and returns the parsed JSON so the caller can pull out the job ID.

import os
import requests

API_KEY = os.environ["HIAPI_API_KEY"]
BASE_URL = os.environ["HIAPI_BASE_URL"]

def submit_audio_to_video(audio_path: str, prompt: str) -> dict:
    url = f"{BASE_URL}/v1/jobs"
    headers = {"Authorization": f"Bearer {API_KEY}"}
    data = {
        "model": "ltx-2.5-pro/audio-to-video",
        "prompt": prompt,
    }
    with open(audio_path, "rb") as f:
        files = {"audio": (os.path.basename(audio_path), f, "audio/wav")}
        resp = requests.post(url, headers=headers, data=data, files=files, timeout=120)

    resp.raise_for_status()
    return resp.json()

if __name__ == "__main__":
    job = submit_audio_to_video(
        "sample.wav",
        "A slow dolly through a neon-lit city street at night, rain on the pavement",
    )
    print(job["id"], job["status"])

A few choices are deliberate. requests.post with data= and files= produces the same multipart body as the curl call, so behavior matches. The explicit timeout prevents a hung upload from blocking a worker forever. The (filename, fileobj, content_type) tuple in files sets the MIME type explicitly, mirroring curl's type=. Opening the file inside a with block guarantees the handle closes even if the request raises.

Wrap this in your own service layer and return the job ID to whatever polled the submission — a queue worker, a web endpoint, or a CLI. Note that submission success only means the job was accepted; the video does not exist yet.

Handling the async job: polling and retrieving results

Video generation takes time proportional to prompt complexity and duration, so the endpoint returns quickly and does the work in the background. Your integration is a three-step lifecycle: submit, poll, download.

Poll. After submission, call the job-status endpoint with the job ID, repeating on a fixed interval. Use a modest interval — a few seconds — rather than a tight loop; hammering the status endpoint wastes rate limit and tells you nothing new. Cap the total wait with a deadline so a stuck job fails visibly instead of hanging a worker indefinitely.

Detect completion. The status field transitions from a queued/running state to a terminal one. Treat success and failure as distinct branches: on success, extract the output URL; on failure, surface the error message rather than retrying blindly, because malformed audio or a rejected prompt will fail identically every time. Log the job ID with every status check so you can correlate later.

Download. A successful job returns a URL to the generated video. Fetch it promptly — output URLs are not permanent. If your application serves the video to users, download it to your own storage and serve from there rather than handing clients a temporary URL that may expire mid-session. Verify the download completed and the file is a valid video before declaring the job done.

Roll this into one function: submit, poll until terminal or deadline, download on success, return a local path or stored URL. Everything upstream of that function only needs to know whether it succeeded.

Common integration mistakes and how to avoid them

Authentication handled loosely. The most common failure is a missing or malformed Authorization header — often because the key was read before the environment loaded, or a stray newline came along with the token. Load secrets once at startup, validate they exist, and strip whitespace. A 401 means the credential, not the model, is the problem.

Audio payload problems. Sending the file without the right MIME type, sending a format the endpoint does not accept, or sending a file too large for the request all produce opaque validation errors. Set the content type explicitly, convert audio to a supported format up front rather than hoping, and reject oversized uploads in your own code with a clear message before they reach the API.

Treating submission as completion. Reading a job ID as if it were the video is the classic async mistake. Submission returns a handle; the video arrives only after polling reaches a successful terminal state. Parse the status field, don't assume.

Polling badly. Tight loops, missing deadlines, and no jitter are the usual culprits. Poll on an interval, enforce a maximum wait, and make failure paths explicit.

Ignoring expiry on result URLs. If you cache output URLs and serve them hours later, users hit broken links. Download to durable storage on success.

Work through those five and your integration will be boring — which is exactly what you want. Start from the model page, run the curl call once, then port it to Python and put the lifecycle behind a single function.

Related articles

View all articles →

Start building with persistent AI artifacts

Get your API key and call image, video and audio models through one task-based API.

Read the API docs