Skip to main content

Clone Python SDK

Server-side synchronous and asynchronous clients for Clone predictions, usage, observation events, cancellation and optional user-approved Clone connections. Composer UI stays in the JavaScript SDK. This client never submits a user message.

Python 3.11+. The candidate distribution is clone-sdk; import clone_sdk. Until the first PyPI publication, install the verified wheel from the release.

pip install ./clone_sdk-0.2.0-py3-none-any.whl
import os
from clone_sdk import CloneClient

with CloneClient(os.environ["CLONE_APP_KEY"]) as client:
    result = client.predict(
        "subject-from-your-authenticated-session",
        {
            "request_id": "prediction-001",
            "session_id": "conversation-001",
            "context_revision": "1",
            "mode": "next_prompt",
            "draft": {"text": "", "revision": 0},
            "messages": [{"role": "user", "content": "Draft a product announcement.", "origin": "human"}],
            "language": "en",
        },
    )
    print(result.status)

For FastAPI or other async servers, use async with AsyncCloneClient(...) and await client.predict(...). Reuse a client for the application's lifetime and close it during shutdown. The async client enforces a total 15-second deadline, including body reads. The sync client uses 15-second per-I/O timeouts and checks the elapsed budget between response chunks. Both bound concurrency to 16 by default, reject saturation without queuing, limit response bodies to 1 MiB, and never automatically retry potentially billable work. Override timeout up to 30 seconds and max_concurrent_requests up to 1,000 after measuring your load.

Derive user_id from your server session; the client overwrites an untrusted body's user_id. Keep the app key exclusively on your backend. HTTPS is required except loopback development. Redirects are not followed. Client errors expose only a safe code, HTTP status and numeric retry_after, never response text.

Keep the same request ID and exact body when reconciling an unknown result. Hide failed predictions and keep your editor and manual send path independent. Response identity is checked; the host still owns expiry, rendering, Tab/Undo, session changes and successful-send acknowledgments.

Optional personalization uses started, flow = client.connect(user_id, redirect_uri) to create a PKCE flow (or started, flow = await client.connect(...) for async). Store the returned flow in a server session, redirect the user to started.authorize_url, then call exchange(flow, callback, authenticated_user_id). State, request and subject must match. The flow contains a secret verifier and must not be logged or serialized to browser storage. Basic predictions need no Clone end-user account.

client.record_event(
    subject,
    {
        "event_id": "event-001",
        "request_id": "prediction-001",
        "kind": "presented",
    },
)
usage = client.usage()
client.cancel(subject, "prediction-001")

Only report submitted after your host accepts the send. Reuse an event ID on delivery retries. Events contain no prompt text and do not change billing. Read the public API, billing and reliability contracts before production use.

Development: uv sync, uv run pytest, uv run ruff check ., uv build and uv run twine check dist/*. All ordinary tests use local or mocked transports; they do not establish model quality or customer adoption.

Metadata

Release files for clone-sdk 0.2.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 clone-sdk 0.2.0
File Size Uploaded Provenance
clone_sdk-0.2.0.tar.gz 56.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for clone-sdk 0.2.0
File Interpreter ABI Platform
clone_sdk-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 64.3 kB

Release files / clone_sdk-0.2.0.tar.gz

Download URL clone_sdk-0.2.0.tar.gz
Size 56.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b129d5f9672d733fde745637c4514c293bfddf4364d1e509d9274a0db16437f2
BLAKE2b-256 checksum
How to use checksums
7ba0e59fc8da50ed2a210ee268ed248089519d2f119c7d960d544260d24502ae
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 Oct 4, 2026.

Transparency log

Release files / clone_sdk-0.2.0-py3-none-any.whl

Download URL clone_sdk-0.2.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7fba84288ff25c989a6a5faed2027006bfea1e894e7eab16980c2d297d4c002d
BLAKE2b-256 checksum
How to use checksums
0e26ffca88efc622d8c5a43524bb00aee8638d8f3d1adde701a57be0083c795d
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 Oct 4, 2026.

Transparency log

Security for clone-sdk 0.2.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for clone_sdk-0.2.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 4, 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.

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