Skip to main content

Official Python SDK for the EigenPal API

Project description

eigenpal

Trigger EigenPal workflows from Python.

pypi downloads license docs

Install

pip install eigenpal

Requires Python 3.9+. Get an API key at app.eigenpal.com → Settings → API Keys.

Quick start

import os
from pathlib import Path
from eigenpal import EigenpalClient, EigenpalValidationError

client = EigenpalClient(api_key=os.environ["EIGENPAL_API_KEY"])

# Pass a Path / file handle / { content, filename, mime_type }. The SDK
# uploads the request as multipart/form-data, no base64 needed.
result = client.workflows.executions.run_and_wait(
    "extract-invoice",
    input={"contract_document": Path("contract.pdf")},
)
print(result["status"], result["result"])

Authentication

Generate an API key from the dashboard under Settings → API Keys, then pass it explicitly:

client = EigenpalClient(api_key=os.environ["EIGENPAL_API_KEY"])

The api_key argument always wins. If you omit it, the SDK falls back to EIGENPAL_API_KEY for convenience, handy in scripts where you'd be writing exactly the line above.

Self-hosted

Point the SDK at your own deployment via base_url:

client = EigenpalClient(
    api_key=os.environ["EIGENPAL_API_KEY"],
    base_url=os.environ.get("EIGENPAL_BASE_URL", "https://eigenpal.acme.internal"),
)

base_url likewise wins over the EIGENPAL_BASE_URL env fallback. Defaults to https://app.eigenpal.com (the hosted cloud).

Starting runs

client.run(target, input=None, **options) starts a workflow or agent run. Targets can be strings like "workflows.extract-invoice" / "agents.invoice-agent" or structured objects like {"type": "workflow", "slug": "extract-invoice"}.

from pathlib import Path

# Async: returns immediately with { run_id }.
result = client.run(
    "workflows.extract-invoice",
    input={"contract_document": Path("contract.pdf")},
)
print(result.run_id)

# Sync: server holds the connection up to 60 seconds.
result = client.run(
    "workflows.extract-invoice",
    input={"contract_document": Path("contract.pdf")},
    wait_for_completion=60,
)
print(result.status, result.output)

# Long-running: client-side polling (default 5min cap).
final = client.workflows.executions.run_and_wait(
    "extract-invoice",
    input={"contract_document": Path("contract.pdf")},
)
print(final["status"])

The input argument is the input map keyed by input name. Omit it for inputs-less runs. Put the workflow version or agent source ref in the target; other keyword args include overrides and wait_for_completion.

File inputs

Pass a pathlib.Path, an open file handle, or an explicit {"content": bytes, "filename": str, "mime_type": str} descriptor. The SDK auto-detects files and uploads as multipart/form-data (the same shape as curl -F):

from pathlib import Path

# Path: filename + mime type inferred.
client.run("workflows.extract-invoice", input={
    "contract_document": Path("contract.pdf"),
})

# File handle: filename inferred from .name.
with open("contract.pdf", "rb") as f:
    client.run("workflows.extract-invoice", input={"contract_document": f})

# Explicit dict: required for raw bytes.
client.run("workflows.extract-invoice", input={
    "contract_document": {
        "content": data,
        "filename": "contract.pdf",
        "mime_type": "application/pdf",
    },
})

Don't base64-encode files yourself. The SDK is multipart-first; base64 doubles the payload size and skips the optimised upload path.

Execution polling

summaries = client.runs.list(
    type="workflow",
    source="extract-invoice",
    status="failed,cancelled",
)

run = client.runs.get(run_id, include="detail")
client.runs.cancel(run_id)

status = client.runs.get(run_id)
#   RunEnvelope(run=...)

executions = client.runs.list(
    type="workflow",
    source="extract-invoice",
    status="failed",
    from_date="now()-7d",
    limit=50,
)

client.runs.cancel(run_id)

/api/v1/runs is the shared run API for workflow, agent, and eval runs. Use type="workflow"|"agent" and source="<workflowId-or-agentId>" to scope list calls.

Workflows

client.workflows.list(search="invoice", limit=20)
client.workflows.get("extract-invoice")
client.workflows.versions("extract-invoice")

Agents

client.agents.list(search="invoice")
client.agents.get("invoice-agent")

result = client.run("agents.invoice-agent", input={
    "invoice": Path("invoice.pdf"),
})

client.runs.get(result.run_id)
client.runs.cancel(result.run_id)

Agent run listing uses the same shared runs API with type_="agent" and the agent id or slug as source.

Errors

Every non-2xx response raises a typed subclass of EigenpalError:

HTTP Class Notes
400 EigenpalValidationError .issues carries the per-field problems
401 EigenpalAuthError Bad / missing API key
403 EigenpalForbiddenError API trigger disabled, scope mismatch
404 EigenpalNotFoundError Workflow / execution doesn't exist
429 EigenpalRateLimitError .retry_after is the server-suggested wait (seconds)
5xx EigenpalServerError
timeout EigenpalTimeoutError
from eigenpal import EigenpalClient, EigenpalValidationError

client = EigenpalClient(api_key=os.environ["EIGENPAL_API_KEY"])

try:
    # First arg accepts the workflow slug ("extract-invoice") or id ("wf_abc123").
    result = client.workflows.executions.run_and_wait(
        "extract-invoice",
        input={"language": "en"},
    )
    print(result["status"], result["result"])
except EigenpalValidationError as err:
    for issue in err.issues:
        print(f"{issue['field']}: {issue['message']}")
    raise

For file inputs, see docs/files.md.

Reference

Topic What's in it
Workflows List, get, trigger runs, pin versions.
Executions Status, polling, cancel, run-and-wait.
File inputs Multipart upload from Path, file handle, or bytes.
Errors Typed exceptions, retries, request ids.
Configuration API key, base_url, timeouts, headers.
Full API reference Every method, generated from the OpenAPI spec.

License

Apache-2.0.

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

eigenpal-0.6.16.tar.gz (57.8 kB view details)

Uploaded Source

Built Distribution

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

eigenpal-0.6.16-py3-none-any.whl (173.4 kB view details)

Uploaded Python 3

File details

Details for the file eigenpal-0.6.16.tar.gz.

File metadata

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

File hashes

Hashes for eigenpal-0.6.16.tar.gz
Algorithm Hash digest
SHA256 463d0e26e1d11a1829a3d3b5b1f663955f0c4c5500c449f232154658f619b636
MD5 d09eb2a702630696d72c9f7580875c48
BLAKE2b-256 5b2afc34d453f5a467d4fb46fcac9005aa17baabf9c5ec27212c6329f91da55a

See more details on using hashes here.

Provenance

The following attestation bundles were made for eigenpal-0.6.16.tar.gz:

Publisher: release.yml on eigenpal/eigenpal

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

File details

Details for the file eigenpal-0.6.16-py3-none-any.whl.

File metadata

  • Download URL: eigenpal-0.6.16-py3-none-any.whl
  • Upload date:
  • Size: 173.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for eigenpal-0.6.16-py3-none-any.whl
Algorithm Hash digest
SHA256 b37678bb6b3ccf1ebfcc6d3470acb592adf00b612d744a68e564f24643bbce4d
MD5 02029db99c4704ed7b9ed052970a2f80
BLAKE2b-256 da935d4b90b23b3af44d4d6d0d851cd6320eb183f6fc368c78a7a91ced577567

See more details on using hashes here.

Provenance

The following attestation bundles were made for eigenpal-0.6.16-py3-none-any.whl:

Publisher: release.yml on eigenpal/eigenpal

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