Skip to main content

CAVI API Client for Python

Native async lifecycle clients for Claude Messages, Claude Managed Agents, Codex Responses, AGY, Hermes, OpenCode, and OpenClaw. Python 3.11+ is required. Native clients connect directly to provider servers; Node and npm are unnecessary.

The Python distribution is named cavi-api-client, matching @cavi-ai/api-client on npm. Import the Python clients from cavi_runtime.

Version 0.21.0 includes OpenCode api_version=2 and Managed Agents observe_run_completion=True. See the provider compatibility guide for setup and supported operations.

Install from this repository before the first PyPI release:

python -m pip install ./python

HTTPX handles HTTP transport. OpenClaw additionally requires the optional WebSocket transport: python -m pip install './python[openclaw]'.

import asyncio
import os
from cavi_runtime import create_runtime_client

async def main():
    async with create_runtime_client(
        "codex-responses", api_key=os.environ["OPENAI_API_KEY"],
        default_model="YOUR_MODEL",
    ) as client:
        run = await client.start_run({"input": "Explain this code"})
        print(run["run_id"], run["status"])

asyncio.run(main())

Runs may remain active. Retrieve them with get_run; use cancel_run only for explicit backend cancellation. require_run_text accepts completed text and preserves explicit empty output. Native clients expose lifecycle operations, not streaming, batches, or provider control planes.

Version 0.22.0 provides wait_for_run on native and bridge clients, plus a standalone cavi_runtime.wait_for_run(client, run, ...) helper. The result contains reason, the last observed run, and the retrieval count polls. Defaults are 60 polls, a one-second delay before each poll, and a 60-second local deadline including in-flight retrievals. Configure max_polls, poll_interval, and max_wait in seconds. Terminal results include failed and cancelled runs; use require_run_text only when your application requires successful text.

An optional cancel_event=asyncio.Event() stops the local wait with reason: "aborted". Cancelling the waiting task propagates CancelledError. Neither action cancels backend work or an in-flight retrieval. Keep the client open for its request to finish; provider errors after the local wait ends are consumed. Explicit backend cancellation remains cancel_run.

OpenClaw normalizes ok to completed and error to failed, retaining the original value as provider_status. Text preserves whitespace and empty strings. Managed Agents retrieves chronological agent.message text for completed sessions across at most 100 event pages, bounded by the request deadline and the response byte limit for accumulated text. Tool and user events are excluded. Managed Agents requires existing agent_id and environment_id configuration. Set metadata.agent_version on start_run to pin a version; omitting it selects the latest agent version when the session is created. OpenCode closes by stopping active submissions and attempting session aborts before releasing its HTTP transport. Cancelling close does not cancel cleanup; call close again to wait for it.

The optional RuntimeClient.connect bridge remains available for existing applications using a TypeScript adapter; only that mode requires Node.

Metadata

Release files for cavi-api-client 0.22.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 cavi-api-client 0.22.0
File Size Uploaded Provenance Actions
cavi_api_client-0.22.0.tar.gz 31.5 kB With provenance Details for cavi_api_client-0.22.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cavi-api-client 0.22.0
File Interpreter ABI Platform Actions
cavi_api_client-0.22.0-py3-none-any.whl Python 3 none any Details for cavi_api_client-0.22.0-py3-none-any.whl

Total release size: 58.9 kB

Release files / cavi_api_client-0.22.0.tar.gz

Download URL cavi_api_client-0.22.0.tar.gz
Size 31.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c6110cca5eb7c3dfb13422bd43bea89ec605c5da89a759405eacd2a2e646b4bb
BLAKE2b-256 checksum
How to use checksums
1e76ab3724812ea8d42d7680b9188b3368f869d6bcc47da73ebb9fcb756b15c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 21, 2026.

Transparency log

Release files / cavi_api_client-0.22.0-py3-none-any.whl

Download URL cavi_api_client-0.22.0-py3-none-any.whl
Size 27.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c42bf2a12247d97e8c7d7130d147ca2dad074ec31b61acb019741db10696fcf4
BLAKE2b-256 checksum
How to use checksums
98677534b0c27504947e2f2e4a17a1dd8d3684e37980e0a556573e4c081bf172
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 21, 2026.

Transparency log

Security for cavi-api-client 0.22.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.

Full provenance

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

Select from 2 files

Attestation for cavi_api_client-0.22.0.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 Oct 21, 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.

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