Skip to main content

pipelex-sdk

The Python client for the Pipelex hosted API.

pipelex-sdk is the Python counterpart of @pipelex/sdk, exactly as mthds (the mthds-python package) is the Python counterpart of the mthds npm package. It is the hosted superset: the five normative MTHDS Protocol routes (inherited from mthds) plus the durable run lifecycle plus the Pipelex product surface (methods, organizations, billing, API keys, onboarding, storage, run records).

One-way dependency: pipelex-sdk → mthds.

Install

pip install pipelex-sdk

Configuration

The API key resolves, in order: explicit api_key argument → PIPELEX_API_KEY → anonymous. The token is optional — anonymous access works against the protocol routes (e.g. a local bare runner); the product routes return 401.

The base URL resolves, in order: explicit base_url argument → PIPELEX_BASE_URL → the hosted default https://api.pipelex.com. The base URL is host-only (no path/query/fragment); every endpoint composes as {base}/v1/{endpoint}.

The SDK never reads the mthds resolver (MTHDS_API_KEY / MTHDS_BASE_URL / ~/.mthds/config) — those settings configure the vendor-neutral mthds tooling and whichever runner it targets, not this Pipelex client.

request_timeout_seconds (constructor argument, default 20 min) sets the per-instance blocking-execute ceiling the inherited protocol routes (execute / start / validate / models / version) use.

The client is async-only (httpx AsyncClient) and is an async context manager.

Quickstart

from pipelex_sdk.client import PipelexAPIClient

async def main() -> None:
    async with PipelexAPIClient() as client:
        # 1. Validate an MTHDS bundle. The verdict is always returned (never raised):
        #    a 200 discriminated on `is_valid`, carrying `rendered_markdown`.
        report = await client.validate([bundle_text])
        print(report.rendered_markdown)
        if not report.is_valid:
            return

        # 2. Run a method end-to-end. `start_and_wait` self-heals across runner kinds:
        #    durable start+poll on the hosted API, blocking execute on a bare runner.
        result = await client.start_and_wait(
            pipe_code="my_pipe",
            inputs={"topic": "quantum computing"},
        )

        # 3. Read the output. Every completed run delivers a resolved `main_stuff`
        #    (the full working memory also rides `pipe_output` on the blocking path).
        print(result.main_stuff)

Long runs: start + poll explicitly

Behind the hosted gateway, a synchronous execute() is cut off at ~30s and surfaces a PipelineExecuteTimeoutError pointing here. For long methods, drive the durable lifecycle yourself — the run survives client disconnects and is resumable by pipeline_run_id:

ack = await client.start(pipe_code="long_pipe", inputs={...})
result = await client.wait_for_result(ack.pipeline_run_id)

Product routes: branch on err.code, not the HTTP status

The hosted product routes raise a typed ApiResponseError carrying the RFC 9457 code discriminant. Branch on err.code, which is decoupled from the transport status:

from pipelex_sdk.errors import ApiResponseError

try:
    created = await client.create_pipelex_api_key(label="ci")
    print(created.api_key)  # plaintext — returned only once
except ApiResponseError as exc:
    if exc.code == "pipelex_api_key_limit_reached":
        print("Per-account key limit reached — revoke an old key first.")
    else:
        raise

Public import paths (no barrel)

There is no barrel import — package __init__.py files stay empty. Import each symbol from its module:

  • Client & constructionfrom pipelex_sdk.client import PipelexAPIClient, DEFAULT_API_BASE_URL, MthdsFile
  • Run lifecycle typesfrom pipelex_sdk.runs import RunStatus, RunPublic, RunRead, RunResults, RunResultState, WaitForResultOptions, PollInfo
  • Product wire modelsfrom pipelex_sdk.product_models import UserProfile, MethodData, MethodWriteInput, Membership, MembershipsResponse, SubscriptionResponse, PlanView, InvoiceView, OnboardingSubmission, UploadInput, UploadedFile, PipelineRun, ...
  • Typed errorsfrom pipelex_sdk.errors import ApiResponseError, ApiUnreachableError, PipelineExecuteTimeoutError, RunFailedError, RunTimeoutError, RunLifecycleUnavailableError, RunStillRunningError
  • Versionfrom pipelex_sdk.version import __version__
  • Protocol surface (the MTHDS standard's wire types) comes from the mthds dependency — e.g. from mthds.protocol.exceptions import PipelineRequestError, from mthds.runners.api.models import PipelexValidationResult.

Development

make install      # create the venv and install all extras (resolves `mthds` from ../mthds-python)
make agent-check  # fix-imports + format + lint + pyright + mypy
make agent-test   # run the test suite quietly (prints only on failure)
make check        # full gate: agent-check aggregate + unused-imports + pylint

See CLAUDE.md for the coding standards and docs/architecture.md for the design (including the parity map against @pipelex/sdk).

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pipelex_sdk-0.5.0.tar.gz (139.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pipelex_sdk-0.5.0-py3-none-any.whl (44.1 kB view details)

Uploaded Python 3

File details

Details for the file pipelex_sdk-0.5.0.tar.gz.

File metadata

  • Download URL: pipelex_sdk-0.5.0.tar.gz
  • Upload date:
  • Size: 139.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pipelex_sdk-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b83a81c2f27b729d0f995f1ef99a009dcdd5dd0c472c901c8392cc0790290d63
MD5 697c6e76a0596bff31755f7d2d576547
BLAKE2b-256 a319ae26f50b47c53c328942e0d19b2caa457b0f82e4250685f4399d26f7d476

See more details on using hashes here.

Provenance

The following attestation bundles were made for pipelex_sdk-0.5.0.tar.gz:

Publisher: publish.yml on Pipelex/pipelex-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pipelex_sdk-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pipelex_sdk-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 44.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pipelex_sdk-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13bfd9b280737e32b7d7227fd9a27517b9a498483e810bce0201dd27696d10cd
MD5 c874418351a913866e2b6c385b9ece15
BLAKE2b-256 ebf5ce84b165fc410aec2275a9e5e4c1800a9799d69c26b7f5f707bb2d754ae4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pipelex_sdk-0.5.0-py3-none-any.whl:

Publisher: publish.yml on Pipelex/pipelex-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page