Skip to main content

PermutiveAPI

PyPI version Python versions License: MIT

PermutiveAPI is a typed, governed Python SDK and AI-agent platform for the Permutive API. It supports Python 3.9 through 3.13 and provides synchronous and asynchronous clients, typed queries, a safe Codex plugin, deterministic evaluations and scenarios, executable recipes, capability negotiation, generated API contracts, sanitized replay, coordinated runtime resilience, and immutable release evidence.

Install

python -m pip install --upgrade PermutiveAPI

Optional integrations:

python -m pip install --upgrade "PermutiveAPI[async]"
python -m pip install --upgrade "PermutiveAPI[dataframe]"

The core package does not require HTTPX or pandas.

Configure safely

For normal setup, use the shortest readiness flow:

permutiveapi configure
permutiveapi check

configure writes only PERMUTIVE_API_KEY to a local .env file without echoing it. check resolves credentials without displaying them and performs one bounded read-only Permutive API request so authentication and connectivity are verified together.

Use permutiveapi check --json for a machine-readable readiness report with stable secret-safe error codes, retryability, recommended actions, and safe context. Use permutiveapi doctor only when inspecting local .env permissions or Git-ignore hygiene. validate and eval remain credential-free and network-free product checks.

Credential lookup order is explicit input, process environment, project .env, then ~/.config/permutive/.env. Credentials are never uploaded, logged, or included in object representations.

Canonical client

from PermutiveAPI import PermutiveClient

with PermutiveClient("api-key") as client:
    cohort = client.cohorts.get("cohort-id")
    page = client.segments.list(page_size=50)

Canonical resource namespaces are cohorts, imports, segments, sources, and workspaces. Their 25 CRUD/list operations and structural response fingerprints are generated in API_COVERAGE.md.

Async client

Install PermutiveAPI[async]:

import asyncio

from PermutiveAPI import AsyncPermutiveClient


async def main() -> None:
    async with AsyncPermutiveClient("api-key") as client:
        result = await client.request("GET", "cohorts-api/v2/cohorts")
        print(result)


asyncio.run(main())

The async client shares typed JSON, errors, retries, pagination, and bounded-batch semantics with the synchronous SDK.

Typed queries

from PermutiveAPI import all_of, event, in_segment

query = all_of((event("pageview"), in_segment("high-intent")))
payload = query.to_json()

Governed agent platform

The Codex plugin and Python integration reuse the canonical SDK:

from PermutiveAPI.plugins.codex import CodexPlugin

plugin = CodexPlugin.from_env()
tools = plugin.tools().as_openai_tools()
agent_kit = plugin.agent_kit()

For Codex users, the plugin is the preferred entry point. Ask Set up PermutiveAPI or Check my Permutive connection and credentials; the welcome and troubleshooting skills route setup through permutiveapi check --json, launch local non-echoing configuration only when needed, and continue directly to the requested task after readiness succeeds.

Read-only is the default. Write tools require explicit read-write mode and confirmation. Adaptive integrations negotiate capabilities before execution. CodexPlugin.invoke_safe() returns stable secret-safe error codes, retryability, recommended actions, and safe context.

Run deterministic platform proof:

permutiveapi eval
permutiveapi examples
permutiveapi examples --name reviewed-cohort-write

The scorecard covers tool selection, unsupported capabilities, approvals, allow and deny policy, redaction, idempotency, workflow bounds, partial failures, and audit completeness. Seven credential-free recipes cover SDK, async, queries, plugin, and governed workflows. A fresh installed interpreter must complete the canonical recipe within five seconds.

Operational reliability

API drift and replay

python scripts/generate_api_contracts.py --check
python scripts/validate_recordings.py

Versioned samples generate the machine contract and API_COVERAGE.md. Additive fields remain compatible; removals and type changes fail validation. Recordings exclude request payloads, query strings, credentials, authorization headers, cookies, and sensitive response values.

Coordinated limits and rotation

import requests

from PermutiveAPI import (
    AtomicCredentials,
    CoordinatedTransport,
    PermutiveClient,
    RateLimitCoordinator,
)

