Skip to main content

pithio for Python

Shorter context for AI applications, without losing the answer. Runs on your machine; whatever is removed can be fetched back.

import pithio

r = pithio.compress(document, "Which law governs the agreement?", mode="text", keep=0.5)
print(r.ratio, r.tokens_in, r.tokens_out)   # achieved compression and o200k token counts
print(r.text)                               # the most relevant paragraphs, verbatim; removed parts marked
pithio.more(r.handle)                       # the original, page by page
  • mode="text": documents and retrieved passages; keeps the paragraphs most relevant to the query.
  • mode="auto": detects JSON, CSV, logs, test runs, web pages and prose, and uses the method made for each.
  • compress_messages(messages): shortens the tool results inside an OpenAI or Anthropic chat request.

Agents on the Anthropic or OpenAI SDK: one line

import anthropic, pithio

client = pithio.wrap(anthropic.Anthropic())      # also openai.OpenAI() and the async clients

# in your tool loop, before your own tools:
result = pithio.handle_tool_call(block.name, block.input)
if result is not None:
    ...                                           # send it back as that tool call's result

Every messages.create, chat.completions.create and responses.create request has its tool results shortened (the tool call that produced each is its query); nothing else in the request changes, and the same input always gives the same bytes, so the provider's prompt cache keeps working. Requests with tools get a pithio_more tool through which the model fetches anything that was removed. Each call's usage and the request's make-up (token counts, never text) go to ~/.pithio/calls.jsonl: pithio diagnose --source api and the dashboard's Bill tab show where the money goes. Replies, streamed or not, are returned unchanged. Not covered yet: the SDKs' messages.stream() / responses.stream() helpers.

Integrations: pithio.integrations.langchain.PithioCompressor (a document compressor for retrievers), pithio.integrations.llamaindex.PithioNodePostprocessor, pithio.integrations.litellm.PithioGuardrail (a LiteLLM proxy hook that shortens tool results before each model call).

Metadata

Release files for pithio-sdk 0.1.1

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

Source distribution (sdist)

Source distribution for pithio-sdk 0.1.1
File Size Uploaded Provenance Actions
pithio_sdk-0.1.1.tar.gz 1.3 MB With provenance Details for pithio_sdk-0.1.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pithio-sdk 0.1.1
File Actions
pithio_sdk-0.1.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for pithio_sdk-0.1.1-cp310-abi3-win_amd64.whl
pithio_sdk-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for pithio_sdk-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl
pithio_sdk-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for pithio_sdk-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
pithio_sdk-0.1.1-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64), macOS 11.0+ ARM64, macOS 10.12+ x86-64 Details for pithio_sdk-0.1.1-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Total release size: 24.2 MB

Release files / pithio_sdk-0.1.1.tar.gz

Download URL pithio_sdk-0.1.1.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
4f867668abc7e719b7fdd48024187b60713933d443506227f7ef005740b1cf27
BLAKE2b-256 checksum
How to use checksums
66aab39426dda0620bebb4ef0258e5d985144301e2fb34128d95f75cc9283ac6
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 Dec 3, 2026.

Transparency log

Release files / pithio_sdk-0.1.1-cp310-abi3-win_amd64.whl

Download URL pithio_sdk-0.1.1-cp310-abi3-win_amd64.whl
Size 4.4 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
5d6ab422c8ae2b53ce420c57ea51cb6702be13ba85960c7ac027e699fd2e5b5d
BLAKE2b-256 checksum
How to use checksums
c36cd9cb6485e9d682b45b0ee56cebffed1f801bf3a0167f96e2ed399cd7a550
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 Dec 3, 2026.

Transparency log

Release files / pithio_sdk-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL pithio_sdk-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl
Size 4.7 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
1e60b312a168fb4ba8d8b3a6718f1d0b97d99a935999f76ba8bc6e9504ba91f4
BLAKE2b-256 checksum
How to use checksums
6a31ababfe4fa4bf43d31aa7e0f0a4ab62e1b6f58401ea5f965256200a81d176
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 Dec 3, 2026.

Transparency log

Release files / pithio_sdk-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pithio_sdk-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 4.8 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
0e211a89b71eb0a6f950811f5897c12b8195a08b9e1a6e0a7f716783d4c34c80
BLAKE2b-256 checksum
How to use checksums
cddb393c9bfbf94d0af1ae95d4eafe62c6d0f56215eac2cd22e0d4a1bb649efd
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 Dec 3, 2026.

Transparency log

Release files / pithio_sdk-0.1.1-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Download URL pithio_sdk-0.1.1-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 9.0 MB
Tags CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e1a162620bf16ca8e6f7283ba6bbe582954f051912f5a7bc6b115fd09cd8749c
BLAKE2b-256 checksum
How to use checksums
a7f744b8de285772d456be3ae4b7ae3d79f2258f509c5c628de305e66fb87aff
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 Dec 3, 2026.

Transparency log

Security for pithio-sdk 0.1.1

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 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for pithio_sdk-0.1.1.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 Dec 3, 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