Skip to main content

Python SDK for Alloy Runtime - client, pipeline, and logging

Project description

alloy-runtime-sdk

Python SDK for Alloy Runtime.

Install

pip install alloy-runtime-sdk

Quick start

from alloy_runtime_sdk.api_client.client import ApiClient

async def main() -> None:
    async with ApiClient(
        base_url="https://your-alloy-runtime-host",
        api_key="your_api_key",
    ) as client:
        models = await client.list_models()
        print(models)

What it includes

  • Authenticated HTTP client methods for the Alloy Runtime API.
  • Pipeline runtime helpers for Python-based pipeline steps.
  • Structured logging helpers used by runtime integrations.

Logging

SDK logging is pretty, human-readable text by default:

from alloy_runtime_sdk.logging.config import LogConfig, LogLevel, configure, get_logger

configure(LogConfig(level=LogLevel.DEBUG))
logger = get_logger()

Use JSON Lines explicitly for files, CI, and log shippers:

from alloy_runtime_sdk.logging.config import LogConfig, LogFormat, configure

configure(LogConfig(format=LogFormat.JSONL, output_file="logs/sdk.jsonl"))

SDK logs stay compact: the logging formatter does not add default environment, service, resource, or process-level session_id fields, and successful HTTP responses are not logged. HTTP response logs are emitted only for error responses.

JSON to Markdown helper

Convert JSON-like Python values into LLM-readable Markdown prompt context:

from alloy_runtime_sdk.markdown import json_to_markdown

markdown = json_to_markdown(
    {"customer": {"name": "Ada", "plan": "enterprise"}},
    title="Customer Context",
)

Nested dictionaries become Markdown headings, leaves become key/value lines, and list-of-dictionary values can render as Markdown tables. See docs/sdk/json_to_markdown.md for options.

Local pipeline runner

The SDK supports both Hosted execution and SDK local execution for pipelines.

Use python -m alloy_runtime_sdk.pipeline.local_runner to run a local pipeline module against a hosted Alloy Runtime, or call run_local_pipeline() directly from Python. Local runs return both the stable pipeline_execution_id and active attempt_id/epoch; rerun with the same execution ID to continue the logical workflow.

See docs/pipelines/local_testing.md for the full workflow and examples.

Inspect compact execution live state without querying the database:

execution_state = await client.get_execution_live_state(execution_id)
pipeline_state = await client.get_pipeline_execution_live_state(
    pipeline_id,
    execution_id,
)

Use these methods for current status/progress polling. Use get_execution(...) for the durable model-execution transcript and get_pipeline_execution(...) for durable pipeline result, stdout/stderr, failure context, and generation-step detail.

Hosted pipeline executions can be cancelled through the API client:

await client.cancel_pipeline_execution(pipeline_id, execution_id)

Cancellation marks Alloy's execution record cancelled first; hosted provider shutdown and child generation cancellation are handled by the server best-effort.

The SDK depends on alloy-runtime-types, which is published separately for stable, versioned cross-package compatibility.

Hard-cut API migration

Use this SDK with the matching alloy-runtime-types version. Generation requests now use canonical model / agent_id, flat model_options, flat extra_headers, and canonical result.model response identity. See docs/generate/hardcut_migration.md before updating older SDK or pipeline code.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

alloy_runtime_sdk-0.2.109.tar.gz (68.4 kB view details)

Uploaded Source

Built Distribution

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

alloy_runtime_sdk-0.2.109-py3-none-any.whl (75.6 kB view details)

Uploaded Python 3

File details

Details for the file alloy_runtime_sdk-0.2.109.tar.gz.

File metadata

  • Download URL: alloy_runtime_sdk-0.2.109.tar.gz
  • Upload date:
  • Size: 68.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for alloy_runtime_sdk-0.2.109.tar.gz
Algorithm Hash digest
SHA256 a0ef2cdd35fc78ec62af5faa588e64b9a1eb9e9ff0891ced137da5c6da171c64
MD5 feebcd3643185e5ac116a5be92bf42f7
BLAKE2b-256 7b5defcf5912118847196c79bcb599263e8206d8439526dfcd18ab5b2e5bdd5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for alloy_runtime_sdk-0.2.109.tar.gz:

Publisher: publish-python-packages.yml on alloy-runtime/alloy-runtime

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

File details

Details for the file alloy_runtime_sdk-0.2.109-py3-none-any.whl.

File metadata

File hashes

Hashes for alloy_runtime_sdk-0.2.109-py3-none-any.whl
Algorithm Hash digest
SHA256 50327fdabcbb154aaf254dd2be108c176bfc9180ff92baec0b73bd571d8fbcbb
MD5 b27462a01b1f2b1eb219f1b8d05cdc7b
BLAKE2b-256 748486c5a60157b4cfee9f62b367b3da844746ded0b1cc10df8b133c9f9f9696

See more details on using hashes here.

Provenance

The following attestation bundles were made for alloy_runtime_sdk-0.2.109-py3-none-any.whl:

Publisher: publish-python-packages.yml on alloy-runtime/alloy-runtime

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 Pingdom Monitoring Sentry Error logging StatusPage Status page