Skip to main content

Python SDK for OnceOnly idempotency API

Project description

OnceOnly Python SDK

The Idempotency Layer for AI Agents, Webhooks, and Distributed Systems.

OnceOnly is a high-performance Python SDK that ensures exactly-once execution. It prevents duplicate actions (payments, emails, tool calls) in unstable environments like AI agents, webhooks, retries, or background workers.

Website: https://onceonly.tech/ai/
Documentation: https://onceonly.tech/docs/


Features

  • Sync + Async client (httpx-based)
  • Fail-open mode for production safety
  • Stable idempotency keys (supports Pydantic & dataclasses)
  • Decorator for zero-boilerplate usage
  • Optional AI / LangChain integrations

Installation

pip install onceonly-sdk

With LangChain support included:

pip install "onceonly-sdk[langchain]"

Quick Start

from onceonly import OnceOnly

client = OnceOnly(
    api_key="once_live_...",
    fail_open=True  # default: continues if API is down
)

res = client.check_lock(key="order:123", ttl=300)

if res.duplicate:
    print("Duplicate blocked")
else:
    print("First execution")

AI Agents / LangChain Integration 🤖

OnceOnly integrates cleanly with AI-agent frameworks like LangChain.

from onceonly.integrations.langchain import make_idempotent_tool

tool = make_idempotent_tool(
    original_tool,
    client=client,
    key_prefix="agent:tool"
)

Repeated tool calls with the same inputs will execute exactly once, even across retries or agent restarts.


Decorator

from onceonly.decorators import idempotent

@idempotent(client, ttl=3600)
def process_order(order_id):
    ...

Idempotency keys are generated automatically and are stable across restarts.


Fail-Open Mode

Fail-open is enabled by default.

Network errors, timeouts, or server errors (5xx) will not break your application. The SDK will allow execution to continue safely.

Fail-open never applies to:

  • Auth errors (401 / 403)
  • Plan limits (402)
  • Validation errors (422)
  • Rate limits (429)

Support

Need help?
Email: support@onceonly.tech
Or open an issue on GitHub.


License

MIT

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

onceonly_sdk-2.0.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

onceonly_sdk-2.0.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file onceonly_sdk-2.0.0.tar.gz.

File metadata

  • Download URL: onceonly_sdk-2.0.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for onceonly_sdk-2.0.0.tar.gz
Algorithm Hash digest
SHA256 e026fa4d7ecfb4595d15d55ff94d1a20b0dd3ed482b231b5c67443e74834ebd6
MD5 409544c355458bcc028f75fdb1b09a41
BLAKE2b-256 d6f2f20f8ecbc2e16dd29248ab4c5c39be9ffee0a51e55726fa27dea632deac9

See more details on using hashes here.

Provenance

The following attestation bundles were made for onceonly_sdk-2.0.0.tar.gz:

Publisher: release.yml on mykolademyanov/onceonly-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file onceonly_sdk-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: onceonly_sdk-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for onceonly_sdk-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38b500712c163a0d1200479baaaeee20b449fcdd8ce3b2ce9d7541dc0787109e
MD5 787b9d0debfcae0a7f7f1d12055d5aea
BLAKE2b-256 ebf9fe791387a31cc4df6373c3440e9170ff5d0dc509f1ceb40aa13a51998719

See more details on using hashes here.

Provenance

The following attestation bundles were made for onceonly_sdk-2.0.0-py3-none-any.whl:

Publisher: release.yml on mykolademyanov/onceonly-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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