Skip to main content

Anlyon Python SDK

Governed execution for AI agents. Official Python SDK for Anlyon. Your agent invokes a named action. Anlyon holds the credentials, evaluates policy, waits for approval when required, and makes the production call itself.

Installation

pip install anlyon

Quick start

Define the call once, from an operator key. That is the only place your credential appears:

import os
from anlyon import Client

ops = Client(api_key=os.environ["ANLYON_OPERATOR_KEY"])

ops.secrets.put("STRIPE_KEY", value=os.environ["STRIPE_KEY"])

ops.actions.create(
    name="refund-order",
    method="POST",
    url_template="https://api.stripe.com/v1/refunds",
    headers={"Authorization": "Bearer {{secret:STRIPE_KEY}}", "Content-Type": "application/x-www-form-urlencoded"},
    requires_approval=True,
)

From then on, this is all your agent sees. No URL, no header, no key:

anlyon = Client(api_key=os.environ["ANLYON_AGENT_KEY"])

# Successful calls expose the canonical response envelope.
result = anlyon.actions.invoke("refund-order", {"charge": "ch_3P9x", "amount": 12000})

if result.data["pendingApproval"]:
    print("Parked for a human:", result.data["approvalId"])
else:
    print("Stripe replied", result.data["responseStatus"])

anlyon.close()

status on an invocation distinguishes failed (the call did not happen, safe to retry) from unknown (it may have reached the destination, so reconcile before retrying). Anlyon never retries an action invocation for you.

These guarantees cover actions routed through Anlyon. A tool your own code calls directly, with a credential your own process holds, is not routed through Anlyon and is not governed by it.

Async

import asyncio
import os
from anlyon import AsyncClient

async def main():
    async with AsyncClient(api_key=os.environ["ANLYON_AGENT_KEY"]) as client:
        result = await client.actions.invoke("refund-order", {"charge": "ch_3P9x", "amount": 12000})
        print(result.data["status"])

asyncio.run(main())

Configuration

from anlyon import Client, RetryConfig

client = Client(
    api_key="anlyon_live_xxx",       # falls back to ANLYON_API_KEY
    base_url="http://localhost:4000",  # falls back to ANLYON_BASE_URL
    timeout=10.0,
    retry=RetryConfig(max_attempts=5),
)

Resources

The governed execution path:

  • client.actions: create, import_openapi, list, get, update, delete, invoke, invocations, invocation, versions (hosted execution)
  • client.secrets: put, list, get, delete (write-only vault, no method returns a value)
  • client.approvals, client.budgets: the controls around an invocation
  • client.events: publish, list, get, topics CRUD, subscriptions
  • client.analytics, client.logs: usage, delivery analytics, redacted execution history, exports
  • client.billing, client.notifications: provider-safe billing state and notification preferences
  • client.integrations: Slack and Discord delivery

Write operations accept an idempotency_key so automatic retries can never double-write:

client.actions.invoke("refund-order", {"charge": "ch_1"}, idempotency_key="refund:ord_42")

Error handling

Successful calls return ApiResponse with success, data, pagination, stats, and request_id, matching the HTTP contract and TypeScript SDK. For compatibility with the 0.1 release, indexing, iteration, get(), len(), and equality delegate to response.data. New code should use response.data explicitly. The legacy shortcut is deprecated for removal in the next major release.

Failed requests raise typed exceptions (never return an error envelope):

from anlyon import Client, NotFoundError, RateLimitError

client = Client(api_key="anlyon_live_xxx")
try:
    client.actions.get("act_missing")
except NotFoundError:
    print("Not found")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after}s")

Legacy namespaces

The namespaces below remain supported on the same client and are not part of the governed execution path.

  • client.memory: remember, remember_many, recall, forget, ingest, upload_file, summarize, consolidate, jobs, collections
  • client.sessions, client.context: persistent conversations and token-budgeted context
  • client.cache: lookup, store, list, get, delete, flush (semantic cache)
  • client.files: upload, presign, download, list, get, delete
  • client.messages: publish, publish_batch, list, get, cancel
  • client.queues, client.schedules, client.url_groups, client.dlq: durable delivery controls
  • client.workflows: create, list, get, update, delete, trigger, list_runs, get_run, list_run_steps, cancel_run, notify
  • client.flow_control: rate and concurrency controls
client = Client(api_key="anlyon_live_xxx")

client.memory.remember(content="The customer prefers email over phone.", idempotency_key="user-123-pref")

result = client.memory.recall(query="how should we contact this customer?")
for r in result.data["results"]:
    print(r["score"], r["content"])

client.messages.publish(url="https://example.com/hook", idempotency_key="order-456")

client.close()

Metadata

Release files for anlyon 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anlyon 0.4.1
File Size Uploaded
anlyon-0.4.1.tar.gz 71.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for anlyon 0.4.1
File Interpreter ABI Platform
anlyon-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 137.5 kB

Release files / anlyon-0.4.1.tar.gz

Download URL anlyon-0.4.1.tar.gz
Size 71.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bcdb9d463c43d95974e44662bdc310b152fc2320221a1744b548df8648c4f9bd
BLAKE2b-256 checksum
How to use checksums
680ac2e0a6d93de53c6105c197383ceb9a59fedd8bea2bec1be0661e45134199
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 3, 2026.

Transparency log

Release files / anlyon-0.4.1-py3-none-any.whl

Download URL anlyon-0.4.1-py3-none-any.whl
Size 66.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbab75d80bbb7eba94002ebcf71117eae6d3b1a253a2997dc7d7c4ab882f7e48
BLAKE2b-256 checksum
How to use checksums
fbdec41d1d74acfd9b447fba62ec7fbc6bd2b5be1a1e5f8315d792092553a958
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 3, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.0

2 release files

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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