Skip to main content
Generated from lighton-sdk 1.2.0. Install it and see runnable examples in the quick start.

Client

LightOn

LightOn.ask()

POST /api/v3/ask, ask a grounded question over indexed documents. Arguments Returns Raises

LightOn.close()

LightOn.extract()

POST /api/v3/extract, extract structured data from a document. Pass exactly one of: path: A local file to upload (multipart). url: A publicly accessible URL to fetch. file: An already-ingested file (File object or id), no re-upload, the server reads the document it already has. Arguments Returns Raises

LightOn.parse()

POST /api/v3/parse, parse a document into per-page text. Pass exactly one of: path: A local file to upload (multipart). url: A publicly accessible URL to fetch. Arguments Returns Raises
POST /api/v3/search, retrieve relevant passages (no generation). Arguments Returns

LightOnConfiguration

Non-essential client knobs. api_key stays a direct LightOn() argument.

Workspaces & files

Workspace

Workspace.create()

Create this workspace and bind the client for later lifecycle calls. Arguments Returns

Workspace.delete()

Delete this resource and clear its local id.

Workspace.get()

Classmethod.
Fetch a single resource by id. Arguments Returns

Workspace.ingest()

Upload a File into this workspace, uploading is the ingestion. Non-blocking by default: the returned File is ‘pending’, poll it via refresh()/wait(). Pass wait=True to block until ingestion is terminal. Arguments Returns Raises

Workspace.ingest_many()

Upload many files into this workspace, concurrently. Every local path is validated to exist before any upload starts (fail fast). Staying under the API rate limit and the 429 cooldown are handled by the client (see LightOnConfiguration.max_requests_per_minute / rate_limit_retries), so they apply across uploads and status polls alike. Arguments Returns Raises

Workspace.list()

Classmethod.
List every resource, following pagination to the end. Arguments Returns

Workspace.refresh()

Re-fetch this resource from the API (GET). Returns

Workspace.save()

Persist local edits to name/description (PATCH). Returns

WorkspaceTaxonomy

How much of a workspace is classified, and under which roots. The cheapest way to see classification coverage without listing files. Only the list endpoint returns it (Workspace.list()); the detail endpoint omits the key entirely, so get()/refresh() leave whatever was already there rather than clearing it.

RootContentType

How many of a workspace’s documents sit under one root content type.

WorkspaceSync

The external datasource a workspace imports from, when one is connected. None on a workspace whose documents were uploaded directly.

File

File.classify()

Assign a content type to this file (ContentType object or path string). Arguments Returns Raises

File.clear_attribute()

Clear an attribute value under an assigned content type. Arguments Returns

File.create()

Upload the file (multipart), this starts ingestion. Arguments Returns Raises

File.delete()

Delete this resource and clear its local id.

File.delete_many()

Classmethod.
Delete many files in one request (POST /files/bulk-delete). All-or-nothing: if any id is unknown (or not yours), the API rejects the whole call with 404 and deletes nothing, which this surfaces as a NotFoundError. There is no partial-success result to report, so a failure raises rather than returning a per-file report: nothing was deleted, and retrying with the ids you can account for is the fix. Arguments Returns Raises

File.download()

Download this document’s stored bytes (GET /files/<id>/download). Arguments Returns Raises

File.download_thumbnail()

Download this document’s 256x256 WebP thumbnail. Generated asynchronously and independently of ingestion, so an embedded file may still have none. Check the thumbnail field first, a fetch before it is READY raises NotFoundError: doc.refresh() if doc.thumbnail and doc.thumbnail.status is ThumbnailStatus.READY: image = doc.download_thumbnail() Returns Raises

File.facets()

List this file’s assigned content types and their attribute values. Returns Raises

File.get()

Classmethod.
Fetch a single resource by id. Arguments Returns

File.get_by_name()

Classmethod.
Fetch every file with this user-facing name in a workspace. Matches title, not filename: the server uniquifies filenames on upload (“report.pdf” is stored as something like “report_20260728_c9be.pdf”), so the name you uploaded never matches the stored one. A title defaults to the uploaded filename without its extension, so “report.pdf” and “report” both find that upload. Titles are not unique the way stored filenames are, uploading the same document twice gives both copies the same title, so this returns every match rather than picking one. Check the length if you need exactly one. The API’s title filter is a case-insensitive partial match, so the candidates it returns are narrowed to an exact title match here. Arguments Returns Raises

File.list()

Classmethod.
List every resource, following pagination to the end. Arguments Returns

File.pages()

Fetch the parsed text of this document, one entry per page. The platform stores what it parsed at ingestion, so this reads it back instead of re-uploading and re-parsing a document it already has. The result is the same {index, markdown} shape parse returns (literally the same Page model), so code can move between parsing a local file and reading an ingested one without reshaping anything. Costs a request with include_content=true and is not part of refresh(), because the text can be large and most callers don’t want it. Returns Raises

File.refresh()

Re-fetch this resource from the API (GET). Returns

File.replace()

