Public Python SDK for calling remote functions, with sync and async clients.
Project description
paperclip-sdk
Python SDK for calling server-hosted Paperclip tools from scripts, workers, web apps, and async services.
Use it when you want to keep business logic, pricing rules, private workflows, or customer-specific functionality on the server while calling it from Python through a small client.
Install
poetry add paperclip-sdk
or
pip install paperclip-sdk
Authentication
The SDK reads the API key from LEASEKEY_API_KEY by default:
export LEASEKEY_API_KEY="your-api-key"
The default base URL is https://leasekey.org. For self-hosted or local servers, pass a custom base_url.
Quickstart
Sync
from paperclip_sdk import Paperclip
with Paperclip() as paperclip:
result = paperclip.tools.core.hello_world(name="Ada")
print(result)
Async
import asyncio
from paperclip_sdk import AsyncPaperclip
async def main() -> None:
async with AsyncPaperclip() as paperclip:
result = await paperclip.tools.core.hello_world(name="Ada")
print(result)
asyncio.run(main())
Tool access styles
The SDK supports three equivalent ways to call the same tool.
Sync
from paperclip_sdk import Paperclip
with Paperclip() as paperclip:
print(paperclip.tools.core.hello_world(name="Ada"))
print(paperclip.core.hello_world(name="Ada"))
print(paperclip["core.hello_world"](name="Ada"))
Async
import asyncio
from paperclip_sdk import AsyncPaperclip
async def main() -> None:
async with AsyncPaperclip() as paperclip:
print(await paperclip.tools.core.hello_world(name="Ada"))
print(await paperclip.core.hello_world(name="Ada"))
print(await paperclip["core.hello_world"](name="Ada"))
asyncio.run(main())
Use a specific server
Sync
from paperclip_sdk import Paperclip
with Paperclip(
base_url="http://127.0.0.1:8889",
api_key="your-api-key",
) as paperclip:
result = paperclip.tools.core.hello_world(name="Ada")
print(result)
Async
import asyncio
from paperclip_sdk import AsyncPaperclip
async def main() -> None:
async with AsyncPaperclip(
base_url="http://127.0.0.1:8889",
api_key="your-api-key",
) as paperclip:
result = await paperclip.tools.core.hello_world(name="Ada")
print(result)
asyncio.run(main())
Discover available tools
Use paperclip.list_tools() for the flat tool list or paperclip.manifest() for the full manifest payload.
Sync
from paperclip_sdk import Paperclip
with Paperclip() as paperclip:
print(paperclip.list_tools())
Async
import asyncio
from paperclip_sdk import AsyncPaperclip
async def main() -> None:
async with AsyncPaperclip() as paperclip:
print(await paperclip.list_tools())
asyncio.run(main())
Error handling
By default, the SDK uses suppress_errors=True.
That means failed calls can return None instead of raising immediately, and the captured failure is available in last_error.
Sync
from paperclip_sdk import Paperclip
with Paperclip(suppress_errors=True) as paperclip:
result = paperclip.tools.core.hello_world(name="Ada")
if result is None:
print("Call failed:", paperclip.last_error)
Async
import asyncio
from paperclip_sdk import AsyncPaperclip
async def main() -> None:
async with AsyncPaperclip(suppress_errors=True) as paperclip:
result = await paperclip.tools.core.hello_world(name="Ada")
if result is None:
print("Call failed:", paperclip.last_error)
asyncio.run(main())
To raise failures immediately, disable suppressed errors:
Sync
from paperclip_sdk import Paperclip
with Paperclip(suppress_errors=False) as paperclip:
result = paperclip.tools.core.hello_world(name="Ada")
print(result)
Async
import asyncio
from paperclip_sdk import AsyncPaperclip
async def main() -> None:
async with AsyncPaperclip(suppress_errors=False) as paperclip:
result = await paperclip.tools.core.hello_world(name="Ada")
print(result)
asyncio.run(main())
Debug logging
from paperclip_sdk import Paperclip
with Paperclip(
base_url="http://127.0.0.1:8889",
debug=True,
log_server_meta=True,
) as paperclip:
result = paperclip.tools.core.hello_world(name="Ada")
print(result)
Notes
- Tools can be accessed as
paperclip.tools.<namespace>.<name>(...) - Masked namespace access is also supported:
paperclip.<namespace>.<name>(...) - Flat concrete tool access is also supported:
paperclip["<namespace>.<name>"](...) - Registered tools can be discovered with
paperclip.list_tools() - The full manifest is available with
paperclip.manifest() - The default base URL is
https://leasekey.org - The SDK automatically sends
User-Agent: paperclip-sdk/<version> - The SDK also sends
X-Leasekey-SDK-Version: <version> - Built-in retry behavior covers retryable transport failures and these HTTP statuses:
408,425,429,502,503,504
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file paperclip_sdk-0.6.1.tar.gz.
File metadata
- Download URL: paperclip_sdk-0.6.1.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92beeee0702fccb670748a5660aeb4831785e45c30a4947d57156b9f2f4418eb
|
|
| MD5 |
f47fb1afd04387dedacd80b74287c6c0
|
|
| BLAKE2b-256 |
e32151f844c5480fe102af8297a79ea83ad70e32aaff2a621cc903432b38ba00
|
Provenance
The following attestation bundles were made for paperclip_sdk-0.6.1.tar.gz:
Publisher:
publish.yml on leasekey-org/paperclip-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
paperclip_sdk-0.6.1.tar.gz -
Subject digest:
92beeee0702fccb670748a5660aeb4831785e45c30a4947d57156b9f2f4418eb - Sigstore transparency entry: 1191982462
- Sigstore integration time:
-
Permalink:
leasekey-org/paperclip-server@bbf90b746a2c7f56e6a6e9bf1cd194b9d6ce0401 -
Branch / Tag:
refs/tags/v0.6.1 - Owner: https://github.com/leasekey-org
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bbf90b746a2c7f56e6a6e9bf1cd194b9d6ce0401 -
Trigger Event:
release
-
Statement type:
File details
Details for the file paperclip_sdk-0.6.1-py3-none-any.whl.
File metadata
- Download URL: paperclip_sdk-0.6.1-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37c72e44227a6bc609d7c121f849fe0ce991e2242ba6aed8ffea3f7ccba7868c
|
|
| MD5 |
c9b62954f6020d603b9b74fc6fe83eef
|
|
| BLAKE2b-256 |
d140164dc3f2a3e6e9e734b5d8da27f6956200e6d4501810e6ac765b300fb5ed
|
Provenance
The following attestation bundles were made for paperclip_sdk-0.6.1-py3-none-any.whl:
Publisher:
publish.yml on leasekey-org/paperclip-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
paperclip_sdk-0.6.1-py3-none-any.whl -
Subject digest:
37c72e44227a6bc609d7c121f849fe0ce991e2242ba6aed8ffea3f7ccba7868c - Sigstore transparency entry: 1191982463
- Sigstore integration time:
-
Permalink:
leasekey-org/paperclip-server@bbf90b746a2c7f56e6a6e9bf1cd194b9d6ce0401 -
Branch / Tag:
refs/tags/v0.6.1 - Owner: https://github.com/leasekey-org
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bbf90b746a2c7f56e6a6e9bf1cd194b9d6ce0401 -
Trigger Event:
release
-
Statement type: