Skip to content
Interlatent/Documentation
Ivy/Technical reference/Queries & tag operations

Queries & tag operations

Query saved annotations and recorded per-frame data with SQL, then use the matching clip IDs for tagging or export.

Available query views

run_query(project_id, sql) reads saved annotations and recorded data. It does not inspect the video or infer new labels. Each view joins on clip_id. Per-frame columns depend on the imported data; inspect the available fields before writing a telemetry query.

ViewFields
episodesclip_id, name, source, episode_index, fps, duration_s, frame_count, tasks
spansclip_id, track, label, t0, t1, revision
eventsclip_id, track, label, t, revision
scalarsclip_id, track, t, value, revision
framesclip_id plus recorded per-frame fields, such as timestamp, observation.state, and action

Find episodes with a saved presence label

This query assumes a reviewed span track named object_presence whose positive label is exactly “red cup visible”. Replace the track and label with the values actually saved in your project. DISTINCT returns one row per matching episode, even if it has several matching intervals.

Presence querysql
SELECT DISTINCT e.clip_id, e.name
FROM episodes AS e
JOIN spans AS s ON s.clip_id = e.clip_id
WHERE s.track = 'object_presence'
  AND s.label = 'red cup visible'
ORDER BY e.name

Return matching action intervals

Return clip_id, t0, and t1 when you need evidence windows for review or trimming. This example finds “grasp” spans longer than two seconds on a track named Subtasks. Track names, label spelling, and case must match the stored values.

Action interval querysql
SELECT clip_id, t0, t1, t1 - t0 AS duration_s
FROM spans
WHERE track = 'Subtasks'
  AND label = 'grasp'
  AND t1 - t0 > 2
ORDER BY clip_id, t0

Combine conditions on the same episode

Use EXISTS to require two labels on the same episode. This example selects recordings containing a visible red cup and a failed grasp anywhere in that episode. It does not require those intervals to overlap.

Combined condition querysql
SELECT e.clip_id, e.name
FROM episodes AS e
WHERE EXISTS (
    SELECT 1 FROM spans AS s
    WHERE s.clip_id = e.clip_id
      AND s.track = 'object_presence'
      AND s.label = 'red cup visible'
)
AND EXISTS (
    SELECT 1 FROM spans AS s
    WHERE s.clip_id = e.clip_id
      AND s.track = 'grasp_outcome'
      AND s.label = 'failed grasp'
)

Filter a measurement or recorded channel

Scalar tracks contain timestamped measurements. This example selects clips whose saved mean_brightness samples fall below 30. The threshold is an example in grayscale units, not a universal dark-video criterion. Validate thresholds on your own footage.

Scalar threshold querysql
SELECT clip_id, MIN(value) AS minimum_brightness
FROM scalars
WHERE track = 'mean_brightness'
GROUP BY clip_id
HAVING MIN(value) < 30

Tag query results

A result with a clip_id column also returns matching clip IDs for follow-up operations. Pass those IDs to update_video_tags to add or remove labels, up to 1,000 IDs per call. Preserve the exact selection and report missing or unowned IDs as skipped.

Tag tool callspython
# Tool-call examples for your agent, not a standalone Python script.
update_video_tags(
    clip_ids=["CLIP_ID"],
    add=["contains-red-cup", "needs-review"],
)

# After review, preserve the content tag and replace the queue tag.
update_video_tags(
    clip_ids=["CLIP_ID"],
    remove=["needs-review"],
    add=["reviewed"],
)

Coverage, pagination, and pending results

Queries return at most 10,000 rows. If truncated is true, narrow the query or aggregate it rather than treating the returned rows as the full selection. A query that is still running returns a job ID; poll get_job with kind="query" at least five seconds apart. Use the returned export_version when recording which annotation snapshot informed a result.

Start hereQuickstartImport a Hugging Face dataset and analyze an episode with Ivy.Start hereConnect an agentOfficial setup for Interlatent’s Ivy at interlatent.com. Connect your agent to shared visual data, hosted compute, and saved analysis through Ivy.Start hereTrain vision models with an agentUse Ivy by Interlatent for vision model training and evaluation. Training access is gated; contact team@interlatent.com to request access.User manualImport a datasetImport public or private Hugging Face datasets, video files, or recordings from connected storage.User manualAccess datasets from a coding agentDescribe the dataset you want, ask questions about its recordings, and turn the answers into a selection for vision model work with your MCP-compatible coding agent.User manualAmazon S3Connect a bucket, import a small recording collection, and verify that it is ready for analysis.User manualGoogle DriveShare a folder with Ivy, review the import plan, and bring the recordings into a project.User manualGoogle Cloud StorageGrant bucket access, verify the connection, and import recordings from a gs:// path.User manualFiles & video linksImport a single video, a direct download link, or a local recording directory.User manualFind & tag videosFind recordings by their visual content, save a selection as tags, and reuse it in later analysis.User manualObject trackingDetect objects, track their masks with SAM, and inspect the result before measuring motion or counting passages.User manualModels & analysisChoose the method for your question: actions, object locations, masks, or classifications.User manualSubtask segmentation & semantic trimmingPrompt Ivy to divide a video into meaningful steps, steer the boundaries and labels, and export selected sections as video clips.User manualTrim & process videoTrim video by timestamps or meaningful action sections, create processed views, and keep source and output times clear.User manualRun your first experimentsRun action labeling and object tracking on a small sample, then compare and apply the results.User manualReview & exportInspect annotations, correct errors, and export a Dataset snapshot.Technical referenceCore conceptsProjects, recordings, annotations, pipelines, and Dataset snapshots.Technical referencePython recipes & ffmpegRun repeatable measurements and video transformations with annotate(clip, ctx), then save outputs for review.Technical referenceQueries & tag operationsQuery saved annotations and recorded per-frame data with SQL, then use the matching clip IDs for tagging or export.Technical referenceSource connectionsConnection states, cloud permissions, import tools, and recovery for source workflows.Technical referenceTool referencePublic MCP tools grouped by task. Your connected agent provides the current schemas and availability.Technical referenceTroubleshootingResolve common connection, import, analysis, and access errors.ResourcesRights & data FAQAnswers about private video data, vision model ownership, provider handling, evaluation, and trial pricing with Interlatent.