Skip to main content

Liyagent Python SDK

A small client for Liyagent's public API: agents, runs, evals, knowledge, approvals and solution templates. It depends only on httpx and returns the server's JSON as it is.

pip install liyagent          # from PyPI, once released
pip install ./sdk/python      # from this repository

Python 3.10+. Versioned with the package (liyagent.__version__); see CHANGELOG.md.

Sign in

from liyagent import Client

# A service account (what a pipeline uses): exchanged for a one-hour session,
# and for a new one when it expires.
liya = Client("https://acme.liyagent.com", token="svc/ci-deployer:...")

# A person, as the console signs in.
liya = Client("https://acme.liyagent.com", username="ana", password="...")

# The machine surface (knowledge.answer): the instance API key or a client token.
liya = Client("https://acme.liyagent.com", api_key="...")

LIYA_URL, LIYA_TOKEN (or TICKETIQ_TOKEN) and LIYA_API_KEY are read when the arguments are left out, as the liya CLI reads them.

What it covers

Namespace Calls
liya.agents list, get, put, delete, export, apply (agents as code), ask, start, stop, workflows, run_workflow, workflow_run
liya.runs list, checkpoint, resume
liya.evals datasets, dataset, create_dataset, start_run, runs, run, compare, wait
liya.knowledge answer, collections, articles, approve_article, reject_article
liya.approvals list, get, approve, reject
liya.templates list, get, preview, install (with params), installs, uninstall
liya.templates (authoring, templates.write) authored, authored_versions, validate, draft_from_agent, save_draft, publish, delete_draft, withdraw

Anything else: liya.request("GET", "/api/..."), with the same credentials and errors.

Types

Request bodies are typed: liyagent.models holds a TypedDict per body (TemplateInstallBody, BundleApplyBody, …) and REQUEST_BODIES maps each operation to its body. They are generated from the server's OpenAPI document by sdk/scripts/generate_models.py, and the server's test suite fails when the committed file differs from what the document says. The package ships py.typed, so mypy and pyright read them. Responses are the server's JSON as it is.

Your own templates

doc = liya.templates.draft_from_agent("desk-helper", key="desk-answers")["template"]
doc["params"] = [{"name": "team", "label": "Escalation team", "required": True}]
doc["agent"]["instructions"] += "\nEscalate to {{ params.team }}."
assert liya.templates.validate(doc)["ok"]
liya.templates.save_draft(doc)
liya.templates.publish("desk-answers", doc["version"])
liya.templates.install("desk-answers", agent_id="desk-two", params={"team": "Network"})

Errors

A refusal raises LiyagentError with status, the server's detail (for a bundle or template refusal, {message, at}: where in the document it was) and a kind: auth (401, sign in again), forbidden (403, a permission is missing), not_found, invalid (400, 422), conflict (409, 412), unreachable or error.

Check the server

liya.check_server() lists the operations this SDK uses that the server does not serve, so a pipeline can stop before it calls a route an older release does not have. The same list (liyagent.OPERATIONS) is checked against the server's OpenAPI document in the server's test suite (tests/unit/test_sdk_python.py).

Examples

  • examples/install_template.py — preview a template, stop if any part would be refused, install it.
  • examples/eval_gate.py — score an agent on its eval set and fail a build that is worse than the pinned baseline.
  • examples/approvals_queue.py — work the approval queue from a terminal.

Releasing

See sdk/RELEASING.md: a tag sdk-py-vX.Y.Z builds and publishes this package to PyPI from GitHub Actions (.github/workflows/sdk-release.yml) by trusted publishing.

Metadata

Release files for liyagent 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 liyagent 0.2.0
File Size Uploaded Provenance Actions
liyagent-0.2.0.tar.gz 20.2 kB Without provenance Details for liyagent-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 39.2 kB

Release files / liyagent-0.2.0.tar.gz

Download URL liyagent-0.2.0.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2a5ef35f3397d8f79a1a58af96fbad1696f9168234d29b565f4e44dc46d1c026
BLAKE2b-256 checksum
How to use checksums
c3cb145008e69aa45b185cab224698df658baaffdb71ec4da230cb6a91b7d880
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / liyagent-0.2.0-py3-none-any.whl

Download URL liyagent-0.2.0-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0597812515dd4a0ebe957da77bc3797d914ffbd8431dbd0299caa369e3a1aaf1
BLAKE2b-256 checksum
How to use checksums
70c47c5f620c25a6db6c422ad41748e43ae4f02c6b80195e3c1737c3910eaab6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for liyagent 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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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

0.2.0 This release

2 release files No 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