Skip to main content

Official Python SDK for the Primate Vision API (Primate Intelligence). Video scene understanding: upload, analyze, stream.

Project description

primate-intelligence

Official Python SDK for the Primate Vision API by Primate Intelligence — video scene understanding: upload a video, ask a question, get a deterministic answer with confidence and clip timestamps.

Status: built in-repo from the OpenAPI spec (GET /v1/openapi.json). Not yet published to PyPI — install from the repo until the first public release.

Install

pip install primate-intelligence

Requires Python 3.10+.

Quickstart

from primate_intelligence import Primate

client = Primate()  # reads PRIMATE_API_KEY from the environment

video = client.videos.create(url="https://example.com/clip.mp4")
analysis = client.analyses.create_and_wait(
    video_id=video["id"],
    prompt="Is there a person in this video?",
)
print(analysis["result"]["answer"], analysis["result"]["confidence"])

Get a free test key with no signup:

curl -X POST https://api.primateintelligence.ai/v1/sandbox

Features

  • Typed resource namespaces for the full /v1 surface: videos, analyses, streams, client_tokens, models, usage, errors, webhook_endpoints.
  • Automatic retries driven by the error registry retryable flags + Retry-After.
  • Auto idempotency keys (UUIDv4) on all create calls.
  • create_and_wait() — create an analysis and block until a terminal state (uses Prefer: wait server-side, then polls).
  • videos.upload() — create + presigned S3 PUT + complete, in one call.
  • Pagination iteratorsfor video in client.videos.iter(): ….
  • Webhook verificationverify_webhook() implements Standard Webhooks with constant-time compare + replay-window checks.

Error handling

from primate_intelligence import Primate, PrimateError

client = Primate()
try:
    client.analyses.create(video_id="video_x", prompt="hi")
except PrimateError as err:
    print(err.code, err.status, err.request_id, err.docs_url)
    if err.code == "insufficient_credits":
        usage = client.usage.retrieve()
        # → prompt the account owner to top up or enable auto-refill

Every error carries code, status, request_id, and a docs_url anchor into the error registry. Retryable codes are retried automatically before the exception reaches you.

Webhooks

from primate_intelligence import verify_webhook_request

@app.post("/webhooks/primate")
async def receive(request: Request):
    raw = await request.body()
    verify_webhook_request(
        secret=os.environ["PRIMATE_WEBHOOK_SECRET"],  # whsec_…
        headers=dict(request.headers),
        raw_body=raw,
    )  # raises ValueError on bad signature / stale timestamp
    # dedupe on the webhook-id header — delivery is at-least-once
    return Response(status_code=204)

Configuration

Kwarg Env var Default
api_key PRIMATE_API_KEY — (required)
base_url PRIMATE_BASE_URL https://api.primateintelligence.ai
max_retries 3
timeout_s 60.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

primate_intelligence-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

primate_intelligence-0.1.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file primate_intelligence-0.1.0.tar.gz.

File metadata

  • Download URL: primate_intelligence-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for primate_intelligence-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e12bf95faef11525203f2dcbd2fc6324b1ad34ab445f08c0ca87b1cd3de09cff
MD5 73309a3ea9fba18297cf5e3f5f5c3c71
BLAKE2b-256 2bbbb94a42b8557a73783d05c8444fcb2168aaaaea388c3abd244c577d84f021

See more details on using hashes here.

File details

Details for the file primate_intelligence-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for primate_intelligence-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2651982489e828ce52977a4299dbae613e2c261582d19cab9dd4b6bde482e66e
MD5 521ad257a18639535d6a33d773af0226
BLAKE2b-256 2b3e29c3e1ed1d60036a6e18facf1f9524678aa8081f98a17d2f8bb2f53c2bd3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page