Skip to main content

Official Python SDK for the PLCs.ai API — interpret PLC code from your own tools.

Project description

plcsai — Python SDK for the PLCs.ai API

Interpret PLC code from your own tools. Official Python client for the PLCs.ai API. Zero third-party dependencies.

Install

pip install plcsai

Requires Python 3.8+.

Quickstart

from plcsai import Client

client = Client(api_key="plck_live_…")  # or set PLCS_API_KEY

result = client.interpret(
    project_id="prj_…",
    prompt="Why is the filler at line 2 not advancing past Starting?",
)
print(result.answer)
print(result.citations)
print(result.request_id)  # quote this in a support request

Streaming

for event in client.interpret_stream(project_id="prj_…", prompt="…"):
    if event.type == "token":
        print(event.text, end="", flush=True)
    elif event.type == "done":
        print("\nusage:", event.usage)

Conversations, analyses, ingest, embed tokens

conv = client.create_conversation("prj_…", name="Line 2 stoppage")
client.send_message(conv.conversation_id, "And why now?")

job = client.start_analysis("prj_…")
done = client.wait_for_analysis(job.analysis_id)

client.ingest_project(file_path="Conveyor.L5X")

token = client.mint_embed_token("prj_…")  # read-only, for the iframe

What the client handles for you

  • Auth — sends Authorization: Bearer … on every request.
  • Idempotency — auto-generates a stable Idempotency-Key per write (reused across retries).
  • Retries — backs off and retries only on retryable errors, respecting Retry-After.
  • Streaming — parses SSE into typed StreamEvents.
  • request_id — surfaced on every result.

Errors

Non-2xx responses raise plcsai.ApiError with .status_code, .error, .user_message, .suggested_action, .is_retryable, and .request_id.

Development

pip install -e '.[dev]'
pytest

Releasing (maintainers)

plcsai is published to PyPI. Bump version in pyproject.toml, then:

python -m build
python -m twine upload dist/*

Project details


Download files

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

Source Distribution

plcsai-1.0.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

plcsai-1.0.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file plcsai-1.0.0.tar.gz.

File metadata

  • Download URL: plcsai-1.0.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for plcsai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8a170c219f713a9cab6da0c4da4a2892187ec5ee28a1131f0817dda442e30821
MD5 07e2151bb1b560fca22be590ef660df6
BLAKE2b-256 99160b88ae28a86b52f7d61cf520fd11235e8924e7262444b1021269845ed24c

See more details on using hashes here.

File details

Details for the file plcsai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: plcsai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for plcsai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93a61d2ce8ea316edb64f20b90b8b721e712464d96f8cb33048937ad63b4b6fa
MD5 29ff02082cc571b0db77db4eb0a99488
BLAKE2b-256 04feab60ce3ac989da72d69fd90f6f546d5af3c2357e16359d6115f167a58686

See more details on using hashes here.

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