Replace this document’s content in place (PATCH, multipart file part). The document keeps its id, title, tags, and content-type classifications, and is re-ingested from the new content, so every reference to the id survives what used to need a delete plus a re-upload. The new file may be of a different type. filename follows the new file, but title (the user-facing name, what get_by_name matches) is preserved, so a replaced document is still found under the name it was uploaded with. Addressed by id, never by name: titles and filenames aren’t unique, so resolve to the one document you mean first (File.get(client, id), or check the length of File.get_by_name(...)) before replacing. Arguments Returns Raises

File.save()

Persist local edits to title, plus whatever you pass explicitly. filename is immutable server-side. title is a plain model field: set it and save. tags and external_metadata are arguments, not fields, because neither is a plain set server-side, and a keyword at the call site says which one you’re doing:
  • tags replaces every tag on the document, auto-assigned included. Pass [] to remove them all; tag()/untag() stay the additive path. (It also can’t be a field: the response returns tag objects, not the list[int] the request takes, which would clash on absorb.)
  • external_metadata merges into what’s stored, including inside additional_metadata, so a partial update leaves the other keys alone. The field of the same name stays readable and round-trips; it just isn’t what gets sent, so assigning it can’t read as a whole-value set.
Omitting either leaves that part of the document untouched, so a plain save() only ever writes the title. Clearing metadata is partial, and the shape is the API’s, verified live: doc_type="" blanks it, and a null inside additional_metadata ({"version": None}) nulls that key. external_id can be neither blanked (422 blank) nor nulled (422 null), and the whole record can’t be dropped: the schema offers a null external_metadata, but the endpoint takes only form/multipart, where a bare null is rejected as “must be a JSON object”, and application/json is 415. So the null branch is unreachable. ponytail: exclude_none=True is load-bearing, not tidiness. It keeps an unset field out of the payload (a None doc_type would 422), while an empty string still goes through, which is what makes the blank-clear work. Arguments Returns Raises

File.set_attribute()

Set an attribute value under an assigned content type. Arguments Returns

File.tag()

Assign tags to this file (POST /files/<id>/tags). Arguments Returns Raises

File.unclassify()

Remove a content-type assignment from this file. Arguments Returns

File.untag()

Remove tags from this file (DELETE /files/<id>/tags/<tag_id>, one each). Arguments Returns Raises

File.wait()

Block (polling) until ingestion reaches a terminal state. ponytail: dumb poll loop, the API offers no webhook. Run in a thread (or use wait_all) for concurrency; the SDK stays sync. Arguments Returns Raises

ExternalMetadata

Where a document came from in a third-party system. How a synced document keeps its origin id: set it on upload (or with save()) and it survives on the File, so a later sync can match the platform document back to the record it was ingested from. Updates merge server-side, including into additional_metadata: patching one key leaves the others in place, there is no way to drop a key this way.

Thumbnail

Whether a file’s 256x256 WebP thumbnail exists yet, and where it lives. Generation is asynchronous and independent of ingestion, so check status before fetching: File.download_thumbnail() 404s while it isn’t READY.

wait_all

Wait for many ingestions concurrently (threads, not async, sync SDK). Arguments Returns Raises

Tags & content types

Tag

Tag.create()

Create this tag and bind the client for later lifecycle calls. Arguments Returns

Tag.delete()

Delete this resource and clear its local id.

Tag.get()

Classmethod.
Raises

Tag.list()

Classmethod.
List every resource, following pagination to the end. Arguments Returns

Tag.refresh()

Raises

ContentType

A node in the content-type taxonomy.

ContentType.adopt()

Classmethod.
Import starter trees from the template catalog into your taxonomy. Arguments Returns

ContentType.batch()

Classmethod.
Apply several taxonomy actions in one request (POST /content-types/batch). Each entry is the body a single-action method would send, so a tree and its attributes land together instead of one round trip each: ContentType.batch(client, [ {“action”: “adopt”, “content_types”: [“legal”]}, {“action”: “define_attribute”, “content_type_path”: “legal”, “name”: “jurisdiction”, “attribute_type”: “select”, “choices”: [“FR”, “US”]}, ]) Arguments Returns

ContentType.define()

Classmethod.
Create or update one node (POST /content-types, define_content_type). Idempotent: defining an existing code again updates it, so this is also how you rename a node. Arguments Returns

ContentType.define_attribute()

Classmethod.
Create or update an attribute column on a node. Arguments Returns Raises

ContentType.list()

Classmethod.
List the content-type taxonomy (top-level nodes, each with children). Arguments Returns

ContentType.templates()

Classmethod.
List the starter taxonomies you can adopt() (GET /content-types/templates). Arguments Returns

ContentType.undefine()

Classmethod.
Delete a node and cascade its whole subtree. Arguments Returns

ContentType.undefine_attribute()

Classmethod.
Remove an attribute column from a node. Arguments Returns

Template

A starter taxonomy from the catalog, what adopt() imports. Same tree as a ContentType except for attributes: on a template it’s a map from node path to that node’s attribute definitions (the whole tree’s attributes hang off the root), not this node’s own list.

Template.adopt()

