Skip to main content

framelens

Python client for FrameLensAI — evaluation and regression testing for video AI.

FrameLensAI turns "did the new model get worse?" from a vibe into a gated, statistical answer: versioned video test suites → provider-neutral eval runs → video-native metrics with confidence intervals → CI gates that block confident regressions.

This package is the client. It talks to a FrameLens server (self-hosted via docker compose, or run locally with make dev); it does not run evals by itself.

pip install framelens

Requires Python 3.10+. The only dependency is httpx.

Quickstart

from framelens import FrameLens

fl = FrameLens(api_key="dev-key", base_url="http://localhost:8000")

sha     = fl.upload_video("clip.mp4")            # content-addressed; re-upload is a no-op
project = fl.create_project("perimeter-security")
dataset = fl.create_dataset(project["id"], "intrusion-events",
                            task_type="event_detection")
fl.add_case(dataset["id"], video_sha=sha,
            ground_truth={"events": [{"start_ms": 4200, "end_ms": 6100}]})
fl.freeze(dataset["id"])                         # immutable version snapshot

model = fl.create_model_config(project["id"], "gpt-4o", adapter="openai_compat",
                               params={"model": "gpt-4o"})   # api_key is encrypted server-side

run = fl.run(project["id"], dataset_id=dataset["id"],
             model_config_id=model["id"])
run = fl.wait(run["id"])                         # or fl.watch(...) for live SSE progress
print(run["summary"]["overall"]["event_f1"])

Runs are idempotent: the same (dataset version, model config, prompt, sampling) tuple produces the same fingerprint, and the server returns the existing run instead of paying for it twice. run() tells you which happened via outcome: created, cached, joined or resumed.

Gating a pull request

A gate fails only when a paired bootstrap says the regression is real — never on a single point estimate.

verdict = fl.gate(run["id"], baseline="main", gates=[
    {"metric": "event_f1",  "min_delta": -0.01},
    {"metric": "fa_per_min", "max_delta": 0.05, "slice": "tags.night"},
])

from framelens import raise_for_gates
raise_for_gates(verdict)      # FrameLensGateFailed, with a readable table

Inside your own test suite

Installing the SDK auto-registers a pytest plugin (via the pytest11 entry point) — no conftest.py wiring:

def test_no_regression(framelens_eval):
    result = framelens_eval(
        project_id, dataset_id=dataset_id, model_config_id=model_config_id,
        gates=[{"metric": "event_f1", "min_delta": -0.01}])
    result.assert_gates()
    assert result.metric("event_f1") > 0.8

Point it at a server with --framelens-url / --framelens-key (or FRAMELENS_API_URL / FRAMELENS_API_KEY), and use --framelens-subset smoke so a PR gates a smoke subset while the nightly gates the full suite.

Async

AsyncFrameLens mirrors the sync client method for method:

from framelens import AsyncFrameLens

async with AsyncFrameLens(api_key=..., base_url=...) as fl:
    run = await fl.run(project_id, dataset_id=..., model_config_id=...)
    run = await fl.wait(run["id"])

Failures are typed, and carry the request id

Every error inherits from FrameLensError and carries the server's request_id, so a failure in your CI log is findable in the server's:

FrameLensAuthError · FrameLensPermissionError · FrameLensNotFoundError · FrameLensValidationError · FrameLensRateLimited · FrameLensServerError · FrameLensConnectionError · FrameLensTimeoutError · FrameLensVersionError · FrameLensRunFailed · FrameLensGateFailed

Transient failures retry with jittered backoff honouring Retry-After: a 429 for every method (refused ⇒ not executed), a 5xx or transport error only where repeating is safe — GET/DELETE plus the POSTs the API makes idempotent.

fl = FrameLens(api_key=..., base_url=..., timeout=30.0,
               verify="/etc/ssl/corp-ca.pem")   # also: transport=, client=

Large collections

List routes are cursor-paginated and capped; the SDK follows the cursor for you.

for prediction in fl.iter_predictions(run_id):   # streams, follows next_cursor
    ...
cases = fl.list_cases(dataset_id)                # same, materialised

Versioning

Semver, pre-1.0: a minor bump may change behaviour, a patch may not. framelens.API_VERSION is the API contract this client was written against and is sent on every request, so an unsupported server answers at the first call rather than deep inside a job.

Licence

Apache-2.0. The full text ships inside the package (LICENSE).

Metadata

Release files for framelens 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for framelens 0.4.1
File Size Uploaded Provenance Actions
framelens-0.4.1.tar.gz 26.7 kB With provenance Details for framelens-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for framelens 0.4.1
File Interpreter ABI Platform Actions
framelens-0.4.1-py3-none-any.whl Python 3 none any Details for framelens-0.4.1-py3-none-any.whl

Total release size: 52.6 kB

Release files / framelens-0.4.1.tar.gz

Download URL framelens-0.4.1.tar.gz
Size 26.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a983dd2a406c87fc12c3ca6f64de817c0c3e9b0fb7ce446c51c6071a1db9c778
BLAKE2b-256 checksum
How to use checksums
5e6b4b8725fbfd5d5d7cfeabc82e89112f7f1ed11a822001cdeb3703391d9e8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / framelens-0.4.1-py3-none-any.whl

Download URL framelens-0.4.1-py3-none-any.whl
Size 25.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ad3668febad61c42d70f4eb4f34410dd3d4f89ec99b37295715304a763861a1
BLAKE2b-256 checksum
How to use checksums
52312d1976c0093a5739fc27ea69857bcb5f00f72c8193eb52994f007fc5144f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for framelens 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for framelens-0.4.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page