Skip to main content

llmentary

Python (pytest) client for llmentary: deterministic trace-based integration tests for LLM apps.

CI codecov OpenSSF Scorecard License: MIT PyPI Python versions

llmentary is the Python/pytest client for the barzoj-co/llmentary recording proxy. It gives tests deterministic, trace-based assertions for OpenAI-compatible Chat Completions and Responses calls. There is no LLM judge: assertions inspect the requests, responses, tool calls, usage, timings, retries, and errors the proxy recorded.

Published platform wheels bundle a version-pinned proxy binary; see docs/binaries.md for how it is resolved and how to override it.

Install

pip install llmentary

For pytest fixture support:

pip install "llmentary[pytest]"

For the quickstart using openai-python:

pip install "llmentary[pytest,openai]"

Quickstart

Point pytest at an existing proxy, or let the fixture start one:

export LLMENTARY_PROXY_URL=http://127.0.0.1:7777
export LLMENTARY_CONTROL_URL=http://127.0.0.1:7778
pytest
export LLMENTARY_BIN=/path/to/llmentary
export LLMENTARY_UPSTREAM_BASE_URL=https://api.openai.com/v1
export LLMENTARY_UPSTREAM_API_KEY="$OPENAI_API_KEY"
pytest
from openai import OpenAI


def test_tool_flow(llmentary):
    client = OpenAI(
        api_key="test-key",
        base_url=llmentary.openai_base_url,
        default_headers=llmentary.headers,
    )

    first = client.chat.completions.create(
        model="gpt-4.1-mini",
        messages=[{"role": "user", "content": "Weather in Paris?"}],
        tools=[
            {
                "type": "function",
                "function": {
                    "name": "get_weather",
                    "parameters": {
                        "type": "object",
                        "properties": {"city": {"type": "string"}},
                        "required": ["city"],
                    },
                },
            }
        ],
    )
    tool_call = first.choices[0].message.tool_calls[0]

    client.chat.completions.create(
        model="gpt-4.1-mini",
        messages=[
            {"role": "user", "content": "Weather in Paris?"},
            first.choices[0].message,
            {"role": "tool", "tool_call_id": tool_call.id, "content": '{"weather":"sunny"}'},
        ],
    )

    llmentary.expect().tool_called("get_weather").args_subset(
        "get_weather", {"city": "Paris"}
    ).tool_result_fed_back("get_weather").no_errors()

The function-scoped llmentary fixture returns a Session: it creates a unique session id, exposes headers with X-Test-Session, waits for proxy quiescence before assertions, and deletes the session during teardown.

Assertions

llmentary.expect().tool_called("search").called_times("search", 1)
llmentary.query(api_type="responses", model="gpt-4.1-mini").expect().no_errors()

with llmentary.soft_expect() as expect:
    expect.tool_called("search")
    expect.response_contains("done")

Supported deterministic assertions include tool calls (tool_called, not_called, called_times, args_subset, args_matcher, order, parallel_tool_calls, tool_result_fed_back), request and finish metadata (model, request_param, finish_reason), usage and timing (tokens, latency, ttft, retries, no_retries), errors (no_errors, has_error, mid_stream_error), and prompt or response text (prompt_contains, prompt_regex, response_contains, response_regex, response_json_valid, response_json_schema). Failures raise AssertionError with the session trace summary.

See docs/api.md and docs/pytest.md.

llmentary repositories

Repository What
llmentary Recording proxy binary (Go)
llmentary-go Go client for go test
llmentary-python Python client and pytest plugin
llmentary-js TypeScript/JavaScript client for Vitest and Jest

License

Licensed under MIT, see LICENSE

Metadata

Release files for llmentary 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 llmentary 0.2.0
File Size Uploaded Provenance
llmentary-0.2.0.tar.gz 94.7 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for llmentary 0.2.0
File
llmentary-0.2.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
llmentary-0.2.0-py3-none-manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
llmentary-0.2.0-py3-none-manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
llmentary-0.2.0-py3-none-macosx_11_0_x86_64.whl Python 3 none macOS 11.0+ x86-64 Details
llmentary-0.2.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details

Total release size: 23.2 MB

Release files / llmentary-0.2.0.tar.gz

Download URL llmentary-0.2.0.tar.gz
Size 94.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2fed157de816a878b1acf76fcbb0b3c196c241918d29fbc9f420002c0308b987
BLAKE2b-256 checksum
How to use checksums
7b216405ae86ac785ab5f688bd3d4a9862b99b6a2b4e304885f3109e29e5e7fc
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 20, 2026.

Transparency log

Release files / llmentary-0.2.0-py3-none-win_amd64.whl

Download URL llmentary-0.2.0-py3-none-win_amd64.whl
Size 4.8 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
4eb2fe2f12cadff119c84ea3454a6d30977edfce306aa922d0da88623c26ec3d
BLAKE2b-256 checksum
How to use checksums
ae6c5b6aa0e3903334d9a1e639b6196805a36125af7f795ff52985f05c72d760
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 20, 2026.

Transparency log

Release files / llmentary-0.2.0-py3-none-manylinux2014_x86_64.whl

Download URL llmentary-0.2.0-py3-none-manylinux2014_x86_64.whl
Size 4.7 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
2a8ae4959e40e8af86484b0b7d14b9145a95edb129c3e60f0c1cde3e353c3a1e
BLAKE2b-256 checksum
How to use checksums
ad33df826acd66a6a6a58ee5de371f6a892758ea9ae279733e6bfbce48878972
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 20, 2026.

Transparency log

Release files / llmentary-0.2.0-py3-none-manylinux2014_aarch64.whl

Download URL llmentary-0.2.0-py3-none-manylinux2014_aarch64.whl
Size 4.2 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
816d995368188ea3108c6db87005388572b68b433f12514d4cb7066f11466d05
BLAKE2b-256 checksum
How to use checksums
aaf426a9d941ed24054c338397e5df87963df4c2aafcdc33573bc8120c424d92
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 20, 2026.

Transparency log

Release files / llmentary-0.2.0-py3-none-macosx_11_0_x86_64.whl

Download URL llmentary-0.2.0-py3-none-macosx_11_0_x86_64.whl
Size 4.8 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
c84a78f278ddafe682c877adcca57300b76ccc7c35044290c2a46b7144a493ad
BLAKE2b-256 checksum
How to use checksums
3143b6368435ed3ac3ff48992688e6a7d542681cd0dc7b2ad87fb0423bea161f
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 20, 2026.

Transparency log

Release files / llmentary-0.2.0-py3-none-macosx_11_0_arm64.whl

Download URL llmentary-0.2.0-py3-none-macosx_11_0_arm64.whl
Size 4.5 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8371674d0c09a897342e14bac2b5a30eec3465e8b9af521cd3676f25d5776824
BLAKE2b-256 checksum
How to use checksums
4dfbfc56f65832882ae5e37c4063d9a9df2558dfc9ae353337d9c30addd5611a
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 20, 2026.

Transparency log

Security for llmentary 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 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for llmentary-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 20, 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