obol — Python binding (ctypes)
Installing from PyPI:
pip install primeradianthq-obol, thenimport obol. The native library is bundled in the wheel — no Rust toolchain, nocargo build, noOBOL_LIB. The sections below are for in-repo development.
A thin, pure-Python binding over obol's C ABI (obol-ffi). No build step: it loads the
prebuilt shared library with ctypes and re-types the JSON the Rust core returns. The Rust
core stays the single source of truth for all accounting; this package only marshals C
strings and parses JSON into dataclasses.
Install / point at the library
The binding needs the obol-ffi shared library (libobol_ffi.dylib on macOS,
libobol_ffi.so on Linux). It is located, in order:
$OBOL_LIB— an explicit absolute path to the shared library.- Beside the installed
obolpackage (for packaged installs). target/release/thentarget/debug/relative to the repo root (for in-tree dev).
For in-tree development, just build the dylib and the target/debug fallback finds it with
no env:
mise exec rust@1.96.0 -- cargo build -p obol-ffi
If the library lives somewhere else, set OBOL_LIB=/abs/path/to/libobol_ffi.dylib.
Usage
import obol
print(obol.version()) # "0.1.1"
est = obol.estimate_path("transcript.jsonl", dialect="claude")
print(est.total_usd, est.pricing_as_of)
for m in est.per_model:
print(m.model, m.provider, m.subtotal_usd)
# Refresh the on-disk pricing snapshot (network; caller supplies the date):
report = obol.refresh("2026-06-05")
On a nonzero status, the call raises obol.ObolError carrying .code, .kind, and
.message from the FFI error envelope.
Pricing tables must exist
estimate_path reads a pricing snapshot from disk. Either run obol refresh (the CLI), or
point OBOL_PRICING_DIR at a directory containing current.json. With no snapshot the call
raises ObolError with kind == "PricingTablesMissing" (code 1).
Ownership & safety contract
obol owns every string it returns through an out-parameter. This binding honors the contract
automatically in _lib._decode_and_free: it copies the obol-owned C string into Python
bytes, then calls obol_string_free, then the caller parses the copy. The
Rust-owned pointer never outlives the copy and is never freed twice. obol_version() returns
a static string and is never freed. You do not manage any of this yourself — the public API
returns plain dataclasses.
Tests
mise exec rust@1.96.0 -- cargo build -p obol-ffi # build the dylib first
cd bindings/python && PYTHONPATH=. python -m pytest tests -q
Metadata
Release files for primeradianthq-obol 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| primeradianthq_obol-0.9.0-py3-none-manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.28+ x86-64 | Details for primeradianthq_obol-0.9.0-py3-none-manylinux_2_28_x86_64.whl |
| primeradianthq_obol-0.9.0-py3-none-manylinux_2_28_aarch64.whl | Python 3 | none | Linux glibc 2.28+ ARM64 | Details for primeradianthq_obol-0.9.0-py3-none-manylinux_2_28_aarch64.whl |
| primeradianthq_obol-0.9.0-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details for primeradianthq_obol-0.9.0-py3-none-macosx_11_0_arm64.whl |
| primeradianthq_obol-0.9.0-py3-none-macosx_10_12_x86_64.whl | Python 3 | none | macOS 10.12+ x86-64 | Details for primeradianthq_obol-0.9.0-py3-none-macosx_10_12_x86_64.whl |
Total release size: 5.1 MB
Release files / primeradianthq_obol-0.9.0-py3-none-manylinux_2_28_x86_64.whl
| Download URL | primeradianthq_obol-0.9.0-py3-none-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
80fcb786e6cee4b07fe5565cd943f13513496aa5742c4f7eef790c7bca68f3a4
|
|
BLAKE2b-256 checksum How to use checksums |
d8a4a36b6f29538b534a858fd36d083b83539455a3bf569bf6191cd0903d8085
|
| 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 Aug 5, 2026.
Transparency logRelease files / primeradianthq_obol-0.9.0-py3-none-manylinux_2_28_aarch64.whl
| Download URL | primeradianthq_obol-0.9.0-py3-none-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
b4f2b40d58eafac2f4db8e1ca92caadcc9cde93e5c883bcb2e841fe7c6762ee0
|
|
BLAKE2b-256 checksum How to use checksums |
848217fa1f64b73e4d169a396f677969992ecba36d344eef0da28a4b1b7035ae
|
| 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 Aug 5, 2026.
Transparency logRelease files / primeradianthq_obol-0.9.0-py3-none-macosx_11_0_arm64.whl
| Download URL | primeradianthq_obol-0.9.0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e217d7aef69ad376d29157cb4d838ff725fa7d7cd6fd830e1b6117ce721b4638
|
|
BLAKE2b-256 checksum How to use checksums |
5ef6a5ad98a96460be99c5166f389cbcb14ed09a5a92be65a4e3e2aa9c7d6a53
|
| 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 Aug 5, 2026.
Transparency logRelease files / primeradianthq_obol-0.9.0-py3-none-macosx_10_12_x86_64.whl
| Download URL | primeradianthq_obol-0.9.0-py3-none-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | Python 3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
0efcbb90b497e86b5488cac2d4211be86bd0e494a17d528476bad4cde9046867
|
|
BLAKE2b-256 checksum How to use checksums |
28a4d489a818434ff01b958b78d986d277c491345c104c3dcaecc92c83a90956
|
| 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 Aug 5, 2026.
Transparency logSecurity for primeradianthq-obol 0.9.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 4 files in this release have been uploaded with provenance metadata.
Attestation for primeradianthq_obol-0.9.0-py3-none-manylinux_2_28_x86_64.whl
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 Aug 5, 2026.
Transparency logA 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.