Skip to main content

Interhuman Python SDK

interhumanai is the first-party Python client for the Interhuman API. It wraps authentication, client tokens, video upload analysis, and the live stream and real-time WebSocket protocols behind a typed, asyncio-first API — no hand-rolled token exchange, multipart bodies, or WebSocket envelope parsing.

Installation

pip install interhumanai

Requires Python 3.10+. Runtime dependencies: httpx, websockets, pydantic.

The SDK is asyncio-first: every network call is a coroutine. Use asyncio.run() in scripts and top-level await in notebooks. The live stream and real-time surfaces are inherently event-driven, so a single async API keeps every surface consistent (and mirrors the promise-based TypeScript SDK).

Quickstart

import asyncio
from interhumanai import InterhumanClient

async def main() -> None:
    client = InterhumanClient(key_id="...", key_secret="...")
    result = await client.upload.analyze("meeting.mp4")
    for signal in result.signals:
        print(signal.type.value, signal.start, signal.end)

asyncio.run(main())

Authentication

Two ways to authenticate:

  • API key credentials (key_id + key_secret): the client exchanges them at POST /v1/auth for a short-lived bearer token and refreshes it automatically before expiry.
  • Pre-issued token (access_token): a JWT or client token used as-is.
from interhumanai import InterhumanClient, Scope

# Managed credentials (recommended for servers)
client = InterhumanClient(key_id="...", key_secret="...", scopes=[Scope.UPLOAD, Scope.STREAM])

# Pre-issued bearer token
client = InterhumanClient(access_token="eyJ...")

The standalone AuthClient exposes the token endpoints directly, and TokenManager / StaticTokenProvider are available when you need to plug a custom token source into the lower-level clients.

Client tokens (browser / untrusted clients)

Mint short-lived, capped tokens server-side so untrusted clients never see the API key:

from interhumanai import AuthClient, Scope

auth = AuthClient()
token = await auth.create_client_token(
    api_key="ih_...",
    scopes=[Scope.STREAM],
    expires_in=300,            # clamped to 60-3600 seconds by the API
    max_concurrent=1,
    max_video_seconds=600,
    allowed_origins=["https://app.example.com"],
)
await auth.revoke_client_token(api_key="ih_...", token=token.access_token)

Upload API

Analyze a complete video file (mp4, avi, mov, mkv, mpeg-ts, or webm; at least 3 seconds, at most 32 MB):

from interhumanai import GoalDimension, IncludeFlag

result = await client.upload.analyze(
    "meeting.mp4",                                        # path, bytes, or file object
    include=[IncludeFlag.CONVERSATION_QUALITY_OVERALL],   # optional sections
    goal_dimensions=[GoalDimension.CLARITY],              # enables feedback
)

The typed AnalysisResult carries signals, engagement_state, and — when requested — feedback and conversation_quality.

Every Signal carries a modality naming the analyses whose evidence produced it. Upload and Stream analyze with Inter-1 alone, so theirs always read ["video"]; a real-time signal seen by several tracks lists each one, e.g. ["audio", "video", "visual"].

Stream API

One StreamClient handles one live session against WS /v1/stream/analyze. Send binary WebM or fragmented-MP4 chunks and consume typed events with async for:

from interhumanai import IncludeFlag, SignalDetectedEvent

async with client.stream() as session:
    await session.wait_for_session_ready()
    await session.update_config(include=[IncludeFlag.CONVERSATION_QUALITY_OVERALL])
    await session.send_video(first_chunk)   # first chunk carries the container header
    await session.request_close()           # graceful drain; close() tears down immediately
    async for event in session:
        if isinstance(event, SignalDetectedEvent):
            print(event.data.signal_type.value, event.data.start)

Iteration ends when the connection closes; session.close_info then holds the close code and reason. Event types this SDK version does not know arrive as UnknownEvent instead of failing the session.

Real-Time API

RealtimeClient targets WS /v0/realtime/analyze — a temporary v0 public release that accepts either the stream or the realtime scope. On top of the stream protocol it adds multi-track analysis configuration, client transcripts, and transcript/recommendation output (it never emits engagement or conversation-quality events). The previous hyphenated spelling WS /v0/real-time/analyze still works as a temporary compatibility alias; new integrations should use WS /v0/realtime/analyze:

from interhumanai import AnalysisGroup, RealtimeRecommendationFrequency, RealtimeRecommendationGeneratedEvent, TranscriptSegment

