Introduction: Make video searchable with natural language
Imagine you're building an application that stores hundreds of hours of video footage. A user wants to find every moment when a person walks through a restricted entrance, a customer discusses pricing, or a forklift moves through a warehouse.
The footage contains the information they need. The challenge is finding it.
Traditional video workflows often rely on manually reviewing footage, navigating timelines, or searching metadata added by someone beforehand. These approaches become difficult to maintain as video libraries grow.
What if your application could search video using a natural-language query and return the relevant moments with timestamps?
That's what we'll build in this tutorial using Zyris and its official Python SDK.
We'll take a sample video, upload it to Zyris, prepare it for search, and query it using a phrase such as:
person walking near the gate
Zyris returns ranked video segments with start and end timestamps and playback URLs. Your application can use those results to display relevant clips instead of asking users to manually search through the entire recording.
By the end, you'll understand the complete workflow and have a Python quickstart you can adapt to your own application.
What you'll build
We'll create a simple video-search workflow with five steps:
- Authenticate: Connect to Zyris using your developer API key.
- Upload: Send a local video file to the platform.
- Process: Run the pipelines required to make the video searchable.
- Search: Submit a natural-language query against the processed video.
- Retrieve: Display ranked matches, timestamps, and playback links.
For this tutorial, we'll use a local video file named sample.mp4. Use a video you own or have permission to process.
Prerequisites
Before you start, you'll need:
- Python 3.8 or later.
- A Zyris developer API key.
- A local video file to use as a sample.
- A terminal or command prompt.
This tutorial uses the official Zyris Python SDK, which wraps the Video Platform Developer API in a typed Python client.
Step 1: Install the Zyris Python SDK
Create a project directory and install the SDK:
mkdir zyris-video-search
cd zyris-video-search
pip install zyris
The SDK handles the underlying HTTP requests and parses responses into structured models. This means you can work with Python methods and returned objects instead of manually constructing every API request.
Place your sample video in the project directory:
zyris-video-search/
├── sample.mp4
└── search_video.py
We'll create search_video.py in the following steps.
Step 2: Authenticate securely
Every request to the developer API must be authenticated.
Generate your API key from the Zyris dashboard's developer settings. The key is used by the SDK to authenticate requests automatically through the X-API-Key header.
Avoid placing your actual key directly in your source code. If you commit a script to GitHub or share it with a colleague, a hardcoded key can expose your account.
Instead, store the key in an environment variable.
On macOS or Linux:
export ZYRIS_API_KEY="sk_your_actual_key"
On Windows PowerShell:
$env:ZYRIS_API_KEY="sk_your_actual_key"
Your Python application can now read the key without embedding it in the script.
We'll use the following code to create a client:
import os
from zyris import Client
api_key = os.environ["ZYRIS_API_KEY"]
client = Client(
api_key=api_key,
base_url="https://playground.zyris.ai",
)
The SDK uses https://playground.zyris.ai as its documented base URL in the quickstart.
The client exposes several resource groups, including:
client.uploadsfor video ingestion and upload status.client.videosfor video details and processing pipelines.client.searchfor semantic search and visualization.client.chatfor natural-language questions about a video.client.embeddingsfor accessing text and video embeddings.
For this tutorial, we'll focus on uploads, videos, and search.
Step 3: Upload a video
Before searching a video, you need to ingest it into the platform.
The SDK provides an upload_file() helper that handles the multipart upload workflow. It divides a file into chunks, uploads those chunks, completes the upload, and initiates the subsequent transcoding and HLS generation process.
Here's how to upload the sample video:
job = client.uploads.upload_file(
"sample.mp4",
name="Sample Video",
)
video_id = job.video_id
print(f"Video uploaded. ID: {video_id}")
The returned video_id identifies the video in subsequent operations.
Important: Uploading a video doesn't mean it is immediately searchable. The upload workflow starts processing tasks, and those tasks must finish before you can initiate the analysis and search pipelines.
Wait for upload processing to finish
Video ingestion is asynchronous. Instead of assuming the upload is ready as soon as the SDK returns a video ID, check its processing status.
import time
while True:
status = client.uploads.get_status(video_id)
upload_state = status.derived_status()
print(f"Upload status: {upload_state}")
if upload_state == "completed":
break
if upload_state == "failed":
raise RuntimeError(
status.error_message or "Video upload processing failed"
)
time.sleep(2)
The derived_status() method combines the upload's thumbnail generation, transcoding, and HLS generation states into a single status:
| Status | Meaning |
|---|---|
pending | Processing hasn't started yet. |
in_progress | At least one processing task is underway. |
completed | All required upload-processing tasks have completed. |
failed | A processing task has failed. |
The loop checks every two seconds until the upload reaches a terminal state.
In a production application, consider adding a maximum wait time, structured logging, and a retry policy so that a prolonged processing job doesn't leave a worker waiting indefinitely.
Step 4: Prepare the video for semantic search
This is the step that makes the difference between simply storing a video and being able to search its contents.
Zyris documents two independent processing pipelines:
- The analyse pipeline supports content understanding and natural-language questions about the video.
- The search-process pipeline prepares the video segments and embeddings needed for semantic search and embedding retrieval.
A video is not fully processed until both pipelines have finished. Search requires the search-process pipeline to complete, while the analyse pipeline supports the broader video-understanding workflow.
Start both pipelines after upload processing is complete:
client.videos.initiate_analyse(video_id)
client.videos.initiate_search_process(video_id)
These calls enqueue processing jobs; they do not mean that processing has already finished.
Wait for both pipelines
The next step is to monitor each pipeline independently.
while True:
analyse_status = client.videos.get_analyse_status(video_id)
search_status = client.videos.get_search_process_status(video_id)
print(
f"Analyse: {analyse_status.status} | "
f"Search: {search_status.status}"
)
if analyse_status.is_terminal() and search_status.is_terminal():
if analyse_status.is_failed() or search_status.is_failed():
raise RuntimeError(
"Video processing failed: "
f"analyse={analyse_status.status}, "
f"search={search_status.status}"
)
break
time.sleep(2)
Notice that we don't compare both pipelines against one universal success string. Their documented success states differ:
- The analyse pipeline reports success as
done. - The search-process pipeline reports success as
success.
The SDK's status helpers let us check whether a pipeline has reached a terminal state and whether it failed.
Once both pipelines have completed successfully, the video is ready for the semantic-search step.
Step 5: Search the video using natural language
Now comes the main part of the tutorial.
Suppose the sample video contains several scenes, and your application needs to find moments involving a person walking near a gate.
You don't need to supply a timestamp or a manually assigned tag. You can express the search in natural language:
hits = client.search.search(
"person walking near the gate",
video_ids=[video_id],
top_k=5,
)
Let's break down the parameters:
- Query: The natural-language description of the moment you're looking for.
video_ids: Restricts the search to the video we've just processed.top_k: Sets the maximum number of ranked results to return. Here, we're requesting five.
You must provide at least one of video_ids or collection_id. This lets you search a specific video or scope the query to a collection of processed videos.
For example, you could adapt the query to different applications:
| Application | Example query |
|---|---|
| Security | person entering a restricted area |
| Retail | customer waiting at the checkout counter |
| Warehousing | forklift moving near the loading bay |
| Sports | a bowler delivering a yorker |
| Meetings | the moment they discuss pricing |
These are illustrative queries, not guaranteed results from the sample video. Search results depend on the footage and the relevance of its contents to the query.
How is this different from a conventional search?
A conventional metadata search generally depends on fields or tags that have already been recorded. If a video segment has no relevant tag, a query for that tag may not find it.
Semantic video search instead lets you describe the content you're looking for in natural language. Zyris returns ranked, timestamped clips based on the search.
This makes it possible to build interfaces where users describe a moment in their own words rather than learning a fixed set of labels or navigating an entire video timeline.
Step 6: Return the relevant moments to your application
The search call returns a list of ranked hits. Each hit includes information such as:
- Its rank in the results.
- The start and end timestamps of the segment.
- The associated video ID.
- A thumbnail URL.
- Video and HLS playback URLs.
You can use this information to show search results in a frontend, let users open relevant moments, or pass the results to another part of your application.
Here's a basic way to print the results:
for hit in hits:
print(f"Result #{hit.rank}")
print(f"Video ID: {hit.video_id}")
print(f"Start: {hit.start}")
print(f"End: {hit.end}")
print(f"Thumbnail: {hit.thumbnail_url}")
print(f"Playback: {hit.hls_playlist_url}")
print("-" * 40)
The start and end timestamps use the HH:MM:SS format.
For example, a result might identify a relevant segment from 00:02:18 to 00:02:24. That example is illustrative; your actual timestamps will depend on the video you process.
What can you do with the results?
Once you have the ranked hits, you can use them in several ways:
- Build a searchable video library. Display the query, thumbnail, timestamp, and matching clip so users can quickly navigate to relevant footage.
- Create a review workflow. Let a reviewer inspect only the moments returned by a query instead of manually scanning every minute of a recording.
- Support cross-video search. Pass multiple video IDs or a collection ID to search across a broader library of processed footage.
- Connect search to existing application logic. Use the returned video IDs and timestamps to link results to your own records, workflows, or review tools.
The SDK provides the search results and playback-related URLs. How those results are presented, filtered, stored, or acted upon is up to your application.
Step 7: Put everything together
The following script combines the steps into one end-to-end example. It uploads a local video, waits for upload processing, starts both pipelines, waits for them to finish, and searches for relevant moments.
Save it as search_video.py.
import os
import time
from zyris import Client
API_KEY = os.environ["ZYRIS_API_KEY"]
BASE_URL = "https://playground.zyris.ai"
VIDEO_PATH = "sample.mp4"
VIDEO_NAME = "Sample Video"
SEARCH_QUERY = "person walking near the gate"
TOP_K = 5
POLL_INTERVAL = 2
MAX_WAIT_SECONDS = 3600
def wait_for_upload(client, video_id):
deadline = time.monotonic() + MAX_WAIT_SECONDS
while time.monotonic() < deadline:
status = client.uploads.get_status(video_id)
state = status.derived_status()
print(f"Upload processing: {state}")
if state == "completed":
return
if state == "failed":
raise RuntimeError(
status.error_message or "Upload processing failed"
)
time.sleep(POLL_INTERVAL)
raise TimeoutError("Timed out waiting for upload processing")
def wait_for_pipelines(client, video_id):
deadline = time.monotonic() + MAX_WAIT_SECONDS
while time.monotonic() < deadline:
analyse = client.videos.get_analyse_status(video_id)
search = client.videos.get_search_process_status(video_id)
print(
f"Analyse: {analyse.status} | "
f"Search: {search.status}"
)
if analyse.is_terminal() and search.is_terminal():
if analyse.is_failed() or search.is_failed():
raise RuntimeError(
"Video pipeline failed: "
f"analyse={analyse.status}, "
f"search={search.status}"
)
return
time.sleep(POLL_INTERVAL)
raise TimeoutError("Timed out waiting for video pipelines")
def main():
if not os.path.isfile(VIDEO_PATH):
raise FileNotFoundError(
f"Video file not found: {VIDEO_PATH}"
)
with Client(
api_key=API_KEY,
base_url=BASE_URL,
) as client:
# 1. Upload the video.
job = client.uploads.upload_file(
VIDEO_PATH,
name=VIDEO_NAME,
)
video_id = job.video_id
print(f"Uploaded video ID: {video_id}")
# 2. Wait for transcoding and HLS generation.
wait_for_upload(client, video_id)
# 3. Start both required processing pipelines.
client.videos.initiate_analyse(video_id)
client.videos.initiate_search_process(video_id)
# 4. Wait until both pipelines finish.
wait_for_pipelines(client, video_id)
# 5. Search for relevant moments.
hits = client.search.search(
SEARCH_QUERY,
video_ids=[video_id],
top_k=TOP_K,
)
# 6. Display the returned results.
if not hits:
print("No matching clips were returned.")
return
print(f"\nResults for: {SEARCH_QUERY}\n")
for hit in hits:
print(f"Rank: #{hit.rank}")
print(f"Time: {hit.start} - {hit.end}")
print(f"Video ID: {hit.video_id}")
print(f"Thumbnail: {hit.thumbnail_url}")
print(f"Playback: {hit.hls_playlist_url}")
print("-" * 50)
if __name__ == "__main__":
main()
Run the script:
python search_video.py
The script prints the upload ID, processing progress, and the matching clips returned by the search query.
The one-hour timeout in this example is a configurable safeguard, not a statement about how long processing should take. Adjust it for your workload, and use a background worker or job queue for long-running tasks in a production service.
Step 8: Handle common errors
A useful developer integration needs to account for failures as well as the successful workflow.
Here are several errors you may encounter when building with Zyris.
| HTTP status | What it means | What to check |
|---|---|---|
| 400 | Bad request | Check input parameters and business rules. |
| 401 | Authentication failed | Confirm that your API key is present and valid. |
| 403 | Permission denied | Check whether the key has access to the requested resource. |
| 404 | Resource not found | Verify the video or collection ID. |
| 409 | Conflict | Check whether a required processing step has finished. |
| 413 | Payload too large | Use the multipart upload helper for larger files instead of direct upload. |
| 422 | Validation error | Review the request parameters and their expected types. |
| 429 | Rate limited | Respect the Retry-After header when available. |
| 5xx | Server or upstream error | Retry transient failures with an appropriate backoff policy. |
The Python SDK exposes typed exceptions for common failures, including AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, PayloadTooLargeError, and RateLimitError.
For example, a 409 ConflictError can indicate that a processing prerequisite hasn't been satisfied. Before starting the analysis and search pipelines, make sure upload processing has completed.
For rate limiting, avoid retrying continuously in a tight loop. Use bounded retries and honour the retry delay supplied by the server when available.
Step 9: Keep your integration secure
When building a video-search application, authentication and resource access deserve as much attention as the search query itself.
Keep these practices in mind:
- Protect API keys. Store keys in environment variables or a secret manager, not in source code or public repositories.
- Keep privileged requests on the backend. Don't embed a developer API key in frontend code shipped to end users.
- Scope searches deliberately. Provide the video IDs or collection IDs relevant to the operation.
- Treat playback URLs appropriately. Zyris returns signed thumbnail and video URLs, alongside an authentication-gated HLS URL. Don't assume every URL is permanent or publicly accessible.
- Handle failures explicitly. Distinguish failed processing from a job that's still running.
- Be careful with deletion. The documented
delete_videooperation permanently deletes the video and its derived assets, with no undo.
These safeguards make the difference between a quick proof of concept and an integration that can be maintained safely.
What you've built
You've now implemented the core workflow for natural-language video search with Zyris:
- Installed the official Python SDK.
- Authenticated using a developer API key.
- Uploaded a sample video.
- Waited for upload processing to finish.
- Started the analyse and search-process pipelines.
- Searched the processed video using natural language.
- Retrieved ranked segments with timestamps and playback-related URLs.
This is a starting point, not a complete production application. You can build on it with a frontend, persistent job tracking, collections, access controls, and retry handling appropriate to your workload.
The same SDK also supports additional workflows, including asking natural-language questions about a video and retrieving the video segments' stored embeddings. Those capabilities can help you move beyond finding a moment to building richer video-understanding applications.
Next steps
Explore the official Zyris developer resources:
- Python SDK documentation: Review the SDK's upload, video, search, chat, and embedding interfaces.
- API Reference: Use the HTTP API documentation if you need to work directly with REST endpoints rather than the Python SDK.
- MCP Server documentation: Connect Zyris to an MCP-compatible AI client and use agent-callable tools for video ingestion, search, and analysis.
- Zyris Playground: Try uploading and searching video in the browser.
The idea is simple: instead of making users search through a timeline, give your application a way to retrieve relevant video moments from a natural-language query.
With Zyris, that workflow can become part of the application you're already building.