credentials = AtomicCredentials("initial-key")
coordinator = RateLimitCoordinator(requests_per_second=10)
transport = CoordinatedTransport(requests.Session(), credentials, coordinator)
client = PermutiveClient("managed-placeholder", transport=transport)

client.request("GET", "cohorts-api/v2/cohorts")
credentials.rotate("rotated-key")

One coordinator can be shared by synchronous and asynchronous transports. Every request attempt receives one immutable credential generation, Retry-After deferrals apply across all callers, and transport exceptions redact the real rotating key before reaching the client.

Performance and releases

python scripts/validate_performance.py

Performance budgets detect material local regressions. The release workflow builds once, generates an SBOM and SHA-256 manifest, attests the artifacts, and verifies the exact candidate before PyPI Trusted Publishing and GitHub Release creation.

See docs/OPERATIONAL_RELIABILITY.md for the complete contract.

CLI

Command Purpose
permutiveapi configure Create a protected local credential file.
permutiveapi check Verify credentials and live read-only API connectivity.
permutiveapi doctor Inspect local credential-file safety without showing values.
permutiveapi validate Validate the installed product surface.
permutiveapi test Run deterministic installed-package checks.
permutiveapi eval Print governed-platform scorecard JSON.
permutiveapi docs Print canonical documentation paths.
permutiveapi examples Discover or print executable recipes.
permutiveapi upgrade Print the explicit upgrade command.
permutiveapi uninstall Print the explicit removal command.

Development

git clone https://github.com/fatmambot33/PermutiveAPI.git
cd PermutiveAPI
python -m pip install -e ".[dev]"

python scripts/validate_release_metadata.py
python scripts/validate_typing_scope.py
python scripts/generate_api_contracts.py --check
python scripts/validate_recordings.py
python scripts/validate_performance.py
python scripts/generate_evaluation_scorecard.py --check evals/scorecard.json
black --check --diff src tests typing_examples scripts
pydocstyle src/PermutiveAPI
pyright
pytest -q
python -m build
python -m twine check dist/*

Supported changes require NumPy-style docstrings, strict typing, deterministic network-free tests, secret redaction, clean installation, and machine-readable evidence.

Project contracts

Compatibility

PUBLIC_API.md is the source of truth. Legacy resource classes remain supported as compatibility APIs, but new code should prefer PermutiveClient, AsyncPermutiveClient, typed queries, and canonical tool surfaces. Review MIGRATION.md before replacing older call patterns.

License

MIT. See LICENSE.

Metadata

Release files for PermutiveAPI 6.9.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 PermutiveAPI 6.9.0
File Size Uploaded Provenance Actions
permutiveapi-6.9.0.tar.gz 195.3 kB With provenance Details for permutiveapi-6.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for PermutiveAPI 6.9.0
File Interpreter ABI Platform Actions
permutiveapi-6.9.0-py3-none-any.whl Python 3 none any Details for permutiveapi-6.9.0-py3-none-any.whl

Total release size: 318.4 kB

Release files / permutiveapi-6.9.0.tar.gz

Download URL permutiveapi-6.9.0.tar.gz
Size 195.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f33dcb19f6590c294e2278ef5c5a6c2ebd032a6a2ed8d12d926b4b81b4ab07be
BLAKE2b-256 checksum
How to use checksums
229518c8233b4ab4b53149308b0e656df79f20ee26cd6227477f672bf83c9bc4
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 Oct 31, 2026.

Transparency log

Release files / permutiveapi-6.9.0-py3-none-any.whl

Download URL permutiveapi-6.9.0-py3-none-any.whl
Size 123.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
847bb42bf2116bd39f0af3ed48cd28313078912e326da3b978e80080b6f0bfc2
BLAKE2b-256 checksum
How to use checksums
f2beb65c0dd3d5e017b8e392fe46d2f0f0139d6c27978c14585321e502539846
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 Oct 31, 2026.

Transparency log

Security for PermutiveAPI 6.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for permutiveapi-6.9.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 31, 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.

Release history Release notifications | RSS feed

This release

6.9.0 This release

2 release files Full provenance

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