async with client.realtime() as session:
    await session.wait_for_session_ready()
    await session.update_config(
        analysis_groups=[AnalysisGroup.AUDIO, AnalysisGroup.VISUAL],
        realtime_recommendation_frequency=RealtimeRecommendationFrequency.MEDIUM,
        realtime_recommendation_instructions="Coach the presenter.",   # non-empty value enables recommendations
    )
    await session.send_transcript([TranscriptSegment(start=0.0, end=2.0, text="Hi.", speaker=0)])
    async for event in session:
        if isinstance(event, RealtimeRecommendationGeneratedEvent):
            print(event.data.text)

The VISUAL analysis group reports its negative signal as SignalType.TENSION, while the AUDIO group (and Inter-1) reports SignalType.FRUSTRATION. They describe the same state seen versus heard, and both can be active at once, each with its own signal lifecycle. SignalType.TENSION is real-time only — the upload and stream surfaces never emit it — so code that branches on signal_type should handle both.

Errors

Three surfaces, mirroring the API:

  • InterhumanAPIError — raised for non-2xx HTTP responses (with status, error_id, correlation_id, link) and for transport failures (status == 0).
  • InterhumanConfigError — raised for client-side misuse before any network call (missing credentials, sending on a closed session, double connect).
  • WebSocket error envelopes are delivered as ErrorEvents through iteration, not raised — fatal ones are followed by the connection closing.

Environments

InterhumanClient(key_id=..., key_secret=...)                          # production (default): api.interhuman.ai
InterhumanClient(key_id=..., key_secret=..., environment="staging")   # staging-api.interhuman.ai
InterhumanClient(key_id=..., key_secret=..., base_url="http://localhost:8080")  # local override

WebSocket URLs are derived automatically (https:// → wss://).

Examples

Runnable scripts for every flow live in examples/: auth.py, client_tokens.py, upload.py, stream.py, and realtime.py.

Development

The SDK lives in the interhuman-api repository under sdk/python/. Its tests live in tests/sdk/python/ and run with the repository's main suite:

uv run pytest tests/sdk/python

API reference docs

The reference documentation on docs.interhuman.ai is generated from this package's docstrings and type metadata — do not hand-write it. Edit the docstrings in src/interhumanai/, then regenerate:

python scripts/build_mintlify_docs.py   # docstrings → Mintlify MDX in docs-dist/mintlify/

On every push to main that touches the SDK, the Sync Docs to interhuman-docs workflow regenerates this page and opens a PR against the interhuman-docs repository. That workflow keeps a single rolling docs-sync PR open — a later run updates it in place instead of opening another one.

Releasing

This package is versioned in lockstep with the TypeScript SDK (@interhumanai/sdk): both always carry the same version and release together from a single workflow. Publishing is automatic and deploy-gated: bump __version__ in src/interhumanai/_version.py and the version in sdk/typescript/package.json to the same value (semver), add a CHANGELOG.md entry to each package, and merge to main. After the Deploy workflow succeeds, the SDK release workflow builds, tests, and publishes both packages (idempotently per registry), then tags the commit sdk-v<version>. See docs/sdk-release.md for details.

License

Apache-2.0

Metadata

Release files for interhumanai 0.11.0

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

Source distribution (sdist)

Source distribution for interhumanai 0.11.0
File Size Uploaded Provenance Actions
interhumanai-0.11.0.tar.gz 26.7 kB Without provenance Details for interhumanai-0.11.0.tar.gz

Built distribution (wheel)

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

Total release size: 58.0 kB

Release files / interhumanai-0.11.0.tar.gz

Download URL interhumanai-0.11.0.tar.gz
Size 26.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dfe435ce68a6b4013165af68f3028bce21ad31d6b38f8527b522b599447be135
BLAKE2b-256 checksum
How to use checksums
e4a8513f1fb72367f8d32462691b7c1f4a459277af08318f6c98d13aed4c6244
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / interhumanai-0.11.0-py3-none-any.whl

Download URL interhumanai-0.11.0-py3-none-any.whl
Size 31.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90e47a3a010c01e5123497bf9617a89b5d6e924625e14c04340317549f3c3905
BLAKE2b-256 checksum
How to use checksums
a76ae24939f5b45b3fe6a43ba7a4a07677cf113364f1701044b80251c1fa6a5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for interhumanai 0.11.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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