Generated from
lighton-sdk 1.2.0.
Install it and see runnable examples in the quick start.Client
LightOn
LightOn.ask()
Returns
Raises
LightOn.close()
LightOn.extract()
Returns
Raises
LightOn.parse()
Returns
Raises
LightOn.search()
Returns
LightOnConfiguration
Non-essential client knobs. api_key stays a direct LightOn() argument.Workspaces & files
Workspace
Workspace.create()
Returns
Workspace.delete()
Workspace.get()
Classmethod.
Returns
Workspace.ingest()
Returns
Raises
Workspace.ingest_many()
Returns
Raises
Workspace.list()
Classmethod.
Returns
Workspace.refresh()
Workspace.save()
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()
Returns
Raises
File.clear_attribute()
Returns
File.create()
Returns
Raises
File.delete()
File.delete_many()
Classmethod.
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()
Returns
Raises
File.download_thumbnail()
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()
Raises
File.get()
Classmethod.
Returns
File.get_by_name()
Classmethod.
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.
Returns
File.pages()
{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()
File.replace()
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()
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:
tagsreplaces 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 thelist[int]the request takes, which would clash on absorb.)external_metadatamerges into what’s stored, including insideadditional_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.
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()
Returns
File.tag()
Returns
Raises
File.unclassify()
Returns
File.untag()
Returns
Raises
File.wait()
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 intoadditional_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 checkstatus
before fetching: File.download_thumbnail() 404s while it isn’t READY.
wait_all
Returns
Raises
Tags & content types
Tag
Tag.create()
Returns
Tag.delete()
Tag.get()
Classmethod.
Tag.list()
Classmethod.
Returns
Tag.refresh()
ContentType
A node in the content-type taxonomy.ContentType.adopt()
Classmethod.
Returns
ContentType.batch()
Classmethod.
Returns
ContentType.define()
Classmethod.
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.
Returns
Raises
ContentType.list()
Classmethod.
children).
Arguments
Returns
ContentType.templates()
Classmethod.
adopt() (GET /content-types/templates).
Arguments
Returns
ContentType.undefine()
Classmethod.
Returns
ContentType.undefine_attribute()
Classmethod.
Returns
Template
A starter taxonomy from the catalog, whatadopt() 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.
Returns
Template.batch()
Classmethod.
Returns
Template.define()
Classmethod.
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.
Returns
Raises
Template.list()
Classmethod.
children).
Arguments
Returns
Template.templates()
Classmethod.
adopt() (GET /content-types/templates).
Arguments
Returns
Template.undefine()
Classmethod.
Returns
Template.undefine_attribute()
Classmethod.
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 currentvalue. 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()
Returns
ApiKey.delete()
ApiKey.get()
Classmethod.
Returns
ApiKey.list()
Classmethod.
Returns
ApiKey.refresh()
ApiKey.save()
ApiKeyScope
Jobs & batches
ParseJob
ParseJob.poll()
Returns
Raises
ParseJob.wait()
File.wait.
ponytail: dumb poll loop, the API offers no webhook.
Arguments
Returns
Raises
ExtractJob
ExtractJob.poll()
Returns
Raises
ExtractJob.wait()
File.wait.
ponytail: dumb poll loop, the API offers no webhook.
Arguments
Returns
Raises
BatchIngestJob
A running (or finished) batch ingestion. Returned byWorkspace.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()
BatchIngestJob.wait()
Returns
Raises
BatchIngest
Terminal result of a batch: the Files that succeeded and what failed.BatchProgress
Live snapshot of a running batch (seeBatchIngestJob.progress).
FailedIngest
One file that didn’t make it.Streaming events
AskEvent
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 tooriginal 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 beASYNC, 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. Onlypending (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 fromlighton.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.