Classmethod.
Import starter trees from the template catalog into your taxonomy. Arguments Returns

Template.batch()

Classmethod.
Apply several taxonomy actions in one request (POST /content-types/batch). Each entry is the body a single-action method would send, so a tree and its attributes land together instead of one round trip each: ContentType.batch(client, [ {“action”: “adopt”, “content_types”: [“legal”]}, {“action”: “define_attribute”, “content_type_path”: “legal”, “name”: “jurisdiction”, “attribute_type”: “select”, “choices”: [“FR”, “US”]}, ]) Arguments Returns

Template.define()

Classmethod.
Create or update one node (POST /content-types, define_content_type). Idempotent: defining an existing code again updates it, so this is also how you rename a node. Arguments Returns

Template.define_attribute()

Classmethod.
Create or update an attribute column on a node. Arguments Returns Raises

Template.list()

Classmethod.
List the content-type taxonomy (top-level nodes, each with children). Arguments Returns

Template.templates()

Classmethod.
List the starter taxonomies you can adopt() (GET /content-types/templates). Arguments Returns

Template.undefine()

Classmethod.
Delete a node and cascade its whole subtree. Arguments Returns

Template.undefine_attribute()

Classmethod.
Remove an attribute column from a node. Arguments Returns

Attribute

One attribute of a content type, a definition, or a value set on a file. Carries both the schema (type/required/choices) and, when read from a file’s facets, the current value. value is None for bare definitions / when unset.

Facet

A content type assigned to a file, with the file’s attribute values on it.

API keys

ApiKey

ApiKey.create()

Create this API key and bind the client for later lifecycle calls. Arguments Returns

ApiKey.delete()

Delete this resource and clear its local id.

ApiKey.get()

Classmethod.
Fetch a single resource by id. Arguments Returns

ApiKey.list()

Classmethod.
List every resource, following pagination to the end. Arguments Returns

ApiKey.refresh()

Re-fetch this resource from the API (GET). Returns

ApiKey.save()

Persist local edits to name/scopes (PATCH). Returns

ApiKeyScope

Jobs & batches

ParseJob

ParseJob.poll()

Re-fetch this job’s status from the API, updating this object in place. Arguments Returns Raises

ParseJob.wait()

Block (polling) until the job is terminal, mirrors File.wait. ponytail: dumb poll loop, the API offers no webhook. Arguments Returns Raises

ExtractJob

ExtractJob.poll()

Re-fetch this job’s status from the API, updating this object in place. Arguments Returns Raises

ExtractJob.wait()

Block (polling) until the job is terminal, mirrors File.wait. ponytail: dumb poll loop, the API offers no webhook. Arguments Returns Raises

BatchIngestJob

A running (or finished) batch ingestion. Returned by Workspace.ingest_many(mode=ExecMode.ASYNC). Uploads (and, when wait=True, ingestion polls) run in a background thread; read progress, succeeded, and failed at any time, or block with wait().

BatchIngestJob.poll()

Return the current progress. Mirror of the parse/extract job’s poll(); state updates itself in the background thread, so this just snapshots it.

BatchIngestJob.wait()

Block until the batch finishes, then return its result. Arguments Returns Raises

BatchIngest

Terminal result of a batch: the Files that succeeded and what failed.

BatchProgress

Live snapshot of a running batch (see BatchIngestJob.progress).

FailedIngest

One file that didn’t make it.

Streaming events

AskEvent

Represent a PEP 604 union type E.g. for int | str

SourcesEvent

The retrieved chunks, sent once before generation starts.

TokenEvent

One chunk of the answer as it generates.

DoneEvent

Generation finished; no further events follow.

Enums

AttributeType

Type of a content-type attribute column. select/multi_select require choices; the API also accepts the aliases multiselect and richtext for the hyphenated values used here.

DownloadPurpose

Which stored version of a file to download. The server falls back to original when the requested purpose has no associated file.

ExecMode

Execution mode for parse/extract: run inline or queue as an async job. Uppercase members (unlike the other enums here) so the async member can be ASYNC, lowercase async is a Python keyword and can’t be a member name.

FileStatus

Ingestion pipeline status for a File.

JobStatus

Status of an async parse/extract job. Only pending (initial) and completed (success) are documented by the API, the schema types status as a bare string with no enum and doesn’t publish the failure vocabulary. This enum is for call-site comparisons (StrEnum members equal their string values), NOT to validate the response field, so an unrecognized server value compares unequal rather than erroring. Detect terminal-failure via completed_at being set without completed (or, for parse, the error block) rather than a status string.

RelevanceScoring

Cross-encoder relevance scoring step for search.

ReprocessLevel

Reprocessing level queued on a File (pending_reprocess), update = replacement.

Role

Access role granted by an API-key scope on a workspace.

SearchMode

Retrieval mode for search/ask.

ThumbnailStatus

Whether a file’s thumbnail has been generated (uppercase, as the API sends).

Exceptions

Importable from lighton.exceptions. Every method that performs a request can raise these, so they are listed once here rather than repeated on each method. A method’s own Raises block covers only what it raises directly.