Developer resources

Python SDK

Official Python SDK for Lucidry's REST API.

pip install lucidry-sdk

Quickstart: synchronous

Upload a document, run a job, and download the artifact.

python
from lucidry import LucidryClient

client = LucidryClient(api_key="sk_live_your_key")

# Upload a source document
source = client.sources.upload("report.docx")

# Create a processing job
job = client.jobs.create(
    source_id=source.id,
    tier_code="write",
    profile_id="prof_exec_brief"
)

# Wait for completion
completed = client.jobs.wait_for_completion(
    job.id,
    poll_interval=2.0,
    timeout=300.0
)

# Download the artifact
client.artifacts.download(completed.artifact_id, "output.docx")
print("Done!")

Quickstart: async

The same flow with AsyncLucidryClient and asyncio.

python
import asyncio
from lucidry import AsyncLucidryClient

async def main():
    client = AsyncLucidryClient(api_key="sk_live_your_key")

    source = await client.sources.upload("report.docx")
    job = await client.jobs.create(
        source_id=source.id,
        tier_code="write",
        profile_id="prof_exec_brief"
    )
    completed = await client.jobs.async_wait_for_completion(
        job.id, poll_interval=2.0, timeout=300.0
    )
    await client.artifacts.download(completed.artifact_id, "output.docx")
    print("Done!")

asyncio.run(main())

Configuration

Parameters accepted by the LucidryClient constructor.

  • api_key

    str

    Your Lucidry API key

    Required · default -

  • base_url

    str

    API base URL

    Optional · default https://lucidry.io/api/v1

  • timeout

    float

    Request timeout in seconds

    Optional · default 30.0

  • max_retries

    int

    Max retry attempts for 5xx errors

    Optional · default 3

  • logger

    logging.Logger

    Custom logger

    Optional · default None

API methods

Every resource namespace exposed by the client.

  • client.sources.upload(file_path_or_bytes, name=None)

    Upload a source document. Only .docx and .pdf are accepted, up to 50MB.

    Params
    file_path_or_bytes: str | bytes, name: str | None
    Returns
    SourceAsset
  • client.sources.get(source_id)

    Get source asset details, including the security scan result.

    Params
    source_id: str
    Returns
    SourceAsset
  • client.sources.list(**params)

    List source assets for the authenticated organization.

    Params
    limit: int = 50, cursor: str | None = None
    Returns
    list[SourceAsset]

Error handling

Every failure raises a typed exception from lucidry.exceptions.

python
from lucidry.exceptions import (
    LucidryError,
    AuthenticationError,
    RateLimitError,
    NotFoundError,
    APIError
)

try:
    job = client.jobs.create(source_id="src_01", tier_code="write", profile_id="prof_std")
except AuthenticationError as e:
    print(f"Invalid API key: {e}")
except RateLimitError as e:
    print(f"Rate limited. Retry after: {e.retry_after}s")
except APIError as e:
    print(f"API error {e.status_code}: {e.message} (code: {e.error_code})")
  • LucidryError

    -

    Base class every SDK exception inherits from.

  • AuthenticationError

    401

    Invalid, revoked, or missing API key.

  • RateLimitError

    429

    Rate limit exceeded. Exposes retry_after.

  • NotFoundError

    404

    The requested resource does not exist for this organization.

  • APIError

    4xx / 5xx

    Any other API error. Exposes status_code, message, and error_code.

Pydantic models

Models and enums exported from the package root.

class SourceAsset

  • id: str
  • status: str
  • file_name: str
  • word_count: int | None
  • created_date: datetime

class ProcessingJob

  • id: str
  • status: JobStatus
  • source_id: str
  • tier_code: TierCode
  • progress: int
  • artifact_id: str | None
  • quality_score: int | None

class Artifact

  • id: str
  • job_id: str
  • download_url: str
  • format: str
  • word_count: int
  • expires_at: datetime

class TransformProfile

  • id: str
  • name: str
  • description: str
  • settings: dict

class UsageSummary

  • period: str
  • jobs_processed: int
  • words_processed: int
  • total_cost: float

class WebhookEndpoint

  • id: str
  • url: str
  • events: list[str]
  • status: str

enum JobStatus

  • pending
  • processing
  • completed
  • failed
  • canceled

enum TierCode

  • clean
  • edit
  • write
  • magic

Polling helper

Wait for a terminal job state, synchronously or with asyncio.

python
# Sync polling with progress callback
def on_progress(job):
    print(f"Status: {job.status} - Progress: {job.progress}%")

result = client.jobs.wait_for_completion(
    job_id="job_123",
    poll_interval=2.0,
    timeout=300.0,
    on_progress=on_progress
)

# Async polling
result = await async_client.jobs.async_wait_for_completion(
    job_id="job_123",
    poll_interval=2.0,
    timeout=300.0
)

Logging

The SDK logs to the lucidry logger namespace.

python
import logging
logging.getLogger("lucidry").setLevel(logging.DEBUG)